mirror of
https://github.com/torvalds/linux.git
synced 2026-10-28 17:55:02 +01:00
hrtimer: Apply READ_ONCE() to lockless base->running loads
Updates to base->running are protected by the hrtimer base lock, but some loads are lockless. Therefore, prevent compiler mischief by applying READ_ONCE() to the lockless loads. KCSAN located this issue. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260919001428.3133388-12-paulmck@kernel.org
This commit is contained in:
parent
ad80926d78
commit
5dffe33bfd
|
|
@ -2004,7 +2004,7 @@ bool hrtimer_active(const struct hrtimer *timer)
|
|||
base = READ_ONCE(timer->base);
|
||||
seq = raw_read_seqcount_begin(&base->seq);
|
||||
|
||||
if (timer->is_queued || base->running == timer)
|
||||
if (timer->is_queued || READ_ONCE(base->running) == timer)
|
||||
return true;
|
||||
|
||||
} while (read_seqcount_retry(&base->seq, seq) || base != READ_ONCE(timer->base));
|
||||
|
|
@ -2041,7 +2041,7 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, struct hrtimer_cloc
|
|||
lockdep_assert_held(&cpu_base->lock);
|
||||
|
||||
debug_hrtimer_deactivate(timer);
|
||||
base->running = timer;
|
||||
WRITE_ONCE(base->running, timer);
|
||||
|
||||
/*
|
||||
* Separate the ->running assignment from the ->is_queued assignment.
|
||||
|
|
@ -2100,7 +2100,7 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, struct hrtimer_cloc
|
|||
raw_write_seqcount_barrier(&base->seq);
|
||||
|
||||
WARN_ON_ONCE(base->running != timer);
|
||||
base->running = NULL;
|
||||
WRITE_ONCE(base->running, NULL);
|
||||
}
|
||||
|
||||
static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user