bpf: Add bpf_cpumask_weight() kfunc
authorDavid Vernet <void@manifault.com>
Thu, 7 Dec 2023 21:08:42 +0000 (15:08 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 10 Dec 2023 05:37:33 +0000 (21:37 -0800)
commita6de18f310a511278c1ff16b96eb2d500eada725
treee3a2a52d95faf82312d1e13f815fc797a4b6bf4a
parent5181dc08f79583c6dead80208137a97e68ff07b0
bpf: Add bpf_cpumask_weight() kfunc

It can be useful to query how many bits are set in a cpumask. For
example, if you want to perform special logic for the last remaining
core that's set in a mask. Let's therefore add a new
bpf_cpumask_weight() kfunc which checks how many bits are set in a mask.

Signed-off-by: David Vernet <void@manifault.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231207210843.168466-2-void@manifault.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Documentation/bpf/cpumasks.rst
kernel/bpf/cpumask.c