linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create()
@ 2025-09-02 21:51 Caleb Sander Mateos
  2025-09-03  1:20 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Caleb Sander Mateos @ 2025-09-02 21:51 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Caleb Sander Mateos, io-uring, linux-kernel

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().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 io_uring/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 6c07efac977c..545a7d5eefec 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3890,11 +3890,11 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
 		goto err;
 	}
 
 	if (ctx->flags & IORING_SETUP_SINGLE_ISSUER
 	    && !(ctx->flags & IORING_SETUP_R_DISABLED))
-		WRITE_ONCE(ctx->submitter_task, get_task_struct(current));
+		ctx->submitter_task = get_task_struct(current);
 
 	file = io_uring_get_file(ctx);
 	if (IS_ERR(file)) {
 		ret = PTR_ERR(file);
 		goto err;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create()
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2025-09-03  1:20 UTC (permalink / raw)
  To: Caleb Sander Mateos; +Cc: io-uring, linux-kernel

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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: remove WRITE_ONCE() in io_uring_create()
  2025-09-03  1:20 ` Jens Axboe
@ 2025-09-03  3:32   ` Caleb Sander Mateos
  0 siblings, 0 replies; 3+ messages in thread
From: Caleb Sander Mateos @ 2025-09-03  3:32 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, linux-kernel

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.

Thanks,
Caleb

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-03  3:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).