trace_remote_alloc_buffer(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ trace_remote_alloc_buffer ✨

okay so bestie, this one's straight out of the Kernel API Manual, section 9, and it's genuinely one of the more satisfying little helpers out there. sit down, hydrate, and let's get into it πŸ’…


🌸 NAME 🌸

trace_remote_alloc_buffer β€” dynamically allocate a trace buffer πŸŽ€

like, it makes a buffer appear out of nowhere. manifestation but for kernel memory. no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

int trace_remote_alloc_buffer (struct trace_buffer_desc *desc , size_t
desc_size , size_t buffer_size , const struct cpumask *cpumask );

four args, one int coming back at you, and yes the *desc is doing the heavy lifting here. look at her go 😭


πŸ’œ ARGUMENTS πŸ’œ

  • desc β€” the uninitialized trace_buffer_desc. literally uninitialized, okay? she's a blank canvas and this function is the artist 🎨
  • desc_size β€” the size of the trace_buffer_desc. must be at least equal to trace_buffer_desc_size. not less. we don't do less here πŸ™…β€β™€οΈ
  • buffer_size β€” size in bytes of each per-CPU ring-buffer. per. CPU. each one gets its own πŸ’–
  • cpumask β€” the CPUs to allocate a ring-buffer for. whoever's in the mask gets one, everyone else stays home 🌈

🧚 DESCRIPTION 🧚

okay so here's the vibe: this is the helper that dynamically allocates a set of pages β€” enough pages to cover buffer_size, mind you β€” for each CPU out of cpumask, and then fills in desc. that's the whole job. allocate, then fill. iconic behaviour honestly πŸ‘‘

and where do you call it from? most likely from trace_remote_callbacks.load_trace_buffer. iykyk 🫢


πŸ”₯ RETURN πŸ”₯

  • 0 on success β€” slay πŸŽ‰
  • a negative error code on failure β€” not slay, but at least you know πŸ’€

⭐ SEE ALSO ⭐

go read those too, bestie, they're the rest of the story 🌸


reminder: desc comes in uninitialized on purpose, and desc_size has a hard floor at trace_buffer_desc_size. don't skimp on the size, fr fr πŸ™ˆ

and that's the whole page, no notes πŸ’– this one ships from ./kernel/trace, dated October 2026 β€” go forth and allocate responsibly, you absolute kernel main character πŸŽ€βœ¨

πŸ“¦ where this page comes from