Re: [PATCH 03/11] fs: aio: Use acquire/release for ring->tail publication

From: Jinjie Ruan

Date: Mon Aug 31 2026 - 21:44:27 EST




在 2026/8/31 20:13, Jan Kara 写道:
> On Tue 25-08-26 17:54:14, Jinjie Ruan wrote:
>> Replace the smp_wmb() + WRITE_ONCE(ring->tail) and READ_ONCE(ring->tail)
>> + smp_rmb() barrier pair with smp_store_release()/smp_load_acquire()
>> on `ring->tail`.
>>
>> This expresses the publish/subscribe pattern more clearly and allows
>> architectures with native acquire/release instructions (e.g. arm64's
>> STLR/LDAR) to avoid the cost of full one-way barriers (DMB ISHST/ISHLD).
>>
>> The release ensures event data written before updating ring->tail is
>> visible to readers that observe the new tail value via acquire, which
>> is exactly the ordering the barrier pair provided.
>>
>> No functional change intended.
>>
>> Assisted-by: DeepSeek:DeepSeek-V3
>> Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
>
> The patch looks good. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@xxxxxxx>
>
> Just one nit below:
>
>> diff --git a/fs/aio.c b/fs/aio.c
>> index d78acc69f487..4413c82688cc 100644
>> --- a/fs/aio.c
>> +++ b/fs/aio.c
>> @@ -1206,13 +1206,12 @@ static void aio_complete(struct aio_kiocb *iocb)
>> /* after flagging the request as done, we
>> * must never even look at it again
>> */
>> - smp_wmb(); /* make event visible before updating tail */
>> -
>> - ctx->tail = tail;
>> + WRITE_ONCE(ctx->tail, tail);
>
> I don't thing ctx->tail is accessed anywhere outside of completion_lock so
> I think this WRITE_ONCE is pointless.

I agree with that. I'll drop the unnecessary WRITE_ONCE in v2.

>
> Honza