diff options
author | Namhyung Kim <namhyung@kernel.org> | 2022-12-09 22:07:25 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-12-14 17:24:31 +0300 |
commit | eca949b2b4addd941d369d4c2014b87f3c3e203b (patch) | |
tree | 722907c1e3f3b8a96b48c83eaed99f4df6621029 /tools/perf/builtin-lock.c | |
parent | fd507d3e359c7e06d74321cd3d8a5ec8769d05a9 (diff) | |
download | linux-eca949b2b4addd941d369d4c2014b87f3c3e203b.tar.xz |
perf lock contention: Implement -t/--threads option for BPF
The BPF didn't show the per-thread stat properly. Use task's thread id (PID)
as a key instead of stack_id and add a task_data map to save task comm names.
$ sudo ./perf lock con -abt -E 5 sleep 1
contended total wait max wait avg wait pid comm
1 740.66 ms 740.66 ms 740.66 ms 1950 nv_queue
3 305.50 ms 298.19 ms 101.83 ms 1884 nvidia-modeset/
1 25.14 us 25.14 us 25.14 us 2725038 EventManager_De
12 23.09 us 9.30 us 1.92 us 0 swapper
1 20.18 us 20.18 us 20.18 us 2725033 EventManager_De
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Blake Jones <blakejones@google.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 <song@kernel.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221209190727.759804-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-lock.c')
-rw-r--r-- | tools/perf/builtin-lock.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 15ce6358f127..6fa3cdfec5cb 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -12,6 +12,7 @@ #include "util/target.h" #include "util/callchain.h" #include "util/lock-contention.h" +#include "util/bpf_skel/lock_data.h" #include <subcmd/pager.h> #include <subcmd/parse-options.h> @@ -61,11 +62,7 @@ static int max_stack_depth = CONTENTION_STACK_DEPTH; static int stack_skip = CONTENTION_STACK_SKIP; static int print_nr_entries = INT_MAX / 2; -static enum { - LOCK_AGGR_ADDR, - LOCK_AGGR_TASK, - LOCK_AGGR_CALLER, -} aggr_mode = LOCK_AGGR_ADDR; +static enum lock_aggr_mode aggr_mode = LOCK_AGGR_ADDR; static struct thread_stat *thread_stat_find(u32 tid) { @@ -1619,6 +1616,7 @@ static int __cmd_contention(int argc, const char **argv) .map_nr_entries = bpf_map_entries, .max_stack = max_stack_depth, .stack_skip = stack_skip, + .aggr_mode = show_thread_stats ? LOCK_AGGR_TASK : LOCK_AGGR_CALLER, }; session = perf_session__new(use_bpf ? NULL : &data, &eops); @@ -1691,11 +1689,6 @@ static int __cmd_contention(int argc, const char **argv) if (select_key(true)) goto out_delete; - if (show_thread_stats) - aggr_mode = LOCK_AGGR_TASK; - else - aggr_mode = LOCK_AGGR_CALLER; - if (use_bpf) { lock_contention_start(); if (argc) |