public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/register: use atomic_read/write for sq_flags migration
@ 2025-01-24 21:34 Jens Axboe
  2025-01-25  6:47 ` lizetao
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Axboe @ 2025-01-24 21:34 UTC (permalink / raw)
  To: io-uring

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.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501242000.A2sKqaCL-lkp@intel.com/
Fixes: 2c5aae129f42 ("io_uring/register: document io_register_resize_rings() shared mem usage")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

diff --git a/io_uring/register.c b/io_uring/register.c
index 0db181437ae3..9a4d2fbce4ae 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -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));
 
-- 
Jens Axboe


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

* RE: [PATCH] io_uring/register: use atomic_read/write for sq_flags migration
  2025-01-24 21:34 [PATCH] io_uring/register: use atomic_read/write for sq_flags migration Jens Axboe
@ 2025-01-25  6:47 ` lizetao
  0 siblings, 0 replies; 2+ messages in thread
From: lizetao @ 2025-01-25  6:47 UTC (permalink / raw)
  To: Jens Axboe, io-uring



> -----Original Message-----
> From: Jens Axboe <axboe@kernel.dk>
> Sent: Saturday, January 25, 2025 5:35 AM
> To: io-uring <io-uring@vger.kernel.org>
> Subject: [PATCH] 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.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501242000.A2sKqaCL-
> lkp@intel.com/
> Fixes: 2c5aae129f42 ("io_uring/register: document io_register_resize_rings()
> shared mem usage")
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
> 
> diff --git a/io_uring/register.c b/io_uring/register.c index
> 0db181437ae3..9a4d2fbce4ae 100644
> --- a/io_uring/register.c
> +++ b/io_uring/register.c
> @@ -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));
> 
> --
> Jens Axboe
> 

Reviewed-by: Li Zetao <lizetao1@huawei.com>

--
Li Zetao

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

end of thread, other threads:[~2025-01-25  7:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 21:34 [PATCH] io_uring/register: use atomic_read/write for sq_flags migration Jens Axboe
2025-01-25  6:47 ` lizetao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox