Skip to content

bpf: Clear invalid cpumask bits after population

Avi Weiss bpf linux-kselftest 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Clear invalid tail bits when populating a cpumaskkernel/bpf/cpumask.c+1 -10 replies
2/2selftests/bpf: Check cpumask weight after populationtools/testing/selftests/bpf/progs/cpumask_success.c+3 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf 0/2] bpf: Clear invalid cpumask bits after population

bpf_cpumask_populate() copies the final bitmap word without clearing bits beyond nr_cpu_ids. On configurations where cpumask operations scan a whole word, those bits can inflate the reported mask weight.

Patch 1 clears the unused tail bits. Patch 2 checks the resulting weight in the existing populate selftest.

Tested on 97d73c825122 (x86_64, CONFIG_NR_CPUS=64, 4 possible CPUs):
- Unpatched: cpumask/test_populate FAIL (err=5).
- Patched: cpumask/test_populate PASS.
- Patched: cpumask selftests 36/36 subtests PASS.

Not run: allmodconfig, allyesconfig, the full BPF selftest suite, cross-architecture builds or a dedicated performance benchmark. The changes have not been rebuilt on top of the target BPF fixes tip.

Avi Weiss (2):
bpf: Clear invalid tail bits when populating a cpumask selftests/bpf: Check cpumask weight after population

 kernel/bpf/cpumask.c                                | 2 +-
 tools/testing/selftests/bpf/progs/cpumask_success.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

base-commit: 4b4eb7f44ee05754339d07e9df649809f45d14c5

Signature · 1 line
2.43.0