io_uring_sqe_set_flags(3)

πŸ’… io_uring_sqe_set_flags β€” the liburing manual, bestie edition πŸ’…

okay so we're deep in the liburing manual, specifically the page for io_uring_sqe_set_flags. pull up a chair, grab a boba, we're doing kernel-adjacent lore today πŸ§‹βœ¨


πŸŽ€ NAME πŸŽ€

io_uring_sqe_set_flags β€” the way you set flags for a submission queue entry, no cap 🫢


🌸 SYNOPSIS 🌸

#include <liburing.h>

void io_uring_sqe_set_flags(struct io_uring_sqe *sqe,
                            unsigned flags);

πŸ¦‹ DESCRIPTION πŸ¦‹

so io_uring_sqe_set_flags(3) is literally the function that lets you, the caller, change the behavior of the submission queue entry by specifying flags. it enables the flags belonging to the sqe submission queue entry param. that's it, that's the job. πŸ’β€β™€οΈ

flags is a bit mask of 0 or more of the following values ORed together:

  • IOSQE_FIXED_FILE β€” the file descriptor in the SQE refers to the index of a previously registered file or direct file descriptor, not a normal file descriptor. it's giving "i already told you about this file, go look it up" πŸ‘‘
  • IOSQE_ASYNC β€” normal io_uring operation is to try and issue an sqe as non-blocking first, and if that fails, execute it in an async manner. but to support more efficient overlapped operation of requests that the application knows / assumes will always (or most of the time) block, the application can ask for an sqe to be issued async from the start. heads up though: this flag immediately causes the SQE to be offloaded to an async helper thread with no initial non-blocking attempt. that may be less efficient, so don't use it liberally, and definitely not without understanding the performance and efficiency tradeoffs. 😭 (this is the "skip the vibe check and go straight to the line" flag)
  • IOSQE_IO_LINK β€” when this flag is specified, the SQE forms a link with the next SQE in the submission ring. that next SQE will not be started before the previous request completes. this, in effect, forms a chain of SQEs, which can be arbitrarily long. the tail of the chain is denoted by the first SQE that does not have this flag set. chains are not supported across submission boundaries β€” even if the last SQE in a submission has this flag set, it will still terminate the current chain. this flag has no effect on previous SQE submissions, nor does it impact SQEs that are outside of the chain tail. which means multiple chains can be executing in parallel, or chains and individual SQEs can be running side by side. only members inside the chain are serialized. also, a chain of SQEs will be broken if any request in that chain ends in error. πŸ’€
  • IOSQE_IO_HARDLINK β€” like IOSQE_IO_LINK, except the links aren't severed if an error or unexpected result occurs. ride or die fr fr 🫢
  • IOSQE_IO_DRAIN β€” when this flag is specified, the SQE will not be started before previously submitted SQEs have completed, and new SQEs will not be started before this one completes. it's giving "everyone wait, i'm going first and you can't start till i'm done" 🚧
  • IOSQE_CQE_SKIP_SUCCESS β€” request that no CQE be generated for this request, if it completes successfully. this can be useful in cases where the application doesn't need to know when a specific request completed, if it completed successfully. lowkey the "don't text me if it went fine" option πŸ™ˆ
  • IOSQE_BUFFER_SELECT β€” if set, and if the request types supports it, select an IO buffer from the indicated buffer group. this can be used with requests that read or receive data from a file or socket, where buffer selection is deferred until the kernel is ready to transfer data, instead of when the IO is originally submitted. the application must also set the buf_group field in the SQE, indicating which previously registered buffer group to select a buffer from. pick your buffer at the last possible second, main character energy ✨

⭐ RETURN VALUE ⭐

None. literally nothing. it's void, bestie, it gives you nothing back and that's fine 🌈


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, you ate it πŸ’… this was liburing-2.1, dated January 25, 2022 β€” go forth and set your flags, queen πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from