From 4d22c1037dafdac3d9bf30a3fb39d88f4391e41a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 31 Aug 2022 13:45:32 -0600 Subject: [PATCH] engines/io_uring: set COOP_TASKRUN for ring setup If available, this will generally improve performance quite a bit. Fio can easily use it, we just need to set the flag. IORING_SETUP_COOP_TASKRUN tells the kernel that the application doesn't need to get rescheduled to handle task_work, it's fine to defer this to when we transition anyway. For a QD=8 random read workload, this increases performance from 680K to 870K IOPS. Signed-off-by: Jens Axboe --- engines/io_uring.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/io_uring.c b/engines/io_uring.c index 94376efa..a51468f5 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -809,9 +809,19 @@ static int fio_ioring_queue_init(struct thread_data *td) p.flags |= IORING_SETUP_CQSIZE; p.cq_entries = depth; + /* + * Setup COOP_TASKRUN as we don't need to get IPI interrupted for + * completing IO operations. + */ + p.flags |= IORING_SETUP_COOP_TASKRUN; + retry: ret = syscall(__NR_io_uring_setup, depth, &p); if (ret < 0) { + if (errno == EINVAL && p.flags & IORING_SETUP_COOP_TASKRUN) { + p.flags &= ~IORING_SETUP_COOP_TASKRUN; + goto retry; + } if (errno == EINVAL && p.flags & IORING_SETUP_CQSIZE) { p.flags &= ~IORING_SETUP_CQSIZE; goto retry; -- 2.25.1