bpf_cpumask_weight(9)
β¨ 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 π:
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_distribute(9)bpf_cpumask_any_and_distribute(9)bpf_cpumask_populate(9)
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
- 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