]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Fix ringbuf selftest sample counting undeterminism
authorAndrii Nakryiko <andriin@fb.com>
Mon, 8 Jun 2020 00:36:15 +0000 (17:36 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 8 Jun 2020 14:00:42 +0000 (16:00 +0200)
commit38f2e3a3a90ec9d300c36b1552920a1acecd390f
tree9b3c95033f3b723e5ff83c3c47023b1406e33e61
parentdec4a59f7edd16a99f748d5b5ec1dbdad7262626
selftests/bpf: Fix ringbuf selftest sample counting undeterminism

Fix test race, in which background poll can get either 5 or 6 samples,
depending on timing of notification. Prevent this by open-coding sample
triggering and forcing notification for the very last sample only.

Also switch to using atomic increments and exchanges for more obviously
reliable counting and checking. Additionally, check expected processed sample
counters for single-threaded use cases as well.

Fixes: c9c2670d34a1 ("selftests/bpf: Fix sample_cnt shared between two threads")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200608003615.3549991-1-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/ringbuf.c