]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: implement bpf_send_signal() helper
authorYonghong Song <yhs@fb.com>
Thu, 23 May 2019 21:47:45 +0000 (14:47 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 24 May 2019 21:26:47 +0000 (23:26 +0200)
commit6947ab3350197b37c99d45486047098722e5d5f1
tree50fa7aad59d5e95c7e18f3aa84e4271addbabbd7
parentdd93228303f91b3dff53bf140c4557b916dfa5da
bpf: implement bpf_send_signal() helper

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.

Such a mechanism can be implemented in the following way:
  . a perf ring buffer is created between bpf program
    and tracing app.
  . once a particular event happens, bpf program writes
    to the ring buffer and the tracing app gets notified.
  . the tracing app sends a signal SIGALARM to the hhvm.

But this method could have large delays and causing profiling
results skewed.

This patch implements bpf_send_signal() helper to send
a signal to hhvm in real time, resulting in intended stack traces.

Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/uapi/linux/bpf.h
kernel/trace/bpf_trace.c