io_uring/notif: implement notification stacking
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 19 Apr 2024 11:08:42 +0000 (12:08 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 23 Apr 2024 01:31:18 +0000 (19:31 -0600)
commit6fe4220912d19152a26ce19713ab232f4263018d
treeb49a3fb5a3fd41961cb9d2549230a06dd73602f6
parent5a569469b973cb7a6c58192a37dfb8418686e518
io_uring/notif: implement notification stacking

The network stack allows only one ubuf_info per skb, and unlike
MSG_ZEROCOPY, each io_uring zerocopy send will carry a separate
ubuf_info. That means that send requests can't reuse a previosly
allocated skb and need to get one more or more of new ones. That's fine
for large sends, but otherwise it would spam the stack with lots of skbs
carrying just a little data each.

To help with that implement linking notification (i.e. an io_uring wrapper
around ubuf_info) into a list. Each is refcounted by skbs and the stack
as usual. additionally all non head entries keep a reference to the
head, which they put down when their refcount hits 0. When the head have
no more users, it'll efficiently put all notifications in a batch.

As mentioned previously about ->io_link_skb, the callback implementation
always allows to bind to an skb without a ubuf_info.

Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/bf1e7f9b72f9ecc99999fdc0d2cded5eea87fd0b.1713369317.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/notif.c
io_uring/notif.h