summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorQiliang Yuan <odys.yuan@gmail.com>2026-10-09 09:49:32 +0800
committerKumar Kartikeya Dwivedi <memxor@gmail.com>2026-10-19 04:22:58 +0200
commite2c978ad415ce223e71f6ddaa92778225eca0bef (patch)
treec10f2250dff4ac968b2add2811119d0f6619c973 /tools
parent44b6b1dfb259e8baa5226679945fb6c25d11c207 (diff)
selftests/bpf: Run the cpumask map insert tests only for the test task
verify_success() attaches each cpumask test program to task_newtask, forks a single child, and expects err to be 0 afterwards. Most programs return right away for other tasks than the test one. test_insert_leave and test_insert_remove_release don't, and insert a cpumask into the single entry of __cpumask_map for every task created in the system while they are attached. test_insert_leave leaves its cpumask in the map, so a second task created, for instance by a test running in parallel, fails to insert one and sets err to 3. Two tasks created at the same time can do the same to test_insert_remove_release. Return early for other tasks than the test one in both programs, as the other programs do. Fixes: 7b6abcfa15cd ("selftests/bpf: Add selftest suite for cpumask kfuncs") Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com> Link: https://lore.kernel.org/bpf/20261009-selftests-bpf-cpumask-insert-filter-v1-1-3249218594d7@gmail.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/progs/cpumask_success.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/cpumask_success.c b/tools/testing/selftests/bpf/progs/cpumask_success.c
index 36f77b9732d4..ddaba4318c57 100644
--- a/tools/testing/selftests/bpf/progs/cpumask_success.c
+++ b/tools/testing/selftests/bpf/progs/cpumask_success.c
@@ -460,6 +460,9 @@ int BPF_PROG(test_insert_leave, struct task_struct *task, u64 clone_flags)
{
struct bpf_cpumask *cpumask;
+ if (!is_test_task())
+ return 0;
+
cpumask = create_cpumask();
if (!cpumask)
return 0;
@@ -476,6 +479,9 @@ int BPF_PROG(test_insert_remove_release, struct task_struct *task, u64 clone_fla
struct bpf_cpumask *cpumask;
struct __cpumask_map_value *v;
+ if (!is_test_task())
+ return 0;
+
cpumask = create_cpumask();
if (!cpumask)
return 0;