bpf_cpumask_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_cpumask_create(9) β€” the Kernel API Manual moment

okay bestie, so this is bpf_cpumask_create from section 9 of the Kernel API Manual, and honestly? it's iconic. it's giving "i make cpumasks so your BPF program can have a little autonomy." let's get into it πŸŽ€


✨ NAME ✨

bpf_cpumask_create β€” Create a mutable BPF cpumask. literally that's the whole vibe. mutable. BPF. cpumask. slay πŸ’…


🌸 SYNOPSIS 🌸

__bpf_kfunc struct bpf_cpumask * bpf_cpumask_create (void );

no cap, that's the signature. __bpf_kfunc, returns a struct bpf_cpumask *, takes void. periodt.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • void β€” no arguments. none. zero. she takes nothing and she gives you a cpumask. main character energy fr fr πŸ’–

🧚 DESCRIPTION 🧚

okay so here's the tea πŸ‘‘

bpf_cpumask_create allocates a cpumask that can be queried, mutated, acquired, and released by a BPF program. like, she's fully featured. she does it all.

🚨 IMPORTANT CAVEAT, bestie, do not skip this: the cpumask returned by this function must either be embedded in a map as a kptr, or freed with bpf_cpumask_release. there is no third option. you cannot just vibe and forget about her 😭

and listen β€” bpf_cpumask_create allocates memory using the BPF memory allocator, and it will not block. so she's not gonna sit there making you wait, she's non-blocking, she's efficient, we love her for it 🫢

but also… she may return NULL if no memory is available. so like. check your returns. ngl that's just good manners πŸ’€


πŸ”₯ RETURN πŸ”₯

  • A pointer to a new struct bpf_cpumask instance on success. πŸŽ‰ she ate.
  • NULL if the BPF memory allocator is out of memory. 😭 she tried her best.

πŸ‘‘ SEE ALSO πŸ‘‘

okay this is the part where she name-drops her whole friend group and honestly every single one of them is a baddie. the source of truth is the kernel file ./kernel/bpf/cpumask.c. go read it, iykyk πŸ’œ


🌈 the cute sign-off 🌈

this little masterpiece lives in ./kernel/bpf, and she's dated October 2026 β€” yeah, from the future, she's ahead of her time ✨ and the page itself is bpf_cpumask_create(9), obviously, because she's the moment, she's the legend πŸŽ€

anyway bestie go free your cpumasks with bpf_cpumask_release or embed them as a kptr, drink some water, and stan non-blocking allocation πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from