[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51277999-41ec-45ad-a074-2352f46c882e@kernel.dk>
Date: Wed, 3 Sep 2025 17:16:39 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Caleb Sander Mateos <csander@...estorage.com>
Cc: io-uring@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create()
On 9/2/25 9:32 PM, Caleb Sander Mateos wrote:
> On Tue, Sep 2, 2025 at 6:20 PM Jens Axboe <axboe@...nel.dk> wrote:
>>
>> On 9/2/25 3:51 PM, Caleb Sander Mateos wrote:
>>> There's no need to use WRITE_ONCE() to set ctx->submitter_task in
>>> io_uring_create() since no other thread can access the io_ring_ctx until
>>> a file descriptor is associated with it. So use a normal assignment
>>> instead of WRITE_ONCE().
>>
>> Would probably warrant a code comment to that effect, as just reading
>> the code would be slightly confusing after this.
>
> Could you elaborate on why you find it confusing? I wouldn't expect to
> see WRITE_ONCE() or any other atomic operation used when initializing
> memory prior to it being made accessible from other threads. It looks
> like commit 8579538c89e3 ("io_uring/msg_ring: fix remote queue to
> disabled ring") added the WRITE_ONCE() both here and in
> io_register_enable_rings(). But it's only needed in
> io_register_enable_rings(), where the io_ring_ctx already has an
> associated file descriptor and may be accessed concurrently from
> multiple threads.
Just add simple comment saying something like "No need for a WRITE_ONCE()
here, as it's before the ring is visible/enabled". Otherwise I bet I'll
be fielding a patch for that in the future.
--
Jens Axboe
Powered by blists - more mailing lists