On 05/21, Yonghong Song wrote: > This patch tries to solve the following specific use case. > > Currently, bpf program can already collect stack traces > through kernel function get_perf_callchain() > when certain events happens (e.g., cache miss counter or > cpu clock counter overflows). But such stack traces are > not enough for jitted programs, e.g., hhvm (jited php). > To get real stack trace, jit engine internal data structures > need to be traversed in order to get the real user functions. > > bpf program itself may not be the best place to traverse > the jit engine as the traversing logic could be complex and > it is not a stable interface either. > > Instead, hhvm implements a signal handler, > e.g. for SIGALARM, and a set of program locations which > it can dump stack traces. When it receives a signal, it will > dump the stack in next such program location. > [..] > This patch implements bpf_send_signal() helper to send > a signal to hhvm in real time, resulting in intended stack traces. Series looks good. One minor nit/question: maybe rename bpf_send_signal to something like bpf_send_signal_to_current/bpf_current_send_signal/etc? bpf_send_signal is too generic now that you send the signal to the current process.. > Patch #1 implemented the bpf_send_helper() in the kernel, > Patch #2 synced uapi header bpf.h to tools directory. > Patch #3 added a self test which covers tracepoint > and perf_event bpf programs. > > Changelogs: > RFC v1 => v2: > . previous version allows to send signal to an arbitrary > pid. This version just sends the signal to current > task to avoid unstable pid and potential races between > sending signals and task state changes for the pid. > > Yonghong Song (3): > bpf: implement bpf_send_signal() helper > tools/bpf: sync bpf uapi header bpf.h to tools directory > tools/bpf: add a selftest for bpf_send_signal() helper > > include/uapi/linux/bpf.h | 17 +- > kernel/trace/bpf_trace.c | 67 ++++++ > tools/include/uapi/linux/bpf.h | 17 +- > tools/testing/selftests/bpf/Makefile | 3 +- > tools/testing/selftests/bpf/bpf_helpers.h | 1 + > .../bpf/progs/test_send_signal_kern.c | 51 +++++ > .../selftests/bpf/test_send_signal_user.c | 212 ++++++++++++++++++ > 7 files changed, 365 insertions(+), 3 deletions(-) > create mode 100644 tools/testing/selftests/bpf/progs/test_send_signal_kern.c > create mode 100644 tools/testing/selftests/bpf/test_send_signal_user.c > > -- > 2.17.1 >