From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
Brian Song <hibriansong@gmail.com>,
qemu-block@nongnu.org, Bernd Schubert <bschubert@ddn.com>,
Kevin Wolf <kwolf@redhat.com>,
h0lyalg0rithm@git.sr.ht, Fam Zheng <fam@euphon.net>
Subject: [RFC 3/3] aio-posix: enable IORING_SETUP_COOP_TASKRUN | IORING_SETUP_TASKRUN_FLAG
Date: Thu, 24 Jul 2025 16:47:02 -0400 [thread overview]
Message-ID: <20250724204702.576637-4-stefanha@redhat.com> (raw)
In-Reply-To: <20250724204702.576637-1-stefanha@redhat.com>
The IORING_SETUP_COOP_TASKRUN flag reduces interprocessor interrupts
when an io_uring event occurs on a different CPU. The idea is that the
QEMU thread will wait for a CQE anyway, so there is no need to interrupt
the CPU that it is on.
The IORING_SETUP_TASKRUN_FLAG ensures that QEMU's io_uring CQ ring
polling still works with COOP_TASKRUN. The kernel will set a flag in the
SQ ring (this is not a typo, the flag is located in the SQ ring even
though it pertains to the CQ ring) that can be polled from userspace.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
util/fdmon-io_uring.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 4798439097..649dc18907 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -428,13 +428,16 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHandlerList *ready_list,
static bool fdmon_io_uring_need_wait(AioContext *ctx)
{
+ struct io_uring *ring = &ctx->fdmon_io_uring;
+
/* Have io_uring events completed? */
- if (io_uring_cq_ready(&ctx->fdmon_io_uring)) {
+ if (io_uring_cq_ready(ring) ||
+ IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_TASKRUN) {
return true;
}
/* Are there pending sqes to submit? */
- if (io_uring_sq_ready(&ctx->fdmon_io_uring)) {
+ if (io_uring_sq_ready(ring)) {
return true;
}
@@ -465,7 +468,7 @@ void fdmon_io_uring_setup(AioContext *ctx, Error **errp)
{
int ret;
/* TODO only enable these flags if they are available in the host's kernel headers */
- unsigned flags = 0;
+ unsigned flags = IORING_SETUP_COOP_TASKRUN | IORING_SETUP_TASKRUN_FLAG;
ctx->io_uring_fd_tag = NULL;
--
2.50.1
prev parent reply other threads:[~2025-07-24 20:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 20:46 [RFC 0/3] aio-posix: enable io_uring SINGLE_ISSUER and TASKRUN flags Stefan Hajnoczi
2025-07-24 20:47 ` [RFC 1/3] iothread: create AioContext in iothread_run() Stefan Hajnoczi
2025-07-24 20:47 ` [RFC 2/3] aio-posix: enable IORING_SETUP_SINGLE_ISSUER Stefan Hajnoczi
2025-07-24 20:47 ` Stefan Hajnoczi [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=20250724204702.576637-4-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=bschubert@ddn.com \
--cc=fam@euphon.net \
--cc=h0lyalg0rithm@git.sr.ht \
--cc=hibriansong@gmail.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).