This patch set and a corresponding kernel patch set are fixes and optimizations resulting from running unit test 500f9fbadef8-test. - Patch 1 is a fix to the test hanging when it runs on a non-mq queue. The patch preserves the value of wait_nr if SETUP_IOPOLL is set since otherwise __sys_io_uring_enter() could never be called __io_uring_peek_cqe() could never find new completions. With this patch applied, two problems were hit in the kernel as described in the kernel patch set, which caused 500f9fbadef8-test to fail and to hang. With all three patches, 500f9fbadef8-test either passes successfully or skips the test gracefully with the following message: Polling not supported in current dir, test skipped - Patch 2 is an optimization for io_uring_enter() system calls. If we want to wait for completions (wait_nr > 0), account for the completion we might fetch with __io_uring_peek_cqe(). For example, with wait_nr=1 and submit=0, there is no need to call io_uring_enter() if the peek call finds a completion. Below are the perf results for 500f9fbadef8-test without/with the fix: perf stat -e syscalls:sys_enter_io_uring_enter 500f9fbadef8-test 12,289 syscalls:sys_enter_io_uring_enter 8,193 syscalls:sys_enter_io_uring_enter - Patch 3 is a cleanup with no functional changes. Since we always have io_uring_wait_cqe_nr() -> __io_uring_get_cqe() -> __io_uring_peek_cqe() remove the direct call from io_uring_wait_cqe_nr() to __io_uring_peek_cqe(). After the removal, __io_uring_peek_cqe() is called only from __io_uring_get_cqe() so move the two routines together(). Without the move, compilation fails with a 'defined but not used' error. Bijan Mottahedeh (3): preseve wait_nr if SETUP_IOPOLL is set update wait_nr to account for completed event remove duplicate call to __io_uring_peek_cqe() src/include/liburing.h | 32 -------------------------------- src/queue.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 33 deletions(-) -- 1.8.3.1