summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAustin Schuh <austin.linux@gmail.com>2026-10-19 16:12:43 -0700
committerJens Axboe <axboe@kernel.dk>2026-10-20 08:34:27 -0600
commit02caa5922184e99da04b37fd3336066625ea8e2e (patch)
tree6832ecf62a1abd103035f2a633079f904c97c8f9 /include
parent5b01d5955ac206e38097f777eff6ab2a8b948c41 (diff)
io_uring/futex: return a wait's data to the cache when it fails to arm
io_futex_wait() takes its io_futex_data from ctx->futex_cache, and a completed wait gives it back in io_futex_complete(). A wait that fails to arm kfree()s it instead. The usual failure is -EAGAIN from futex_wait_setup(): the futex word no longer holds the expected value. That is routine for a waiter that re-arms with the value it last read, since the word changes whenever there is something to wake for. Each such failure takes an object out of the cache for good, so the cache drains and from then on waits allocate. The cache exists so that arming a wait doesn't have to go to the slab allocator, and that matters most to the waiters that re-arm the most: event loops, often real-time ones. A kmalloc() or kfree() that misses the per-CPU slab takes the node's list_lock, shared with every other user of that kmalloc size on the system, and may go on to the page allocator. On PREEMPT_RT list_lock is a sleeping lock. A real-time task that finds it held waits for the holder, which may be any task on any CPU, to get to run and release it. Priority inheritance boosts the holder only up to the waiter's priority, so the waiter still sits behind whatever outranks that on the holder's CPU, such as threaded interrupt handlers. Re-arming a futex wait should not depend on any of that. Put the data back in the cache on that path too, while the submit lock still protects it. In an event loop re-arming one IORING_OP_FUTEX_WAIT per message under load, 0.39 arms per message failed with -EAGAIN, and io_futex_wait() did 0.39 kmalloc()s and kfree()s per message. With this change, 100,000 waits that all fail with -EAGAIN do one kmalloc() in total. Fixes: 194bb58c6090 ("io_uring: add support for futex wake and wait") Assisted-by: LLM Signed-off-by: Austin Schuh <austin.linux@gmail.com> Link: https://patch.msgid.link/20261019231243.802569-1-austin.linux@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions