timers: Fix data race in timer_stats_account_timer()
authorDmitry Vyukov <dvyukov@google.com>
Fri, 18 Sep 2015 13:54:23 +0000 (15:54 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 22 Sep 2015 13:43:18 +0000 (15:43 +0200)
commit3ed769bdb2a2484fd7f9f7f3047413053aacbe21
tree75f0039968b1b80ffe61b6d446f34ade7b24cf11
parent571af55a31d3652ac1f758f116835a76d0335661
timers: Fix data race in timer_stats_account_timer()

timer_stats_account_timer() reads timer->start_site, then checks it
for NULL and then re-reads it again, while
timer_stats_timer_clear_start_info() can concurrently reset
timer->start_site to NULL. This should not lead to crashes, but can
double number of entries in timer stats as start_site is used during
comparison, the doubled entries will have unuseful NULL start_site.

Read timer->start_site only once in timer_stats_account_timer().

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Cc: andreyknvl@google.com
Cc: glider@google.com
Cc: kcc@google.com
Cc: ktsan@googlegroups.com
Cc: john.stultz@linaro.org
Link: http://lkml.kernel.org/r/1442584463-69553-1-git-send-email-dvyukov@google.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/time/timer.c