io_uring/net: allow multishot receive per-invocation cap
authorJens Axboe <axboe@kernel.dk>
Tue, 8 Jul 2025 01:38:45 +0000 (19:38 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 10 Jul 2025 17:54:33 +0000 (11:54 -0600)
commit6a8afb9fff6478e7944794f089181e93df1c728a
treece570a43150c66a37e5f24f47053aba7300f656d
parent3919b695932dd1990b5c7fd44fc52361f8e2ac5f
io_uring/net: allow multishot receive per-invocation cap

If an application is handling multiple receive streams using recv
multishot, then the amount of retries and buffer peeking for multishot
and bundles can process too much per socket before moving on. This isn't
directly controllable by the application. By default, io_uring will
retry a recv MULTISHOT_MAX_RETRY (32) times, if the socket keeps having
data to receive. And if using bundles, then each bundle peek will
potentially map up to PEEK_MAX_IMPORT (256) iovecs of data. Once these
limits are hit, then a requeue operation will be done, where the request
will get retried after other pending requests have had a time to get
executed.

Add support for capping the per-invocation receive length, before a
requeue condition is considered for each receive. This is done by setting
sqe->mshot_len to the byte value. For example, if this is set to 1024,
then each receive will be requeued by 1024 bytes received.

Link: https://lore.kernel.org/io-uring/20250709203420.1321689-4-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/net.c