buf_data_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ buf_data_size β€” ok bestie let's count some bytes πŸŽ€

hey hi hello, welcome to the Kernel API Manual entry for buf_data_size(9) πŸ’… this is the function you call when you've got a circular buffer and you're like "how much stuff is actually in there rn" β€” and it's gonna tell you. no cap.


✨ SYNOPSIS ✨

u32 buf_data_size (size_t buf_size , u32 read_ptr , u32 write_ptr );

like, three args, one u32 back. that's the whole vibe. πŸ¦‹


🌸 ARGUMENTS 🌸

  • buf_size β€” the size of the circular buffer, yes queen, just tell her how big it is πŸŽ€
  • read_ptr β€” the read pointer, and psst, it's carrying an extra overflow bit with it πŸ‘€
  • write_ptr β€” the write pointer, also rocking that extra overflow bit ✨

πŸ’– DESCRIPTION πŸ’–

okay so here's the situation. since read_ptr and write_ptr both have that extra overflow bit tacked on, they're not straight-up indices anymore β€” so this function calculates the offsets from the pointers, and then uses those offsets to calculate the data size in the buffer. that's it. that's the whole job. it's giving "small function, big responsibility" energy fr fr 🫢


⭐ RETURN ⭐

the number of bytes of data in the buffer πŸ’€ that's literally it, that's the tea


πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./drivers/gpu/drm/xe/xe_eu_stall.c struct β€” go look at her, she's iconic πŸ‘‘

and the whole friend group, no one left out:


ok that's the whole page bestie, nothing hidden, nothing skipped πŸ’œ go forth and count your bytes responsibly 🌈

and that's a wrap!! this one lives in ./drivers/gpu/drm/xe, dated October 2026 β€” mwah, catch you in the next manpage πŸ˜­πŸ’–πŸ§š

πŸ“¦ where this page comes from