io_uring: add support for IORING_SETUP_CQE_MIXED
authorJens Axboe <axboe@kernel.dk>
Thu, 7 Aug 2025 20:14:41 +0000 (14:14 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 20 Aug 2025 19:04:27 +0000 (13:04 -0600)
commit72d893be981d7f88c9b5fa5c690444e53d0efbb9
tree09ed9f100d876be3e096fa393f6fe02fffa8cf1f
parent9256da570b91f1b59c56fd26dc08e9936de7e4b6
io_uring: add support for IORING_SETUP_CQE_MIXED

Normal rings support 16b CQEs for posting completions, while certain
features require the ring to be configured with IORING_SETUP_CQE32, as
they need to convey more information per completion. This, in turn,
makes ALL the CQEs be 32b in size. This is somewhat wasteful and
inefficient, particularly when only certain CQEs need to be of the
bigger variant.

This adds support for setting up a ring with mixed CQE sizes, using
IORING_SETUP_CQE_MIXED. When setup in this mode, CQEs posted to the ring
may be either 16b or 32b in size. If a CQE is 32b in size, then
IORING_CQE_F_32 is set in the CQE flags to indicate that this is the
case. If this flag isn't set, the CQE is the normal 16b variant.

CQEs on these types of mixed rings may also have IORING_CQE_F_SKIP set.
This can happen if the ring is one (small) CQE entry away from wrapping,
and an attempt is made to post a 32b CQE. As CQEs must be contigious in
the CQ ring, a 32b CQE cannot wrap the ring. For this case, a single
dummy CQE is posted with the SKIP flag set. The application should
simply ignore those.

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