io_uring/nop: add IORING_NOP_TW completion flag
authorJens Axboe <axboe@kernel.dk>
Fri, 13 Jun 2025 23:05:19 +0000 (17:05 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Jun 2025 23:05:19 +0000 (17:05 -0600)
To test and profile the overhead of io_uring task_work and the various
types of it, add IORING_NOP_TW which tells nop to signal completions
through task_work rather than complete them inline.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/uapi/linux/io_uring.h
io_uring/nop.c

index cfd17e382082fa38427bbc8dcba3d89b022afe4c..8c3d43caab02d113acfc47865ed585ab8b362a88 100644 (file)
@@ -449,6 +449,7 @@ enum io_uring_msg_ring_flags {
 #define IORING_NOP_FILE                        (1U << 1)
 #define IORING_NOP_FIXED_FILE          (1U << 2)
 #define IORING_NOP_FIXED_BUFFER                (1U << 3)
+#define IORING_NOP_TW                  (1U << 4)
 
 /*
  * IO completion data structure (Completion Queue Entry)
index 6ac2de761fd37b66d7e1b58fe2baa76618be38ce..20ed0f85b1c2b66130b27cfeeb6539e86accf284 100644 (file)
@@ -20,7 +20,8 @@ struct io_nop {
 };
 
 #define NOP_FLAGS      (IORING_NOP_INJECT_RESULT | IORING_NOP_FIXED_FILE | \
-                        IORING_NOP_FIXED_BUFFER | IORING_NOP_FILE)
+                        IORING_NOP_FIXED_BUFFER | IORING_NOP_FILE | \
+                        IORING_NOP_TW)
 
 int io_nop_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 {
@@ -68,5 +69,10 @@ done:
        if (ret < 0)
                req_set_fail(req);
        io_req_set_res(req, nop->result, 0);
+       if (nop->flags & IORING_NOP_TW) {
+               req->io_task_work.func = io_req_task_complete;
+               io_req_task_work_add(req);
+               return IOU_ISSUE_SKIP_COMPLETE;
+       }
        return IOU_COMPLETE;
 }