]> git.baikalelectronics.ru Git - kernel.git/commit
hrtimer: Annotate lockless access to timer->base
authorEric Dumazet <edumazet@google.com>
Tue, 8 Oct 2019 17:32:04 +0000 (10:32 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 14 Oct 2019 13:51:49 +0000 (15:51 +0200)
commite3876ef2609f8fe68282c44f48b22dcdcb961176
treeff2aeaf672e1e411d2054ca722f7d0e84eec72f6
parent1eba4f95a783c5666881b1e9b4c3de4b05c4f502
hrtimer: Annotate lockless access to timer->base

Followup to commit 2e4885debb09 ("hrtimer: Protect lockless access
to timer->base")

lock_hrtimer_base() fetches timer->base without lock exclusion.

Compiler is allowed to read timer->base twice (even if considered dumb)
which could end up trying to lock migration_base and return
&migration_base.

  base = timer->base;
  if (likely(base != &migration_base)) {

       /* compiler reads timer->base again, and now (base == &migration_base)

       raw_spin_lock_irqsave(&base->cpu_base->lock, *flags);
       if (likely(base == timer->base))
            return base; /* == &migration_base ! */

Similarly the write sides must use WRITE_ONCE() to avoid store tearing.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191008173204.180879-1-edumazet@google.com
kernel/time/hrtimer.c