From: Keith Busch <kbusch@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Keith Busch <kbusch@meta.com>,
io-uring@vger.kernel.org, superman.xpt@gmail.com
Subject: Re: [PATCH] io_uring: consistently use rcu semantics with sqpoll thread
Date: Tue, 10 Jun 2025 15:04:56 -0600 [thread overview]
Message-ID: <aEid-Nx11aEPT6Fd@kbusch-mbp> (raw)
In-Reply-To: <b482578b-3418-4f97-b676-41986630a5ee@kernel.dk>
On Tue, Jun 10, 2025 at 02:52:28PM -0600, Jens Axboe wrote:
> Ah we can probably get by with just a bit more work, something like
> this per section should do it.
Nice, and it clears up the data_race() usage with the assignment and
access both under the sqd mutex.
> diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
> index 0625a421626f..8852e104ed68 100644
> --- a/io_uring/sqpoll.c
> +++ b/io_uring/sqpoll.c
> @@ -46,13 +46,18 @@ void io_sq_thread_unpark(struct io_sq_data *sqd)
> void io_sq_thread_park(struct io_sq_data *sqd)
> __acquires(&sqd->lock)
> {
> - WARN_ON_ONCE(data_race(sqd->thread) == current);
> + struct task_struct *tsk;
>
> atomic_inc(&sqd->park_pending);
> set_bit(IO_SQ_THREAD_SHOULD_PARK, &sqd->state);
> mutex_lock(&sqd->lock);
> - if (sqd->thread)
> - wake_up_process(sqd->thread);
> + rcu_read_lock();
> + tsk = rcu_dereference(sqd->thread);
> + if (tsk) {
> + WARN_ON_ONCE(tsk == current);
> + wake_up_process(tsk);
> + }
> + rcu_read_unlock();
> }
>
> void io_sq_thread_stop(struct io_sq_data *sqd)
>
> --
> Jens Axboe
prev parent reply other threads:[~2025-06-10 21:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 19:30 [PATCH] io_uring: consistently use rcu semantics with sqpoll thread Keith Busch
2025-06-10 20:04 ` Jens Axboe
2025-06-10 20:20 ` Keith Busch
2025-06-10 20:45 ` Jens Axboe
2025-06-10 20:52 ` Jens Axboe
2025-06-10 21:04 ` Keith Busch [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=aEid-Nx11aEPT6Fd@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@meta.com \
--cc=superman.xpt@gmail.com \
/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