From 1db268db68823f0fa4c4a4701d3deee88b4c1d84 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 20 Nov 2021 07:27:57 -0700 Subject: [PATCH] io_uring: clamp CQ size to SQ size 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 --- engines/io_uring.c | 7 +++++++ t/io_uring.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/engines/io_uring.c b/engines/io_uring.c index 8b8f35f1..00ae3482 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -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; diff --git a/t/io_uring.c b/t/io_uring.c index b79822d7..7bf215c7 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -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); } -- 2.25.1