io_uring/register: use atomic_read/write for sq_flags migration
Jens Axboe
maintainerPATCH 1/1 io_uring/register: use atomic_read/write for sq_flags migration
A previous commit changed all of the migration from the old to the new ring for resizing to use READ/WRITE_ONCE. However, ->sq_flags is an atomic_t, and while most archs won't complain on this, some will indeed flag this:
io_uring/register.c:554:9: sparse: sparse: cast to non-scalar io_uring/register.c:554:9: sparse: sparse: cast from non-scalar
Just use atomic_set/atomic_read for handling this case.
---
io_uring/register.c +1 -1
@@ -552,7 +552,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) ctx->cqe_cached = ctx->cqe_sentinel =NULL ;WRITE_ONCE (n.rings->sq_dropped,READ_ONCE (o.rings->sq_dropped)); -WRITE_ONCE (n.rings->sq_flags,READ_ONCE (o.rings->sq_flags)); +atomic_set (&n.rings->sq_flags,atomic_read (&o.rings->sq_flags));WRITE_ONCE (n.rings->cq_flags,READ_ONCE (o.rings->cq_flags));WRITE_ONCE (n.rings->cq_overflow,READ_ONCE (o.rings->cq_overflow));
Signature · 1 line
Jens Axboe
Quoted 41 lines
-----Original Message-----
From: Jens Axboe <[email protected]>
Sent: Saturday, January 25, 2025 5:35 AM
To: io-uring <[email protected]>
Subject: [PATCH]io_uring/register: use atomic_read/write forsq_flagsmigrationA previous commit changed all of the migration from the old to the new ring for resizing to use READ/WRITE_ONCE. However, ->sq_flags is an
atomic_t, and while most archs won't complain on this, some will indeed flag this:
io_uring/register.c:554:9: sparse: sparse: cast to non-scalario_uring/register.c:554:9: sparse: sparse: cast from non-scalarJust use atomic_set/atomic_read for handling this case.
Reported-by kernel test robot <[email protected]>Fixes 2c5aae129f42 ("io_uring/register: document io_register_resize_rings()shared mem usage")
Signed-off-by Jens Axboe <[email protected]>---
io_uring/register.c index renamed from io_uring/register.c +0
-0
0db181437ae3..9a4d2fbce4ae100644io_uring/register.c +1
-1@@ -552,7 +552,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg) ctx->cqe_cached = ctx->cqe_sentinel =NULL ;WRITE_ONCE (n.rings->sq_dropped,READ_ONCE (o.rings- >sq_dropped)); -WRITE_ONCE (n.rings->sq_flags,READ_ONCE (o.rings->sq_flags)); +atomic_set (&n.rings->sq_flags,atomic_read (&o.rings->sq_flags));WRITE_ONCE (n.rings->cq_flags,READ_ONCE (o.rings->cq_flags));WRITE_ONCE(n.rings->cq_overflow, READ_ONCE(o.rings-
Quoted 5 lines
Quoted 1 line
cq_overflow));--
Jens Axboe
--
Li Zetao