]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Introduce helper bpf_get_task_stack()
authorSong Liu <songliubraving@fb.com>
Tue, 30 Jun 2020 06:28:44 +0000 (23:28 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 1 Jul 2020 15:23:19 +0000 (08:23 -0700)
commite84990604f273b9e2ac42db841b20ef4e4ead79c
treedf5f451d9328757debc8dd7b81a5e34149577f90
parent4c92d458b048335fdc541cf3153accff3248872a
bpf: Introduce helper bpf_get_task_stack()

Introduce helper bpf_get_task_stack(), which dumps stack trace of given
task. This is different to bpf_get_stack(), which gets stack track of
current task. One potential use case of bpf_get_task_stack() is to call
it from bpf_iter__task and dump all /proc/<pid>/stack to a seq_file.

bpf_get_task_stack() uses stack_trace_save_tsk() instead of
get_perf_callchain() for kernel stack. The benefit of this choice is that
stack_trace_save_tsk() doesn't require changes in arch/. The downside of
using stack_trace_save_tsk() is that stack_trace_save_tsk() dumps the
stack trace to unsigned long array. For 32-bit systems, we need to
translate it to u64 array.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200630062846.664389-3-songliubraving@fb.com
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/stackmap.c
kernel/bpf/verifier.c
kernel/trace/bpf_trace.c
scripts/bpf_helpers_doc.py
tools/include/uapi/linux/bpf.h