engines/io_uring: set single issuer and defer taskrun
authorJens Axboe <axboe@kernel.dk>
Wed, 31 Aug 2022 20:14:29 +0000 (14:14 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 31 Aug 2022 20:14:29 +0000 (14:14 -0600)
If available, set these two flags as well. SINGLE_ISSUER tells the kernel
that it can expect that it's just a single task issuing requests, and
DEFER_TASKRUN tells the kernel that we're fine with deferring task_work
runs until we reap events.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c
os/linux/io_uring.h

index a51468f5b0dd528c3a27b738e9ad9821d4860ca8..d0fc61dcac394e69419b78232c86be4aa69a7fab 100644 (file)
@@ -815,9 +815,20 @@ static int fio_ioring_queue_init(struct thread_data *td)
         */
        p.flags |= IORING_SETUP_COOP_TASKRUN;
 
+       /*
+        * io_uring is always a single issuer, and we can defer task_work
+        * runs until we reap events.
+        */
+       p.flags |= IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN;
+
 retry:
        ret = syscall(__NR_io_uring_setup, depth, &p);
        if (ret < 0) {
+               if (errno == EINVAL && p.flags & IORING_SETUP_DEFER_TASKRUN) {
+                       p.flags &= ~IORING_SETUP_DEFER_TASKRUN;
+                       p.flags &= ~IORING_SETUP_SINGLE_ISSUER;
+                       goto retry;
+               }
                if (errno == EINVAL && p.flags & IORING_SETUP_COOP_TASKRUN) {
                        p.flags &= ~IORING_SETUP_COOP_TASKRUN;
                        goto retry;
index 929997f8277d9b09f8555d90785074e9da534bc7..6604e7360749909732724f934bce74009be00c3e 100644 (file)
@@ -131,6 +131,18 @@ enum {
 #define IORING_SETUP_SQE128            (1U << 10) /* SQEs are 128 byte */
 #define IORING_SETUP_CQE32             (1U << 11) /* CQEs are 32 byte */
 
+/*
+ * Only one task is allowed to submit requests
+ */
+#define IORING_SETUP_SINGLE_ISSUER     (1U << 12)
+
+/*
+ * Defer running task work to get events.
+ * Rather than running bits of task work whenever the task transitions
+ * try to do it just before it is needed.
+ */
+#define IORING_SETUP_DEFER_TASKRUN     (1U << 13)
+
 enum {
        IORING_OP_NOP,
        IORING_OP_READV,