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>
}
}
+ /*
+ * 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;
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);
}