On Wed, Feb 25, 2026 at 04:13:35PM +0800, Stefan Hajnoczi wrote:
> 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 <[email protected]>
> ---
>  util/fdmon-io_uring.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)

Hi Jens,
I noticed liburing's io_uring_cq_ready() does not check the
IORING_SQ_TASKRUN flag. Maybe QEMU's fdmon_io_uring_gsource_check()
needs to check it here so that io_uring_enter(2) will be called with
IORING_ENTER_GETEVENTS in the glib event loop?

(This is a similar idea to your recent patch but needed when
IORING_SETUP_TASKRUN_FLAG is enabled.)

I tried to benchmark this but couldn't observe a difference in IOPS:

diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 652d269e03..ef4257924b 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -356,7 +356,8 @@ static bool fdmon_io_uring_gsource_check(AioContext *ctx)
      * the main loop can miss completions and sleep in ppoll() until the
      * next timer fires.
      */
-    return io_uring_cq_ready(&ctx->fdmon_io_uring);
+    return io_uring_cq_ready(&ctx->fdmon_io_uring) ||
+           (IO_URING_READ_ONCE(*ctx->fdmon_io_uring.sq.kflags) & 
IORING_SQ_TASKRUN);
 }

 /* Dispatch CQE handlers that are ready */

Attachment: signature.asc
Description: PGP signature

Reply via email to