io_uring/msg_ring: add support for sending a sync message io_uring-sync-msg_ring
authorJens Axboe <axboe@kernel.dk>
Mon, 23 Sep 2024 14:19:40 +0000 (08:19 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 24 Sep 2024 19:31:37 +0000 (13:31 -0600)
commit5945addaa20211f4f66714700725fd8dceaa8e76
treedc0ba8692b50f18587c611287db2caa37241a79b
parentd6e15750337a8a71af5b02ff7fa622d89e7a315f
io_uring/msg_ring: add support for sending a sync message

Normally MSG_RING requires both a source and a destination ring. But
some users don't always have a ring avilable to send a message from, yet
they still need to notify a target ring.

Add support for using io_uring_register(2) without having a source ring,
using a file descriptor of -1 for that. Internally those are called
blind registration opcodes. Implement IORING_REGISTER_SEND_MSG_RING as a
blind opcode, which simply takes an sqe that the application can put on
the stack and use the normal liburing helpers to initialize it. Then the
app can call:

io_uring_register(-1, IORING_REGISTER_SEND_MSG_RING, &sqe, 1);

and get the same behavior in terms of the target, where a CQE is posted
with the details given in the sqe.

For now this takes a single sqe pointer argument, and hence arg must
be set to that, and nr_args must be 1. Could easily be extended to take
an array of sqes, but for now let's keep it simple.

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