On 1/13/20 5:19 PM, Andrii Nakryiko wrote: > On Thu, Jan 9, 2020 at 5:16 PM Yonghong Song <yhs@xxxxxx> wrote: >> >> The test_progs send_signal() is amended to test >> bpf_send_signal_thread() as well. >> >> $ ./test_progs -n 40 >> #40/1 send_signal_tracepoint:OK >> #40/2 send_signal_perf:OK >> #40/3 send_signal_nmi:OK >> #40/4 send_signal_tracepoint_thread:OK >> #40/5 send_signal_perf_thread:OK >> #40/6 send_signal_nmi_thread:OK >> #40 send_signal:OK >> Summary: 1/6 PASSED, 0 SKIPPED, 0 FAILED >> >> Signed-off-by: Yonghong Song <yhs@xxxxxx> >> --- >> tools/include/uapi/linux/bpf.h | 18 +++++++++-- > > maybe do tools/uapi header sync in a first patch, along the original change? Will do. > >> .../selftests/bpf/prog_tests/send_signal.c | 30 ++++++++++++------- >> .../bpf/progs/test_send_signal_kern.c | 9 ++++-- >> 3 files changed, 42 insertions(+), 15 deletions(-) >> > > [...] > >> diff --git a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c >> index 0e6be01157e6..4a722024c32b 100644 >> --- a/tools/testing/selftests/bpf/progs/test_send_signal_kern.c >> +++ b/tools/testing/selftests/bpf/progs/test_send_signal_kern.c >> @@ -23,6 +23,7 @@ int bpf_send_signal_test(void *ctx) >> { >> __u64 *info_val, *status_val; >> __u32 key = 0, pid, sig; >> + int use_signal_thread; >> int ret; >> >> status_val = bpf_map_lookup_elem(&status_map, &key); >> @@ -33,11 +34,15 @@ int bpf_send_signal_test(void *ctx) >> if (!info_val || *info_val == 0) >> return 0; >> >> - sig = *info_val >> 32; >> + use_signal_thread = *info_val >> 48; >> + sig = *info_val >> 32 & 0xFFFF; >> pid = *info_val & 0xffffFFFF; > > Would you mind rewriting this test w/ BPF skeleton and global data? It > would make it cleaner without all this masking stuff? Previously I made the change to minimize the number of changed lines. But since you are mentioning rewriting here, I will do it in v2. > >> >> if ((bpf_get_current_pid_tgid() >> 32) == pid) { >> - ret = bpf_send_signal(sig); >> + if (use_signal_thread) >> + ret = bpf_send_signal_thread(sig); >> + else >> + ret = bpf_send_signal(sig); >> if (ret == 0) >> *status_val = 1; >> } >> -- >> 2.17.1 >>