The populate selftest checks individual valid CPU bits, but it does not check whether bits beyond nr_cpu_ids affect cpumask operations that scan the entire final word. Verify the weight after populating an alternating-bit source to catch leftover invalid bits. Signed-off-by: Avi Weiss --- tools/testing/selftests/bpf/progs/cpumask_success.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/cpumask_success.c b/tools/testing/selftests/bpf/progs/cpumask_success.c index ddaba4318c57..09c0ee35d636 100644 --- a/tools/testing/selftests/bpf/progs/cpumask_success.c +++ b/tools/testing/selftests/bpf/progs/cpumask_success.c @@ -887,6 +887,9 @@ int BPF_PROG(test_populate, struct task_struct *task, u64 clone_flags) break; } + if (!err && bpf_cpumask_weight((const struct cpumask *)mask) != nr_cpus / 2) + err = 5; + out: bpf_cpumask_release(mask); -- 2.43.0