From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org, Keith Busch <kbusch@meta.com>
Cc: superman.xpt@gmail.com, Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCHv2] io_uring: consistently use rcu semantics with sqpoll thread
Date: Thu, 12 Jun 2025 08:18:17 -0600 [thread overview]
Message-ID: <8df4ced5-7c26-44f3-b2c3-a0ee1e337ebb@kernel.dk> (raw)
In-Reply-To: <174967568374.462788.11409454167475921556.b4-ty@kernel.dk>
On 6/11/25 3:01 PM, Jens Axboe wrote:
>
> On Wed, 11 Jun 2025 13:53:43 -0700, Keith Busch wrote:
>> The sqpoll thread is dereferenced with rcu read protection in one place,
>> so it needs to be annotated as an __rcu type, and should consistently
>> use rcu helpers for access and assignment to make sparse happy.
>>
>> Since most of the accesses occur under the sqd->lock, we can use
>> rcu_dereference_protected() without declaring an rcu read section.
>> Provide a simple helper to get the thread from a locked context.
>>
>> [...]
>
> Applied, thanks!
>
> [1/1] io_uring: consistently use rcu semantics with sqpoll thread
> commit: 89f607e88c9f885187a0144d0b540fb257b912ea
Folded in the below, looks like that one was missed. We should probably
have renamed ->thread to avoid this kind of stuff, but oh well.
diff --git a/io_uring/register.c b/io_uring/register.c
index cc23a4c205cd..a59589249fce 100644
--- a/io_uring/register.c
+++ b/io_uring/register.c
@@ -273,6 +273,8 @@ static __cold int io_register_iowq_max_workers(struct io_ring_ctx *ctx,
if (ctx->flags & IORING_SETUP_SQPOLL) {
sqd = ctx->sq_data;
if (sqd) {
+ struct task_struct *tsk;
+
/*
* Observe the correct sqd->lock -> ctx->uring_lock
* ordering. Fine to drop uring_lock here, we hold
@@ -282,8 +284,9 @@ static __cold int io_register_iowq_max_workers(struct io_ring_ctx *ctx,
mutex_unlock(&ctx->uring_lock);
mutex_lock(&sqd->lock);
mutex_lock(&ctx->uring_lock);
- if (sqd->thread)
- tctx = sqd->thread->io_uring;
+ tsk = sqpoll_task_locked(sqd);
+ if (tsk)
+ tctx = tsk->io_uring;
}
} else {
tctx = current->io_uring;
--
Jens Axboe
prev parent reply other threads:[~2025-06-12 14:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 20:53 [PATCHv2] io_uring: consistently use rcu semantics with sqpoll thread Keith Busch
2025-06-11 21:01 ` Jens Axboe
2025-06-12 14:18 ` Jens Axboe [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=8df4ced5-7c26-44f3-b2c3-a0ee1e337ebb@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@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