bpf_cpumask_any_distribute(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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