selftests/bpf: Fix flaky send_signal test
authorYonghong Song <yhs@fb.com>
Tue, 17 Aug 2021 19:09:23 +0000 (12:09 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 17 Aug 2021 21:08:30 +0000 (14:08 -0700)
commitb16ac5bf732a5e23d164cf908ec7742d6a6120d3
tree0dc3cebe163058e198e270ed5681468ed6526ab3
parent6f6cc426451bb15a85896efc7c85665b59af04ae
selftests/bpf: Fix flaky send_signal test

libbpf CI has reported send_signal test is flaky although
I am not able to reproduce it in my local environment.
But I am able to reproduce with on-demand libbpf CI ([1]).

Through code analysis, the following is possible reason.
The failed subtest runs bpf program in softirq environment.
Since bpf_send_signal() only sends to a fork of "test_progs"
process. If the underlying current task is
not "test_progs", bpf_send_signal() will not be triggered
and the subtest will fail.

To reduce the chances where the underlying process is not
the intended one, this patch boosted scheduling priority to
-20 (highest allowed by setpriority() call). And I did
10 runs with on-demand libbpf CI with this patch and I
didn't observe any failures.

 [1] https://github.com/libbpf/libbpf/actions/workflows/ondemand.yml

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210817190923.3186725-1-yhs@fb.com
tools/testing/selftests/bpf/prog_tests/send_signal.c