]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix sample_cnt shared between two threads
authorAndrii Nakryiko <andriin@fb.com>
Tue, 2 Jun 2020 05:03:49 +0000 (22:03 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 2 Jun 2020 18:54:56 +0000 (11:54 -0700)
commitc9c2670d34a1b6bae8b1474acc86e817c9818344
tree7ddc17999040baaba1cc4a12e3e0df427f85ec41
parent5af62d10312f4c8f01fc23ad8b0f3735c2d06ffc
selftests/bpf: Fix sample_cnt shared between two threads

Make sample_cnt volatile to fix possible selftests failure due to compiler
optimization preventing latest sample_cnt value to be visible to main thread.
sample_cnt is incremented in background thread, which is then joined into main
thread. So in terms of visibility sample_cnt update is ok. But because it's
not volatile, compiler might make optimizations that would prevent main thread
to see latest updated value. Fix this by marking global variable volatile.

Fixes: b7d03ba86d3a ("selftests/bpf: Add BPF ringbuf selftests")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200602050349.215037-1-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/ringbuf.c