]> Gentwo Git Trees - linux/.git/commit
ring-buffer: Add helper functions for allocations
authorSteven Rostedt <rostedt@goodmis.org>
Tue, 25 Nov 2025 17:11:53 +0000 (12:11 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 2 Dec 2025 20:49:35 +0000 (15:49 -0500)
commitb1e7a590a0133606d3efd41aee38cdeac630b52f
tree773d9d752727769fa765a9bb021a671cb17d5bc3
parentdcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
ring-buffer: Add helper functions for allocations

The allocation of the per CPU buffer descriptor, the buffer page
descriptors and the buffer page data itself can be pretty ugly:

  kzalloc_node(ALIGN(sizeof(struct buffer_page), cache_line_size()),
               GFP_KERNEL, cpu_to_node(cpu));

And the data pages:

  page = alloc_pages_node(cpu_to_node(cpu),
                          GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_COMP | __GFP_ZERO, order);
  if (!page)
return NULL;
  bpage->page = page_address(page);
  rb_init_page(bpage->page);

Add helper functions to make the code easier to read.

This does make all allocations of the data page (bpage->page) allocated
with the __GFP_RETRY_MAYFAIL flag (and not just the bulk allocator). Which
is actually better, as allocating the data page for the ring buffer tracing
should try hard but not trigger the OOM killer.

Link: https://lore.kernel.org/all/CAHk-=wjMMSAaqTjBSfYenfuzE1bMjLj+2DLtLWJuGt07UGCH_Q@mail.gmail.com/
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20251125121153.35c07461@gandalf.local.home
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c