bpf_cpumask_any_distribute(9)
π
bpf_cpumask_any_distribute β the kernel API manual, bestie edition β¨
okay so this is the page for bpf_cpumask_any_distribute(9) from the Kernel API Manual, and it's honestly kinda iconic β it just picks a random CPU out of a cpumask for you. Let's get into it π«Ά
πΈ NAME πΈ
bpf_cpumask_any_distribute β return a random set CPU from a cpumask. that's it. that's the whole job. no cap π
β SYNOPSIS β
__bpf_kfunc u32 bpf_cpumask_any_distribute (const struct cpumask
*cpumask );
like, the return type is u32, it's a __bpf_kfunc, and it takes one const struct cpumask * β noted, saved, memorized π
π¦ ARGUMENTS π¦
cpumaskβ the cpumask being queried. that's the one you're asking "hey who's in here" about β¨
π RETURN π
two possible vibes here, bestie:
- a random set bit within
[0, num_cpus)β if at least one bit is set π >= num_cpusβ if no bit is set at all π (so like, if you get a number that big, the mask was empty, that's your tell)
π DESCRIPTION π
the actual words on the page: a struct bpf_cpumask pointer may be safely passed to src. so yeah β safe to pass that pointer over to src, you're good, no stress π«Ά
π SEE ALSO π
go read these next, they're all in the family and they all ate:
- Kernel file
./kernel/bpf/cpumask.c struct bpf_cpumask(9)bpf_cpumask_create(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_and_distribute(9)bpf_cpumask_weight(9)bpf_cpumask_populate(9)
and that's the whole page, mwah π this one lives in ./kernel/bpf and it's dated October 2026 β go off, king πβ¨
π¦ 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