bpf_cpumask_weight(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ bpf_cpumask_weight(9) β€” the kernel API manual, bestie edition ✨

okay so real talk, this little page is from the Kernel API Manual section 9, and it's about bpf_cpumask_weight β€” yes the whole entire function is just "how many bits are turned on in this mask", and honestly? iconic. lowkey the most straightforward glow-up in the whole cpumask family. let's get into it 🫢


🌸 NAME 🌸

bpf_cpumask_weight β€” returns the number of bits in @cpumask. that's it, that's the whole vibe. no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

__bpf_kfunc u32 bpf_cpumask_weight (const struct cpumask *cpumask );

yes bestie, note the __bpf_kfunc β€” that's the special sauce that makes it callable from BPF. and it hands you back a u32. periodt.


πŸŽ€ ARGUMENTS πŸŽ€

  • cpumask β€” the cpumask you're querying, aka the thing you're asking "so how many bits of u are actually set, huh?" about πŸ’…

🌈 DESCRIPTION 🌈

the whole job: count the set bits in the given cpumask. literally just popcount energy. it's giving "count how many CPUs are in the mask" and it does NOT miss. πŸ’–


⭐ RETURN ⭐

  • the number of bits set in the mask. that's the return value, that's the tea πŸ“

πŸ”₯ SEE ALSO πŸ”₯

the kernel file lives at ./kernel/bpf/cpumask.c and honestly the whole friend group shows up here, so let's do the roll call 😭:

every single one of them, no skips, we don't gatekeep here πŸ‘‘


ok and one last thing β€” this page comes from ./kernel/bpf, dated October 2026. so like, screenshot this for the group chat: we're reading the kernel docs from the future, fr fr πŸ’€βœ¨ bye bestie, go count some bits πŸ’œ
πŸ“¦ where this page comes from