From: Yucong Sun <sunyucong@gmail.com>
Date: Wed, 6 Oct 2021 11:56:11 -0700
Subject: selftests/bpf: Fix race condition in enable_stats
Patch-mainline: v5.16-rc1
Git-commit: d719de0d2f3cbdb5890a147b90a51c5eaaef103e
References: jsc#PED-1377
In parallel execution mode, this test now need to use atomic operation
to avoid race condition.
Signed-off-by: Yucong Sun <sunyucong@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211006185619.364369-7-fallentree@fb.com
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
tools/testing/selftests/bpf/progs/test_enable_stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tools/testing/selftests/bpf/progs/test_enable_stats.c
+++ b/tools/testing/selftests/bpf/progs/test_enable_stats.c
@@ -13,6 +13,6 @@ __u64 count = 0;
SEC("raw_tracepoint/sys_enter")
int test_enable_stats(void *ctx)
{
- count += 1;
+ __sync_fetch_and_add(&count, 1);
return 0;
}