bpf_cpumask_create(9)
π 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 akptr, or freed withbpf_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_cpumaskinstance on success. π she ate. NULLif 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 π
struct bpf_cpumask(9)bpf_cpumask_acquire(9)bpf_cpumask_release(9)bpf_cpumask_first(9)bpf_cpumask_first_zero(9)bpf_cpumask_first_and(9)bpf_cpumask_set_cpu(9)bpf_cpumask_clear_cpu(9)bpf_cpumask_test_cpu(9)bpf_cpumask_test_and_set_cpu(9)bpf_cpumask_test_and_clear_cpu(9)bpf_cpumask_setall(9)bpf_cpumask_clear(9)bpf_cpumask_and(9)bpf_cpumask_or(9)bpf_cpumask_xor(9)bpf_cpumask_equal(9)bpf_cpumask_intersects(9)bpf_cpumask_subset(9)bpf_cpumask_empty(9)bpf_cpumask_full(9)bpf_cpumask_copy(9)bpf_cpumask_any_distribute(9)bpf_cpumask_any_and_distribute(9)bpf_cpumask_weight(9)bpf_cpumask_populate(9)
π 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
- 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