Re: [PATCH RFC 1/9] hrtimer: Mark data-racy accesses to hrtimer_sleeper ->task field

From: Dmitry Ilvokhin

Date: Tue Aug 04 2026 - 13:25:59 EST


On Thu, Jul 30, 2026 at 05:40:11PM -0700, Paul E. McKenney wrote:
> 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.
>
> Therefore, mark data-racy accesses to the hrtimer_sleeper ->task field
> using READ_ONCE() (using a new hrtimer_sleeper_task_get() access function)
> and WRITE_ONCE() (using a new hrtimer_sleeper_task_set() access function).
>
> KCSAN located this issue.
>
> Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>

Reviewed-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>