linux/io_uring
Ming Lei f7bc22ca0d nvme/io_uring: optimize IOPOLL completions for local ring context
When multiple io_uring rings poll on the same NVMe queue, one ring can
find completions belonging to another ring. The current code always
uses task_work to handle this, but this adds overhead for the common
single-ring case.

This patch passes the polling io_ring_ctx through io_comp_batch's new
poll_ctx field. In io_do_iopoll(), the polling ring's context is stored
in iob.poll_ctx before calling the iopoll callbacks.

In nvme_uring_cmd_end_io(), we now compare iob->poll_ctx with the
request's owning io_ring_ctx (via io_uring_cmd_ctx_handle()). If they
match (local context), we complete inline with io_uring_cmd_done32().
If they differ (remote context) or iob is NULL (non-iopoll path), we
use task_work as before.

This optimization eliminates task_work scheduling overhead for the
common case where a ring polls and finds its own completions.

~10% IOPS improvement is observed in the following benchmark:

fio/t/io_uring -b512 -d128 -c32 -s32 -p1 -F1 -O0 -P1 -u1 -n1 /dev/ng0n1

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-01-20 10:18:01 -07:00
..
Kconfig
Makefile io_uring: introduce io_uring querying 2025-09-08 08:06:37 -06:00
advise.c
advise.h
alloc_cache.c
alloc_cache.h
cancel.c io_uring/cancel: move cancelation code from io_uring.c to cancel.c 2025-11-04 09:32:09 -07:00
cancel.h io_uring/cancel: move cancelation code from io_uring.c to cancel.c 2025-11-04 09:32:09 -07:00
cmd_net.c for-6.19/io_uring-20251201 2025-12-03 18:58:57 -08:00
epoll.c
epoll.h
eventfd.c
eventfd.h
fdinfo.c Merge branch 'io_uring-6.18' into for-6.19/io_uring 2025-11-13 07:26:37 -07:00
fdinfo.h
filetable.c io_uring: correct __must_hold annotation in io_install_fixed_file 2025-10-23 07:25:07 -06:00
filetable.h
fs.c
fs.h
futex.c io_uring/futex: move futexv owned status to struct io_futexv_data 2025-11-05 12:55:07 -07:00
futex.h
io-wq.c io_uring/io-wq: always retry worker create on ERESTART* 2025-12-04 07:18:02 -07:00
io-wq.h
io_uring.c io_uring: fix min_wait wakeups for SQPOLL 2025-12-09 16:54:12 -07:00
io_uring.h io_uring: pre-calculate scq layout 2025-11-13 07:27:34 -07:00
kbuf.c io_uring/kbuf: use WRITE_ONCE() for userspace-shared buffer ring fields 2025-12-05 09:52:02 -07:00
kbuf.h io_uring/kbuf: remove obsolete buf_nr_pages and update comments 2025-11-20 13:23:05 -07:00
memmap.c Significant patch series in this merge are as follows: 2025-12-05 13:52:43 -08:00
memmap.h io_uring: add helper calculating region byte size 2025-11-11 07:53:33 -07:00
mock_file.c io_uring: convert io_create_mock_file() to FD_PREPARE() 2025-11-28 12:42:36 +01:00
msg_ring.c io_uring: add wrapper type for io_req_tw_func_t arg 2025-11-03 08:31:26 -07:00
msg_ring.h
napi.c
napi.h
net.c for-6.19/io_uring-20251201 2025-12-03 18:58:57 -08:00
net.h
nop.c
nop.h
notif.c io_uring: fix typos and comment wording 2025-11-05 08:21:43 -07:00
notif.h
opdef.c io_uring: add support for IORING_SETUP_SQE_MIXED 2025-10-22 07:34:57 -06:00
opdef.h io_uring: add support for IORING_SETUP_SQE_MIXED 2025-10-22 07:34:57 -06:00
openclose.c io_uring: fix filename leak in __io_openat_prep() 2025-12-25 07:58:33 -07:00
openclose.h
poll.c io_uring/poll: unify poll waitqueue entry and list removal 2025-12-05 10:23:28 -07:00
poll.h io_uring: add wrapper type for io_req_tw_func_t arg 2025-11-03 08:31:26 -07:00
query.c io_uring/query: drop unused io_handle_query_entry() ctx arg 2025-11-26 09:37:10 -07:00
query.h io_uring/query: drop unused io_handle_query_entry() ctx arg 2025-11-26 09:37:10 -07:00
refs.h
register.c io_uring/query: drop unused io_handle_query_entry() ctx arg 2025-11-26 09:37:10 -07:00
register.h
rsrc.c io_uring: remove nr_segs recalculation in io_import_kbuf() 2026-01-07 08:06:33 -07:00
rsrc.h io_uring/rsrc: refactor io_{un}account_mem() to take {user,mm}_struct param 2025-11-06 16:23:21 -07:00
rw.c nvme/io_uring: optimize IOPOLL completions for local ring context 2026-01-20 10:18:01 -07:00
rw.h io_uring: add wrapper type for io_req_tw_func_t arg 2025-11-03 08:31:26 -07:00
slist.h io_uring/slist: remove unused wq list splice helpers 2025-11-03 10:51:39 -07:00
splice.c io_uring: don't include filetable.h in io_uring.h 2025-09-08 13:20:46 -06:00
splice.h
sqpoll.c Merge branch 'io_uring-6.18' into for-6.19/io_uring 2025-11-13 07:26:37 -07:00
sqpoll.h io_uring/sqpoll: switch away from getrusage() for CPU accounting 2025-10-22 10:51:20 -06:00
statx.c
statx.h
sync.c
sync.h
tctx.c
tctx.h
timeout.c io_uring: add wrapper type for io_req_tw_func_t arg 2025-11-03 08:31:26 -07:00
timeout.h
truncate.c
truncate.h
uring_cmd.c io_uring/uring_cmd: avoid double indirect call in task work dispatch 2025-11-03 08:31:26 -07:00
uring_cmd.h
waitid.c Merge branch 'io_uring-6.18' into for-6.19/io_uring 2025-11-13 07:26:37 -07:00
waitid.h
xattr.c
xattr.h
zcrx.c io_uring/zcrx: share an ifq between rings 2025-11-13 11:19:37 -07:00
zcrx.h io_uring/zcrx: count zcrx users 2025-11-13 11:19:37 -07:00