io_uring_register_sync_msg(3)

πŸ’Œ io_uring_register_sync_msg β€” bestie edition ✨

okay so this is a page from the liburing manual, and we're about to send a lil synchronous message to another ring, no biggie πŸ’…


✨ NAME ✨

io_uring_register_sync_msg β€” send a synchronous message to another ring 🫢


🌸 SYNOPSIS 🌸

#include <liburing.h>

int io_uring_register_sync_msg(struct io_uring_sqe *sqe);

πŸ¦‹ DESCRIPTION πŸ¦‹

So io_uring_register_sync_msg(3) issues a synchronous MSG_RING request, and honestly? iconic. The thing is, your sqe parameter must have been cleared and initialized with io_uring_prep_msg_ring(3) first β€” like, don't skip that step bestie, it's not optional 😭

Normally, message requests get sent from one ring to another ring, cute, very demure. But there are also cases where a source ring is not available, yet it would still be super convenient to send a message to a destination ring. And that's literally why io_uring_register_sync_msg(3) exists. No source ring required! Instead you can just place the sqe parameter on the stack, fill it in using the normal message helpers, and then call io_uring_register_sync_msg(3). Slay.

And since a source ring doesn't exist, the results of the operation are returned directly rather than via a CQE. On the destination/receiving end though? A CQE is posted, exactly as it would have been with a non-sync request. The receiving side stays unbothered and unaware πŸ’…

Only data requests are supported, periodt. Sending files such as setup by io_uring_prep_msg_ring_fd(3) is not supported. The given SQE should be initialized by io_uring_prep_msg_ring(3) or io_uring_prep_msg_ring_cqe_flags(3), or any other helper that sets up a non-fd message request.

The targeted ring may be any ring that the user has access to, even the ring itself β€” main character energy fr fr. This request can be used for simple message passing to another ring, allowing 32+64 bits of data to be transferred through the len and data fields. The use case can be anything from simply waking up someone waiting on the targeted ring, or it can be used to pass messages between the two rings. Versatile queen πŸ‘‘

io_uring_prep_msg_ring_cqe_flags(3) is similar to io_uring_prep_msg_ring(3), but has an additional cqe_flags parameter, which is used to set the flags field on the CQE side. That way, you can set the CQE flags field cqe->flags when sending a message πŸŽ€ But be aware that io_uring could potentially set additional bits into this field β€” so like, heads up, don't assume it's only yours πŸ‘€

Available since kernel 6.13. πŸ—“οΈ

πŸ’– RETURN VALUE πŸ’–

Returns 0 on success, or -errno on error. Simple as that, no cap ✨


🌈 SEE ALSO 🌈


and that's the whole page bestie πŸ₯° this was liburing-2.11, dated July 10, 2025 β€” go forth and send those synchronous messages, you absolute icon πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from