prb_read_valid(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… prb_read_valid(9) β€” a Kernel API Manual moment πŸŽ€

okay so bestie, we're in the prb_read_valid(9) page, which lives in the Kernel API Manual, and it's lowkey one of the most useful little functions in the printk ringbuffer world. let's get into it ✨


✨ NAME ✨

prb_read_valid β€” a non-blocking read of a requested record, or (if that one's gone) the next available record. no waiting around, no blocking, we simply take what's there 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

bool prb_read_valid (struct printk_ringbuffer *rb , u64 seq , struct printk_record *r );

🌸 ARGUMENTS 🌸

  • rb β€” the ringbuffer you're reading from. that's the main character, obviously πŸ‘‘
  • seq β€” the sequence number of the record you wanna read. your little ticket number 🎟️
  • r β€” a record data buffer where the read record gets stored. the drop-off spot πŸ“¦

πŸ’– DESCRIPTION πŸ’–

This is the public function available to readers for reading a record. it's giving "officially supported, no back-door hacks" energy, periodt ✨

Your job as the reader is to provide the info and text_buf buffers of r so they can be filled in. and honestly? any of the buffer pointers can be set to NULL if you're just not interested in that data β€” we respect your boundaries πŸ’…

To make sure r is properly initialized, you should use prb_rec_init_rd. fr fr, don't skip this step πŸ™ˆ

On success, you must check r->info.seq to see which record was actually read. and yes, that's the whole point β€” it's how you detect dropped records 😭 (they're gone, bestie, and this is how you know)

Failure means seq refers to a record that isn't available to the reader yet. not an error, just a "not yet, babe" situation ⏳


🌈 CONTEXT 🌈

Any context. literally any. she's flexible like that 🧚


⭐ RETURN ⭐

true if a record was read, otherwise false. simple, iconic, no notes πŸ”₯


πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./kernel/printk/printk_ringbuffer.c printk_ringbuffer overview(9), prb_reserve_in_last(9), prb_reserve(9), prb_commit(9), prb_final_commit(9), prb_next_reserve_seq(9), prb_read_valid_info(9), prb_first_valid_seq(9), prb_next_seq(9), prb_init(9), prb_record_text_space(9) πŸ’œ


okay that's the whole page, you ate that bestie πŸ’…βœ¨ this one comes from ./kernel/printk, dated October 2026 β€” mwah, go read some ringbuffer records, ily πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from