__ring_buffer_alloc_range(9)
π __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 thering_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 bufferreader_lock_key. yes it's astruct 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_OVERWRITEis 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 π:
Kernel file ./kernel/trace/ring_buffer.cring_buffer_event_length(9)ring_buffer_event_data(9)rb_page_capacity(9)rb_subbuf_capacity(9)rb_subbuf_max_data_size(9)rb_subbuf_start(9)ring_buffer_event_time_stamp(9)ring_buffer_nr_dirty_pages(9)ring_buffer_wake_waiters(9)ring_buffer_wait(9)ring_buffer_poll_wait(9)rb_check_pages(9)rb_validate_buffer(9)__ring_buffer_alloc(9)__ring_buffer_alloc_remote(9)ring_buffer_free(9)ring_buffer_resize(9)rb_update_event(9)ring_buffer_nest_start(9)ring_buffer_nest_end(9)ring_buffer_unlock_commit(9)ring_buffer_lock_reserve(9)ring_buffer_discard_commit(9)ring_buffer_write(9)ring_buffer_record_disable(9)ring_buffer_record_enable(9)ring_buffer_record_off(9)ring_buffer_record_on(9)ring_buffer_record_is_on(9)ring_buffer_record_is_set_on(9)ring_buffer_record_is_on_cpu(9)ring_buffer_record_disable_cpu(9)ring_buffer_record_enable_cpu(9)ring_buffer_oldest_event_ts(9)ring_buffer_bytes_cpu(9)ring_buffer_entries_cpu(9)ring_buffer_overrun_cpu(9)ring_buffer_commit_overrun_cpu(9)ring_buffer_dropped_events_cpu(9)ring_buffer_read_events_cpu(9)ring_buffer_entries(9)ring_buffer_overruns(9)ring_buffer_iter_reset(9)ring_buffer_iter_empty(9)ring_buffer_peek(9)ring_buffer_iter_peek(9)ring_buffer_consume(9)ring_buffer_read_start(9)ring_buffer_read_finish(9)ring_buffer_iter_advance(9)ring_buffer_size(9)ring_buffer_max_event_size(9)ring_buffer_reset_cpu(9)ring_buffer_reset_online_cpus(9)ring_buffer_reset(9)ring_buffer_empty(9)ring_buffer_empty_cpu(9)ring_buffer_swap_cpu(9)ring_buffer_alloc_read_page(9)ring_buffer_free_read_page(9)ring_buffer_read_page(9)ring_buffer_read_page_data(9)ring_buffer_read_page_size(9)ring_buffer_subbuf_size_get(9)ring_buffer_subbuf_order_get(9)ring_buffer_subbuf_order_set(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms