public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create()
Date: Wed, 3 Sep 2025 17:16:39 -0600	[thread overview]
Message-ID: <51277999-41ec-45ad-a074-2352f46c882e@kernel.dk> (raw)
In-Reply-To: <CADUfDZrpJuq7QH47XTBvCFsENm88WQGX2YYnEPHat_UD6nLC=A@mail.gmail.com>

On 9/2/25 9:32 PM, Caleb Sander Mateos wrote:
> On Tue, Sep 2, 2025 at 6:20 PM Jens Axboe <axboe@kernel.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


      reply	other threads:[~2025-09-03 23:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 21:51 [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create() Caleb Sander Mateos
2025-09-03  1:20 ` Jens Axboe
2025-09-03  3:32   ` Caleb Sander Mateos
2025-09-03 23:16     ` Jens Axboe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51277999-41ec-45ad-a074-2352f46c882e@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox