aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/stacktrace_map_skip.c
diff options
context:
space:
mode:
authorNamhyung Kim <[email protected]>2022-03-14 11:20:41 -0700
committerAlexei Starovoitov <[email protected]>2022-03-20 19:16:23 -0700
commitee2a098851bfbe8bcdd964c0121f4246f00ff41e (patch)
treefb340d9c13b9ed24ef2b964a6c48149fab365467 /tools/testing/selftests/bpf/progs/stacktrace_map_skip.c
parentef078600eec20f20eb7833cf597d4a5edf2953c1 (diff)
bpf: Adjust BPF stack helper functions to accommodate skip > 0
Let's say that the caller has storage for num_elem stack frames. Then, the BPF stack helper functions walk the stack for only num_elem frames. This means that if skip > 0, one keeps only 'num_elem - skip' frames. This is because it sets init_nr in the perf_callchain_entry to the end of the buffer to save num_elem entries only. I believe it was because the perf callchain code unwound the stack frames until it reached the global max size (sysctl_perf_event_max_stack). However it now has perf_callchain_entry_ctx.max_stack to limit the iteration locally. This simplifies the code to handle init_nr in the BPF callstack entries and removes the confusion with the perf_event's __PERF_SAMPLE_CALLCHAIN_EARLY which sets init_nr to 0. Also change the comment on bpf_get_stack() in the header file to be more explicit what the return value means. Fixes: c195651e565a ("bpf: add bpf_get_stack helper") Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Link: https://lore.kernel.org/bpf/[email protected] Based-on-patch-by: Eugene Loh <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/stacktrace_map_skip.c')
0 files changed, 0 insertions, 0 deletions