aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/bpf_skel/lock_contention.bpf.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2022-09-11 22:53:14 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-10-04 08:55:22 -0300
commitc1da8dd5c11dabd50b1578c6b43d73c7bbc28963 (patch)
treef86057657e90c8ce137aaffa5417d2ccbf216be1 /tools/perf/util/bpf_skel/lock_contention.bpf.c
parentperf lock contention: Allow to change stack depth and skip (diff)
downloadlinux-dev-c1da8dd5c11dabd50b1578c6b43d73c7bbc28963.tar.xz
linux-dev-c1da8dd5c11dabd50b1578c6b43d73c7bbc28963.zip
perf lock contention: Skip stack trace from BPF
Currently it collects stack traces to max size then skip entries. Because we don't have control how to skip perf callchains. But BPF can do it with bpf_get_stackid() with a flag. Say we have max-stack=4 and stack-skip=2, we get these stack traces. Before: After: .---> +---+ <--. .---> +---+ <--. | | | | | | | | | +---+ usable | +---+ | max | | | max | | | stack +---+ <--' stack +---+ usable | | X | | | | | | +---+ skip | +---+ | | | X | | | | | `---> +---+ `---> +---+ <--' <=== collection | X | +---+ skip | X | +---+ Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Cc: bpf@vger.kernel.org Link: https://lore.kernel.org/r/20220912055314.744552-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to '')
-rw-r--r--tools/perf/util/bpf_skel/lock_contention.bpf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/util/bpf_skel/lock_contention.bpf.c
index 9e8b94eb6320..e107d71f0f1a 100644
--- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
+++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
@@ -72,6 +72,7 @@ struct {
int enabled;
int has_cpu;
int has_task;
+int stack_skip;
/* error stat */
unsigned long lost;
@@ -117,7 +118,7 @@ int contention_begin(u64 *ctx)
pelem->timestamp = bpf_ktime_get_ns();
pelem->lock = (__u64)ctx[0];
pelem->flags = (__u32)ctx[1];
- pelem->stack_id = bpf_get_stackid(ctx, &stacks, BPF_F_FAST_STACK_CMP);
+ pelem->stack_id = bpf_get_stackid(ctx, &stacks, BPF_F_FAST_STACK_CMP | stack_skip);
if (pelem->stack_id < 0)
lost++;