io_uring/msg_ring: add an alloc cache for CQE entries
authorJens Axboe <axboe@kernel.dk>
Sat, 25 May 2024 15:21:00 +0000 (09:21 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 5 Jun 2024 18:49:55 +0000 (12:49 -0600)
commitfd602fef82da18bafdfeab94a66f7974d382ff70
treea82315ab6e8f6b6cc31d5ff745d1b290cfc604df
parentf1d7dd0c33b484443c1a16ac3fab9bc4d129eb4e
io_uring/msg_ring: add an alloc cache for CQE entries

io_uring accounts the memory allocated, which is quite expensive. Wrap
the allocation and frees in the provided alloc cache framework. The
target ctx needs to be locked anyway for posting the overflow entry,
so just move the overflow alloc inside that section. Flushing the
entries has it locked as well, so io_cache_alloc_free() can be used.

In a simple test, most of the overhead of DEFER_TASKRUN message passing
ends up being accounting for allocation and free, and with this change
it's completely gone.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
io_uring/io_uring.c
io_uring/msg_ring.c
io_uring/msg_ring.h