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

perf lock info: Display both map and thread by default

Change "perf lock info" argument handling to:

Display both map and thread info (rather than an error) when neither are
specified.

Display both map and thread info (rather than just thread info) when
both are requested.

Signed-off-by: Nick Forrington <nick.forrington@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240513091413.738537-2-nick.forrington@arm.com

authored by

Nick Forrington and committed by
Namhyung Kim
f7d4485f af752016

+18 -15
+2 -2
tools/perf/Documentation/perf-lock.txt
··· 111 111 112 112 -t:: 113 113 --threads:: 114 - dump thread list in perf.data 114 + dump only the thread list in perf.data 115 115 116 116 -m:: 117 117 --map:: 118 - dump map of lock instances (address:name table) 118 + dump only the map of lock instances (address:name table) 119 119 120 120 121 121 CONTENTION OPTIONS
+16 -13
tools/perf/builtin-lock.c
··· 1477 1477 fprintf(lock_output, " %#llx: %s\n", (unsigned long long)st->addr, st->name); 1478 1478 } 1479 1479 1480 - static int dump_info(void) 1480 + static void dump_info(void) 1481 1481 { 1482 - int rc = 0; 1483 - 1484 1482 if (info_threads) 1485 1483 dump_threads(); 1486 - else if (info_map) 1487 - dump_map(); 1488 - else { 1489 - rc = -1; 1490 - pr_err("Unknown type of information\n"); 1491 - } 1492 1484 1493 - return rc; 1485 + if (info_map) { 1486 + if (info_threads) 1487 + fputc('\n', lock_output); 1488 + dump_map(); 1489 + } 1494 1490 } 1495 1491 1496 1492 static const struct evsel_str_handler lock_tracepoints[] = { ··· 1988 1992 1989 1993 setup_pager(); 1990 1994 if (display_info) /* used for info subcommand */ 1991 - err = dump_info(); 1995 + dump_info(); 1992 1996 else { 1993 1997 combine_result(); 1994 1998 sort_result(); ··· 2564 2568 2565 2569 const struct option info_options[] = { 2566 2570 OPT_BOOLEAN('t', "threads", &info_threads, 2567 - "dump thread list in perf.data"), 2571 + "dump the thread list in perf.data"), 2568 2572 OPT_BOOLEAN('m', "map", &info_map, 2569 - "map of lock instances (address:name table)"), 2573 + "dump the map of lock instances (address:name table)"), 2570 2574 OPT_PARENT(lock_options) 2571 2575 }; 2572 2576 ··· 2680 2684 if (argc) 2681 2685 usage_with_options(info_usage, info_options); 2682 2686 } 2687 + 2688 + /* If neither threads nor map requested, display both */ 2689 + if (!info_threads && !info_map) { 2690 + info_threads = true; 2691 + info_map = true; 2692 + } 2693 + 2683 2694 /* recycling report_lock_ops */ 2684 2695 trace_handler = &report_lock_ops; 2685 2696 rc = __cmd_report(true);