fdmon-io_uring: check CQ ring directly in gsource_check
gsource_check() only looks at the ppoll revents for the io_uring fd, but CQEs can be posted during gsource_prepare()'s io_uring_submit() call via kernel task_work processing on syscall exit. These completions are already sitting in the CQ ring but the ring fd may not be signaled yet, causing gsource_check() to return false. Add a fallback io_uring_cq_ready() check so completions that arrive during submission are dispatched immediately rather than waiting for the next ppoll() cycle. Signed-off-by: Jens Axboe <axboe@kernel.dk> Message-ID: <20260213143225.161043-3-axboe@kernel.dk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Jens Axboe committed
Feb 13, 2026 at 07:26 UTC
961fcc0f22768e7c3432fc645b93dc7cd4932fae
1 file changed
+13
-1
util/fdmon-io_uring.c
+13
-1
@@ -344,7 +344,19 @@ static void fdmon_io_uring_gsource_prepare(AioContext *ctx)
344
static bool fdmon_io_uring_gsource_check(AioContext *ctx)
345
{
346
gpointer tag = ctx->io_uring_fd_tag;
347
- return g_source_query_unix_fd(&ctx->source, tag) & G_IO_IN;
347
+
348
+ /* Check ppoll revents (normal path) */
349
+ if (g_source_query_unix_fd(&ctx->source, tag) & G_IO_IN) {
350
+ return true;
351
+ }
352
+
353
+ /*
354
+ * Also check for CQEs that may have been posted during prepare's
355
+ * io_uring_submit() via task_work on syscall exit. Without this,
356
+ * the main loop can miss completions and sleep in ppoll() until the
357
+ * next timer fires.
358
+ */
359
+ return io_uring_cq_ready(&ctx->fdmon_io_uring);
360
}
361
362
/* Dispatch CQE handlers that are ready */