Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <sunyucong@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211006185619.364369-7-fallentree@fb.com

authored by

Yucong Sun and committed by
Andrii Nakryiko
d719de0d e87c3434

+1 -1
+1 -1
tools/testing/selftests/bpf/progs/test_enable_stats.c
··· 13 13 SEC("raw_tracepoint/sys_enter") 14 14 int test_enable_stats(void *ctx) 15 15 { 16 - count += 1; 16 + __sync_fetch_and_add(&count, 1); 17 17 return 0; 18 18 }