[tip: timers/core] timers: Use accessor for hrtimer_sleeper ->task field in sleep_timeout.c
From: tip-bot2 for Paul E. McKenney
Date: Tue Sep 29 2026 - 15:06:18 EST
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 9b7bcd671e9c979f16c48589f4b9b6c684ab052f
Gitweb: https://git.kernel.org/tip/9b7bcd671e9c979f16c48589f4b9b6c684ab052f
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
AuthorDate: Fri, 18 Sep 2026 17:14:22 -07:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 29 Sep 2026 21:02:52 +02:00
timers: Use accessor for hrtimer_sleeper ->task field in sleep_timeout.c
The hrtimer_sleeper structure's ->task field is used as a flag to indicate
that the associated hrtimer has expired. This means that the hrtimer
handler can be storing to this field while other code is loading from it
to check for expiry. Note that additional races appear for hrtimers that
can be restarted, which could be argued to be a user error. However, that
is no reason to let the compiler introduce additional confusion, and to
this end, the hrtimer_sleeper_task_get() was introduced, use of which also
has the benefit of avoiding open-code access to hrtimer_sleeper innards.
Therefore, apply this accessor to schedule_hrtimeout_range_clock().
KCSAN located this issue.
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Reviewed-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>
Link: https://patch.msgid.link/20260919001428.3133388-6-paulmck@xxxxxxxxxx
---
kernel/time/sleep_timeout.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/time/sleep_timeout.c b/kernel/time/sleep_timeout.c
index 3c90574..ad8c415 100644
--- a/kernel/time/sleep_timeout.c
+++ b/kernel/time/sleep_timeout.c
@@ -212,7 +212,7 @@ int __sched schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta,
hrtimer_set_expires_range_ns(&t.timer, *expires, delta);
hrtimer_sleeper_start_expires(&t, mode);
- if (likely(t.task))
+ if (likely(hrtimer_sleeper_task_get(&t)))
schedule();
hrtimer_cancel(&t.timer);
@@ -220,7 +220,7 @@ int __sched schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta,
__set_current_state(TASK_RUNNING);
- return !t.task ? 0 : -EINTR;
+ return !hrtimer_sleeper_task_get(&t) ? 0 : -EINTR;
}
EXPORT_SYMBOL_GPL(schedule_hrtimeout_range_clock);