io_uring_prep_madvise(3)

πŸ“¦
version 2.15 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ io_uring_prep_madvise ✨

okay bestie, so this is a page from the liburing Manual and it's literally about preparing an madvise request for io_uring. yeah. we're doing memory-advice async style πŸ’…


πŸŽ€ NAME πŸŽ€

io_uring_prep_madvise β€” prepare an madvise request


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/mman.h>
#include <liburing.h>

void io_uring_prep_madvise(struct io_uring_sqe *sqe,
                           void *addr,
                           __u32 len,
                           int advice);

void io_uring_prep_madvise64(struct io_uring_sqe *sqe,
                             void *addr,
                             off_t len,
                             int advice);

πŸ’– DESCRIPTION πŸ’–

so the io_uring_prep_madvise(3) function gets an madvise request all dressed up and ready to go. it sets up the submission queue entry sqe to kick off an madvise operation at the virtual address addr, running for len bytes, and it's giving it the advice that lives in advice. that's the whole vibe ✨

then there's io_uring_prep_madvise64(3), which is the same thing but it takes a 64-bit length instead of a lil 32-bit one. slay, more bits πŸ’…

⚠️ heads up bestie: older kernels might not support the 64-bit length variant. if you try to use it on a kernel that doesn't do 64-bit lengths, the request gets errored out with -EINVAL in the results field of the CQE. no cap, that's the error you'll see 😭

this function prepares an async madvise(2) request. go check that man page for the details, iykyk 🫢


🌸 RETURN VALUE 🌸

None. that's it. nothing. it's giving void energy, periodt ✨


πŸ“ ERRORS πŸ“

the CQE res field is where the result of the operation shows up. peep the related man page for all the possible values πŸ‘‘

and here's the important bit, bestie: where synchronous system calls will return -1 on failure and set errno to the actual error value β€” io_uring never uses errno. instead it returns the negated errno directly in the CQE res field. so like, no errno detective work needed, the answer is right there πŸ”₯


🌈 SEE ALSO 🌈


and that's the page, angel πŸ’œ this whole thing came from liburing-2.2, dated March 13, 2022 β€” so if you're reading this from the future, hi, the lore is preserved πŸŽ€βœ¨ go forth and madvise responsibly, mwah πŸ’‹

πŸ“¦ where this page comes from