From: Yucong Sun Date: Wed, 6 Oct 2021 18:56:11 +0000 (-0700) Subject: selftests/bpf: Fix race condition in enable_stats X-Git-Tag: v6.6.17~8953^2~2^2~62^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d719de0d2f3cbdb5890a147b90a51c5eaaef103e;p=platform%2Fkernel%2Flinux-rpi.git selftests/bpf: Fix race condition in enable_stats In parallel execution mode, this test now need to use atomic operation to avoid race condition. Signed-off-by: Yucong Sun Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20211006185619.364369-7-fallentree@fb.com --- diff --git a/tools/testing/selftests/bpf/progs/test_enable_stats.c b/tools/testing/selftests/bpf/progs/test_enable_stats.c index 01a002a..1705097 100644 --- 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; }