Skip to content

perf stat: Improve perf stat output (v1)

Namhyung Kim linux-perf-users lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest19 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19perf stat: Clear screen only if output file is a ttytools/perf/builtin-stat.c+8 -00 replies
2/19perf stat: Split print_running() functiontools/perf/util/stat-display.c+27 -100 replies
3/19perf stat: Split print_noise_pct() functiontools/perf/util/stat-display.c+23 -40 replies
4/19perf stat: Split print_cgroup() functiontools/perf/util/stat-display.c+19 -20 replies
5/19perf stat: Split aggr_printout() functiontools/perf/util/stat-display.c+121 -990 replies
6/19perf stat: Factor out print_counter_value() functiontools/perf/util/stat-display.c+53 -280 replies
7/19perf stat: Handle bad events in abs_printout()tools/perf/util/stat-display.c+27 -410 replies
8/19perf stat: Add before_metric argumenttools/perf/util/stat-display.c+42 -400 replies
9/19perf stat: Align cgroup namestools/perf/util/stat-display.c+1 -10 replies
10/19perf stat: Split print_metric_headers() functiontools/perf/util/stat-display.c+37 -150 replies
11/19perf stat: Factor out prepare_interval()tools/perf/util/stat-display.c+24 -150 replies
12/19perf stat: Cleanup interval print alignmenttools/perf/util/stat-display.c+91 -740 replies
13/19perf stat: Remove impossible conditiontools/perf/util/stat-display.c+0 -30 replies
14/19perf stat: Rework header displaytools/perf/util/stat-display.c+106 -790 replies
15/19perf stat: Move condition to print_footer()tools/perf/util/stat-display.c+4 -20 replies
16/19perf stat: Factor out prefix displaytools/perf/util/stat-display.c+15 -280 replies
17/19perf stat: Factor out print_metric_{begin,end}()tools/perf/util/stat-display.c+34 -220 replies
18/19perf stat: Support --for-each-cgroup and --metric-onlytools/perf/util/stat-display.c+47 -110 replies
19/19perf stat: Add print_aggr_cgroup() for --for-each-cgroup and --topdowntools/perf/util/stat-display.c+40 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCHSET 00/19] perf stat: Improve perf stat output (v1)

Hello,

I'm working on cleanup up the perf stat code. The main focus this time is the display logic which has various combinations of options.

I split the code for each output mode - std, csv and json. And then organize them according to the purpose like header, prefix, value, metric and footer. I hope this would help maintaining the code a bit more.

Also I found that cgroup support is missing or insufficient. Specifically when --for-each-cgroup option is given, it'd have multiple copies of the events for those cgroups. Then the output should group the result. This is true for the normal output mode, but the metric- only mode didn't support it well.

With this change, I can see the per-cgroup topdown metrics like below:

  $ sudo ./perf stat -a --topdown --for-each-cgroup user.slice,system.slice sleep 3
  nmi_watchdog enabled with topdown. May give wrong results.
  Disable with echo 0 > /proc/sys/kernel/nmi_watchdog

Performance counter stats for 'system wide':

retiring bad speculation frontend bound backend bound

  S0-D0-C0      2  user.slice            117.3%         3.9%            47.8%           -69.1%
  S0-D0-C1      2  user.slice            119.8%         4.1%            49.3%           -73.2%
  S0-D0-C2      2  user.slice             24.4%         7.9%            68.4%             0.0%
  S0-D0-C3      2  user.slice             24.0%         9.2%            91.2%           -24.4%
  S0-D0-C0      2  system.slice           73.5%         4.0%            19.4%             3.1%
  S0-D0-C1      2  system.slice           90.0%         5.8%            19.7%           -15.5%
  S0-D0-C2      2  system.slice          101.2%         6.6%            33.4%           -41.1%
  S0-D0-C3      2  system.slice           90.7%         4.9%            22.3%           -18.0%
         3.001678216 seconds time elapsed

You can get it from 'perf/stat-display-v1' branch in

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung

Namhyung Kim (19):
perf stat: Clear screen only if output file is a tty
perf stat: Split print_running() function
perf stat: Split print_noise_pct() function
perf stat: Split print_cgroup() function
perf stat: Split aggr_printout() function
perf stat: Factor out print_counter_value() function
perf stat: Handle bad events in abs_printout()
perf stat: Add before_metric argument
perf stat: Align cgroup names
perf stat: Split print_metric_headers() function
perf stat: Factor out prepare_interval()
perf stat: Cleanup interval print alignment
perf stat: Remove impossible condition
perf stat: Rework header display
perf stat: Move condition to print_footer()
perf stat: Factor out prefix display
perf stat: Factor out print_metric_{begin,end}()
perf stat: Support --for-each-cgroup and --metric-only perf stat: Add print_aggr_cgroup() for --for-each-cgroup and --topdown

 tools/perf/builtin-stat.c      |   8 +
 tools/perf/util/stat-display.c | 996 ++++++++++++++++++++-------------
 2 files changed, 624 insertions(+), 380 deletions(-)

base-commit: 7565f9617efac0c0c8e2dbd08dbe0695d56684f5

Signature · 1 line
2.38.1.493.g58b659f92b-goog