diff options
| author | Namhyung Kim <namhyung@kernel.org> | 2025-08-20 17:32:20 -0700 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-09-19 12:14:29 -0300 |
| commit | ece3c7754fc94aed15b7da567a4d22e30e3ee52b (patch) | |
| tree | 0aeb9b48f993eb7c54a521e9c92eba1f64ff5e83 /tools/perf/builtin-trace.c | |
| parent | d120cb34c9c75cf49d8ef821215d26d6e22fe8a9 (diff) | |
perf trace: Add --max-summary option
The --max-summary option is to limit the number of output lines for
syscall summary stats. The max applies to each entries like thread and
cgroups. For total summary, it will just print up to the given number.
For example,
$ sudo perf trace -as --max-summary 3 sleep 0.1
ThreadPoolServi (1011651), 114 events, 14.8%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
epoll_wait 38 0 95.589 0.000 2.515 11.153 28.98%
futex 9 0 0.040 0.002 0.004 0.014 28.63%
read 10 0 0.037 0.003 0.004 0.005 4.67%
sleep (1050529), 250 events, 32.4%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
clock_nanosleep 1 0 100.156 100.156 100.156 100.156 0.00%
execve 4 3 1.020 0.005 0.255 0.989 95.93%
openat 36 17 0.416 0.003 0.012 0.029 10.58%
...
And this is for per-cgroup summary using BPF.
$ sudo perf trace -as --max-summary 3 --summary-mode=cgroup --bpf-summary sleep 0.1
cgroup /user.slice/user-657345.slice/user@657345.service/session.slice/org.gnome.Shell@x11.service, 12 events
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
recvmsg 8 7 0.016 0.001 0.002 0.006 39.73%
ppoll 1 0 0.014 0.014 0.014 0.014 0.00%
write 2 0 0.010 0.002 0.005 0.008 61.02%
cgroup /user.slice/user-657345.slice/session-4.scope, 73 events
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
epoll_wait 8 0 13.461 0.010 1.683 12.235 89.66%
ioctl 20 0 0.204 0.001 0.010 0.113 54.01%
writev 11 0 0.164 0.004 0.015 0.042 20.34%
Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
| -rw-r--r-- | tools/perf/builtin-trace.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index fe737b3ac6e6..5f54777d8ba0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -196,6 +196,7 @@ struct trace { unsigned int max_stack; unsigned int min_stack; enum trace_summary_mode summary_mode; + int max_summary; int raw_augmented_syscalls_args_size; bool raw_augmented_syscalls; bool fd_path_disabled; @@ -4599,7 +4600,7 @@ out_disable: if (!err) { if (trace->summary) { if (trace->summary_bpf) - trace_print_bpf_summary(trace->output); + trace_print_bpf_summary(trace->output, trace->max_summary); else if (trace->summary_mode == SUMMARY__BY_TOTAL) trace__fprintf_total_summary(trace, trace->output); else @@ -4822,6 +4823,7 @@ static size_t syscall__dump_stats(struct trace *trace, int e_machine, FILE *fp, struct hashmap *syscall_stats) { size_t printed = 0; + int lines = 0; struct syscall *sc; struct syscall_entry *entries; @@ -4866,7 +4868,11 @@ static size_t syscall__dump_stats(struct trace *trace, int e_machine, FILE *fp, fprintf(fp, "\t\t\t\t%s: %d\n", perf_env__arch_strerrno(trace->host->env, e + 1), stats->errnos[e]); } } + lines++; } + + if (trace->max_summary && trace->max_summary <= lines) + break; } free(entries); @@ -5443,6 +5449,8 @@ int cmd_trace(int argc, const char **argv) OPT_BOOLEAN(0, "force-btf", &trace.force_btf, "Prefer btf_dump general pretty printer" "to customized ones"), OPT_BOOLEAN(0, "bpf-summary", &trace.summary_bpf, "Summary syscall stats in BPF"), + OPT_INTEGER(0, "max-summary", &trace.max_summary, + "Max number of entries in the summary."), OPTS_EVSWITCH(&trace.evswitch), OPT_END() }; |