Re: [PATCH RFC 2/9] aio: Use accessor for hrtimer_sleeper ->task field

Jan Kara <[email protected]> Fri, 31 Jul 2026 14:32:12 +0200
Newsgroups gmane.linux.kernel.aio.general,gmane.linux.kernel,gmane.linux.file-systems
Message-ID <pkeixgcd65n4mmxlrsw3i2getbkrzyybgd27h4iralrmp53llg@bczwlw3f7fzd>
On Thu 30-07-26 17:40:12, 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, 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.
> 
> KCSAN located this issue.
> 
> Signed-off-by: Paul E. McKenney <[email protected]>
> Cc: Benjamin LaHaise <[email protected]>
> Cc: Alexander Viro <[email protected]>
> Cc: Christian Brauner <[email protected]>
> Cc: Jan Kara <[email protected]>
> Cc: Anna-Maria Behnsen <[email protected]>
> Cc: Frederic Weisbecker <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: <[email protected]>
> Cc: <[email protected]>

Looks good. Feel free to add:

Acked-by: Jan Kara <[email protected]>

								Honza

> ---
>  fs/aio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index f57fa21a250353..e8cd65fce41eba 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -1402,7 +1402,7 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr,
>  		w.min_nr = min_nr - ret;
>  
>  		ret2 = prepare_to_wait_event(&ctx->wait, &w.w, TASK_INTERRUPTIBLE);
> -		if (!ret2 && !t.task)
> +		if (!ret2 && !hrtimer_sleeper_task_get(&t))
>  			ret2 = -ETIME;
>  
>  		if (aio_read_events(ctx, min_nr, nr, event, &ret) || ret2)
> -- 
> 2.40.1
> 
-- 
Jan Kara <[email protected]>
SUSE Labs, CR

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to [email protected].  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>