__ring_buffer_alloc_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ __ring_buffer_alloc_range β€” from the Kernel API Manual, bestie πŸ’…

okay so picture this: it's a kernel man page, it's section 9, and it's about to make your whole ring buffer situation make sense. no cap. this is __ring_buffer_alloc_range(9), and she's here to hand you a trace_buffer built out of memory you already have lying around. iconic behavior honestly.


✨ NAME ✨

__ring_buffer_alloc_range β€” allocate a new ring_buffer from existing memory 🫢

like, not fresh memory. memory that's already yours. she's thrifting. she's upcycling. she's resourceful.


🌸 SYNOPSIS 🌸

struct trace_buffer * __ring_buffer_alloc_range (unsigned long size ,
       unsigned flags , int order , unsigned long start ,
       unsigned long range_size , unsigned long scratch_size ,
       struct lock_class_key *key );

bestie that is a lot of parameters and every single one of them matters. let's go through them one by one, no skipping, we don't do that here πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • size β€” the size in bytes per cpu that is needed. per. cpu. don't forget the per cpu part, that's the whole vibe.
  • flags β€” attributes to set for the ring_buffer. the personality settings, basically.
  • order β€” sub-buffer order. it's the order. of the sub-buffers. slay.
  • start β€” start of allocated range. where the memory you're reusing begins ✨
  • range_size β€” size of allocated range. how much of it there is. math.
  • scratch_size β€” size of scratch area (for preallocated memory buffers). the little scratch pad, for when the buffers are already preallocated πŸ“
  • key β€” ring buffer reader_lock_key. yes it's a struct lock_class_key *. yes you pass the key. iykyk.

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea β˜• β€” currently the only flag that is available is the RB_FL_OVERWRITE flag. that's it. that's the whole flag menu. one item. and honestly? she ate.

what does it do though β€” because the way that this flag works is:

  • if RB_FL_OVERWRITE is set, the buffer will overwrite old data when the buffer wraps πŸ”₯ old data? gone. replaced. makeover era.
  • if this flag is not set, the buffer will drop data when the tail hits the head πŸ’€ not overwrite. drop. the data is just lost. so choose wisely, bestie.
no cap, that's a real behavioral difference and you should know which one you're picking before you pick it πŸ™ˆ

🌈 SEE ALSO 🌈

she has a friend group and you're gonna meet all of them, because they all showed up in the original list and we do not leave anyone out at this party πŸ‘‘:

look at that roster. that's a whole friend group and they all said hi back πŸ’œ


and that's the page, bestie! this lil gem lives over in ./kernel/trace, it's dated October 2026, and it's filed under __ring_buffer_alloc_range(9) in the Kernel API Manual. go forth and allocate responsibly β€” mwah πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from