io_uring_peek_cqe(3)
π io_uring_peek_cqe β liburing manual, but make it cute β¨
okay bestie, pull up a chair πͺ because we're talking about io_uring_peek_cqe(3) β yes it's a real function, yes it lives in the liburing manual, and yes it's about to be your new fave π
β¨ NAME β¨
io_uring_peek_cqe β literally just checking if an io_uring completion event is ready for you, no waiting, no drama πΈ
π SYNOPSIS π
#include <liburing.h>
int io_uring_peek_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr);
unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptrs,
unsigned count);
two functions, one vibe. one peeks a single CQE, the other peeks a whole little squad of them π«Ά
π DESCRIPTION π
okay so first up, io_uring_peek_cqe(3). this function returns an IO completion from the queue that belongs to the ring param β but only if one is already sitting there, readily available π. on a successful return, the cqe_ptr param gets filled with a valid CQE entry, and you're good to go β¨.
here's the important part, bestie: this function does not enter the kernel to wait for an event. like, it will not go knock on the kernel's door and be like "hello?? any completions??" π. an event is only returned if it's already available in the CQ ring. it's giving "if you know, you know" β if it's there, you get it, if it's not, you don't π.
then we have io_uring_peek_batch_cqe(3), the group-chat version π±. it returns up to count request completions in cqe_ptrs, belonging to the ring param, if they're readily available. same energy as above β it will not enter the kernel, unless the CQ ring is in an overflow condition π³ (that's the one exception, don't forget it). upon successful return, cqe_ptrs are filled with the number of events indicated by the return value. iconic behaviour, no cap π
π RETURN VALUE π
- on success,
io_uring_peek_cqe(3)returns0, and thecqe_ptrparameter is filled in π - on success,
io_uring_peek_batch_cqe(3)returns the number of completions that got filled in π₯ - on failure,
io_uring_peek_cqe(3)may return-EAGAINπ (that's the "nothing here yet, try again later" vibe, not a crisis)
π¦ SEE ALSO π¦
go read those too, they're all part of the same friend group π β¨
and that's the whole page, bestie π this one's from liburing-2.2, dated March 12, 2022 β so you know it's been serving reliable peek energy since then ππ«Ά periodt.
π¦ where this page comes from
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms