public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: lizetao <lizetao1@huawei.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring <io-uring@vger.kernel.org>
Subject: RE: [PATCH] io_uring/register: use atomic_read/write for sq_flags migration
Date: Sat, 25 Jan 2025 06:47:45 +0000	[thread overview]
Message-ID: <6e3287d0d5c349a4a511ab338bb8fd3a@huawei.com> (raw)
In-Reply-To: <58689f80-097c-4644-a748-2e848629b379@kernel.dk>



> -----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

      reply	other threads:[~2025-01-25  7:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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=6e3287d0d5c349a4a511ab338bb8fd3a@huawei.com \
    --to=lizetao1@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@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