Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add -H short option for --hierarchy

I found the hierarchy mode useful, but it's easy to make a typo when
using it. Let's add a short option for that.

Also update the documentation. :)

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20240125055124.1579617-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+61 -4
+28 -1
tools/perf/Documentation/perf-report.txt
··· 531 531 --raw-trace:: 532 532 When displaying traceevent output, do not use print fmt or plugins. 533 533 534 + -H:: 534 535 --hierarchy:: 535 - Enable hierarchical output. 536 + Enable hierarchical output. In the hierarchy mode, each sort key groups 537 + samples based on the criteria and then sub-divide it using the lower 538 + level sort key. 539 + 540 + For example: 541 + In normal output: 542 + 543 + perf report -s dso,sym 544 + # Overhead Shared Object Symbol 545 + 50.00% [kernel.kallsyms] [k] kfunc1 546 + 20.00% perf [.] foo 547 + 15.00% [kernel.kallsyms] [k] kfunc2 548 + 10.00% perf [.] bar 549 + 5.00% libc.so [.] libcall 550 + 551 + In hierarchy output: 552 + 553 + perf report -s dso,sym --hierarchy 554 + # Overhead Shared Object / Symbol 555 + 65.00% [kernel.kallsyms] 556 + 50.00% [k] kfunc1 557 + 15.00% [k] kfunc2 558 + 30.00% perf 559 + 20.00% [.] foo 560 + 10.00% [.] bar 561 + 5.00% libc.so 562 + 5.00% [.] libcall 536 563 537 564 --inline:: 538 565 If a callgraph address belongs to an inlined function, the inline stack
+31 -1
tools/perf/Documentation/perf-top.txt
··· 261 261 --raw-trace:: 262 262 When displaying traceevent output, do not use print fmt or plugins. 263 263 264 + -H:: 264 265 --hierarchy:: 265 - Enable hierarchy output. 266 + Enable hierarchical output. In the hierarchy mode, each sort key groups 267 + samples based on the criteria and then sub-divide it using the lower 268 + level sort key. 269 + 270 + For example, in normal output: 271 + 272 + perf report -s dso,sym 273 + # 274 + # Overhead Shared Object Symbol 275 + # ........ ................. ........... 276 + 50.00% [kernel.kallsyms] [k] kfunc1 277 + 20.00% perf [.] foo 278 + 15.00% [kernel.kallsyms] [k] kfunc2 279 + 10.00% perf [.] bar 280 + 5.00% libc.so [.] libcall 281 + 282 + In hierarchy output: 283 + 284 + perf report -s dso,sym --hierarchy 285 + # 286 + # Overhead Shared Object / Symbol 287 + # .......... ...................... 288 + 65.00% [kernel.kallsyms] 289 + 50.00% [k] kfunc1 290 + 15.00% [k] kfunc2 291 + 30.00% perf 292 + 20.00% [.] foo 293 + 10.00% [.] bar 294 + 5.00% libc.so 295 + 5.00% [.] libcall 266 296 267 297 --overwrite:: 268 298 Enable this to use just the most recent records, which helps in high core count
+1 -1
tools/perf/builtin-report.c
··· 1410 1410 "only show processor socket that match with this filter"), 1411 1411 OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace, 1412 1412 "Show raw trace event output (do not use print fmt or plugins)"), 1413 - OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, 1413 + OPT_BOOLEAN('H', "hierarchy", &symbol_conf.report_hierarchy, 1414 1414 "Show entries in a hierarchy"), 1415 1415 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", 1416 1416 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
+1 -1
tools/perf/builtin-top.c
··· 1573 1573 "add last branch records to call history"), 1574 1574 OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace, 1575 1575 "Show raw trace event output (do not use print fmt or plugins)"), 1576 - OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, 1576 + OPT_BOOLEAN('H', "hierarchy", &symbol_conf.report_hierarchy, 1577 1577 "Show entries in a hierarchy"), 1578 1578 OPT_BOOLEAN(0, "overwrite", &top.record_opts.overwrite, 1579 1579 "Use a backward ring buffer, default: no"),