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 14:20:49 -0600 [thread overview]
Message-ID: <aEiToYXiUneeNFq_@kbusch-mbp> (raw)
In-Reply-To: <c2f09260-46c8-4108-b190-232c025947df@kernel.dk>
On Tue, Jun 10, 2025 at 02:04:41PM -0600, Jens Axboe wrote:
> On 6/10/25 1:30 PM, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> >
> > It is already dereferenced with rcu read protection, so it needs to be
> > annotated as such, and consistently use rcu helpers for access and
> > assignment.
>
> There are some bits in io_uring.c that access it, which probably need
> some attention too I think. One of them a bit trickier.
Oh, sure is. I just ran 'make C=1' on the originally affected files, but
should have ran it on all of io_uring/.
I think the below should clear up the new warnings. I think it's safe to
hold the rcu read lock for the tricky one as io_wq_cancel_cb() doesn't
appear to make any blocking calls.
---
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index cf759c172083c..c6502197eb6b2 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2906,10 +2906,12 @@ static __cold void io_ring_exit_work(struct work_struct *work)
struct task_struct *tsk;
io_sq_thread_park(sqd);
- tsk = sqd->thread;
+ rcu_read_lock();
+ tsk = rcu_dereference(sqd->thread);
if (tsk && tsk->io_uring && tsk->io_uring->io_wq)
io_wq_cancel_cb(tsk->io_uring->io_wq,
io_cancel_ctx_cb, ctx, true);
+ rcu_read_unlock();
io_sq_thread_unpark(sqd);
}
@@ -3142,7 +3144,7 @@ __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd)
s64 inflight;
DEFINE_WAIT(wait);
- WARN_ON_ONCE(sqd && sqd->thread != current);
+ WARN_ON_ONCE(sqd && rcu_access_pointer(sqd->thread) != current);
if (!current->io_uring)
return;
--
next prev parent reply other threads:[~2025-06-10 20:20 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 [this message]
2025-06-10 20:45 ` Jens Axboe
2025-06-10 20:52 ` Jens Axboe
2025-06-10 21:04 ` Keith Busch
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=aEiToYXiUneeNFq_@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.