io_uring_cqe_nr(3)

πŸ’– io_uring_cqe_nr β€” bestie edition πŸ’–

okay so this one is from the liburing manual, and honestly? it's short, it's sweet, and it's lowkey essential if you're out here living that mixed-CQE life. no cap. πŸ¦‹


✨ NAME ✨

io_uring_cqe_nr β€” returns the number of CQ ring slots that a CQE has eaten. that's it, that's the whole job. it's giving "small but mighty" πŸ’…


🌸 SYNOPSIS 🌸

#include <liburing.h>

unsigned io_uring_cqe_nr(const struct io_uring_cqe *cqe);

πŸŽ€ DESCRIPTION πŸŽ€

so, io_uring_cqe_nr(3) tells you how many CQ ring slots your cqe has consumed. like, how much room did this little guy take up in the ring? 🫢

here's the tea:

  • for normal 16-byte CQEs, it returns 1. one slot. a single serving. perfectly reasonable. ✨
  • for 32-byte CQEs, which happen when IORING_CQE_F_32 is set in the CQE flags, it returns 2. two slots. it's an overachiever, we love that for it. πŸ‘‘

and why do you care, bestie? because when you're advancing the CQ ring with io_uring_cq_advance(3) on rings that use IORING_SETUP_CQE_MIXED β€” where both 16-byte and 32-byte CQEs can show up in the same ring, chaos incarnate β€” you can't just assume every CQE takes one slot. that's a trap. this function is your vibe check. it tells you exactly how far to advance so you don't skip past a CQE or trip over your own ring. main character energy fr fr 😭

not me almost advancing by one when a 32-byte CQE was sitting there the whole time πŸ’€

πŸ’œ RETURN VALUE πŸ’œ

  • returns 1 for normal CQEs
  • returns 2 for 32-byte CQEs

that's it. two possible answers. no in-between, no drama, no edge cases beyond that. periodt. πŸ’…


🌈 SEE ALSO 🌈


kisses, bestie 🫢 this page is from liburing-2.12, dated January 18, 2025, and that's the whole manual. go advance your ring correctly, i'm so proud of you πŸŽ€πŸ’–

πŸ“¦ where this page comes from