]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: allow send_signal test to timeout
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 12 Nov 2024 11:09:05 +0000 (03:09 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 12 Nov 2024 21:53:27 +0000 (13:53 -0800)
commit3209139d00e594e30abc2429ea54c36bfbb9528a
treea37fd0702d751a0cbe58ed3df6d2c5ffa89c01c2
parent03066ed3105a71c2b0ad39ea44b6e5733ddd4a68
selftests/bpf: allow send_signal test to timeout

The following invocation:

  $ t1=send_signal/send_signal_perf_thread_remote \
    t2=send_signal/send_signal_nmi_thread_remote  \
    ./test_progs -t $t1,$t2

Leads to send_signal_nmi_thread_remote to be stuck
on a line 180:

  /* wait for result */
  err = read(pipe_c2p[0], buf, 1);

In this test case:
- perf event PERF_COUNT_HW_CPU_CYCLES is created for parent process;
- BPF program is attached to perf event, and sends a signal to child
  process when event occurs;
- parent program burns some CPU in busy loop and calls read() to get
  notification from child that it received a signal.

The perf event is declared with .sample_period = 1.
This forces perf to throttle events, and under some unclear conditions
the event does not always occur while parent is in busy loop.
After parent enters read() system call CPU cycles event won't be
generated for parent anymore. Thus, if perf event had not occurred
already the test is stuck.

This commit updates the parent to wait for notification with a timeout,
doing several iterations of busy loop + read_with_timeout().

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20241112110906.3045278-4-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/send_signal.c