Skip to contentSkip to conversation

io_uring: remove WRITE_ONCE() in io_uring_create()

PATCH Applied Caleb Sander Mateos 2 participants 2 messages Sep 4, 2025 – Sep 5, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 io_uring: remove WRITE_ONCE() in io_uring_create()

There's no need to use WRITE_ONCE() to set ctx->submitter_task in io_uring_create() since no other task can access the io_ring_ctx until a file descriptor is associated with it. So use a normal assignment instead of WRITE_ONCE().

---
 io_uring/io_uring.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
io_uring/io_uring.c +7 -2
index 6c07efac977c..20dfa5ef75dc 100644
@@ -3889,12 +3889,17 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
 		ret = -EFAULT;
 		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->flags & IORING_SETUP_R_DISABLED)) {
+		/*
+		 * Unlike io_register_enable_rings(), don't need WRITE_ONCE()
+		 * since ctx isn't yet accessible from other tasks
+		 */
+		ctx->submitter_task = get_task_struct(current);
+	}
 
 	file = io_uring_get_file(ctx);
 	if (IS_ERR(file)) {
 		ret = PTR_ERR(file);
 		goto err;
Signature · 1 line
2.45.2
maintainer Applied
#1 lore raw
Quoted 6 lines · Caleb Sander Mateos

There's no need to use WRITE_ONCE() to set ctx->submitter_task in io_uring_create() since no other task can access the io_ring_ctx until a file descriptor is associated with it. So use a normal assignment instead of WRITE_ONCE().

Applied, thanks!

[1/1] io_uring: remove WRITE_ONCE() in io_uring_create()
(no commit info)

Best regards,

Signature · 1 line
Jens Axboe