]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Harden cpu flags test for lru_percpu_hash map
authorLeon Hwang <leon.hwang@linux.dev>
Mon, 19 Jan 2026 13:34:17 +0000 (21:34 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 26 Jan 2026 18:59:07 +0000 (10:59 -0800)
commit78980b4c7fcb5ef74b7af65fbef5ce8d718cf791
treed2611256cc2e9982192ad07e6ba46ec6792daf97
parent59ef78d403806b9d1f8373ea1a2fe63f88ba17da
selftests/bpf: Harden cpu flags test for lru_percpu_hash map

CI occasionally reports failures in the
percpu_alloc/cpu_flag_lru_percpu_hash selftest, for example:

 First test_progs failure (test_progs_no_alu32-x86_64-llvm-21):
 #264/15 percpu_alloc/cpu_flag_lru_percpu_hash
 ...
 test_percpu_map_op_cpu_flag:FAIL:bpf_map_lookup_batch value on specified cpu unexpected bpf_map_lookup_batch value on specified cpu: actual 0 != expected 3735929054

The unexpected value indicates that an element was removed from the map.
However, the test never calls delete_elem(), so the only possible cause
is LRU eviction.

This can happen when the current task migrates to another CPU: an
update_elem() triggers eviction because there is no available LRU node
on local freelist and global freelist.

Harden the test against this behavior by provisioning sufficient spare
elements. Set max_entries to 'nr_cpus * 2' and restrict the test to using
the first nr_cpus entries, ensuring that updates do not spuriously trigger
LRU eviction.

Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20260119133417.19739-1-leon.hwang@linux.dev
tools/testing/selftests/bpf/prog_tests/percpu_alloc.c