io_uring: clamp CQ size to SQ size
authorJens Axboe <axboe@kernel.dk>
Sat, 20 Nov 2021 14:27:57 +0000 (07:27 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 20 Nov 2021 14:27:57 +0000 (07:27 -0700)
By default, io_uring uses twice as big a CQ ring as the SQ ring. That's
to help with cases where completions can come in unexpectedly. This is not
the case for storage IO, so just clamp the CQ size to save a bit of memory
on the CQEs and CQ ring.

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

index 8b8f35f1e6644b4cf4481956684a46b32de2a8f0..00ae34823f86ec32907700a8118c30a5d3e97ae1 100644 (file)
@@ -692,6 +692,13 @@ static int fio_ioring_queue_init(struct thread_data *td)
                }
        }
 
+       /*
+        * Clamp CQ ring size at our SQ ring size, we don't need more entries
+        * than that.
+        */
+       p.flags |= IORING_SETUP_CQSIZE;
+       p.cq_entries = depth;
+
        ret = syscall(__NR_io_uring_setup, depth, &p);
        if (ret < 0)
                return ret;
index b79822d72eba16dc85c89d944057cf04f9269200..7bf215c7188a6269e8a910749c7300c64055660a 100644 (file)
@@ -384,6 +384,13 @@ static int io_uring_register_files(struct submitter *s)
 
 static int io_uring_setup(unsigned entries, struct io_uring_params *p)
 {
+       /*
+        * Clamp CQ ring size at our SQ ring size, we don't need more entries
+        * than that.
+        */
+       p->flags |= IORING_SETUP_CQSIZE;
+       p->cq_entries = entries;
+
        return syscall(__NR_io_uring_setup, entries, p);
 }