perf lock info: Display both map and thread by default
authorNick Forrington <nick.forrington@arm.com>
Mon, 13 May 2024 09:14:12 +0000 (09:14 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 4 Jun 2024 05:01:00 +0000 (22:01 -0700)
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
tools/perf/Documentation/perf-lock.txt
tools/perf/builtin-lock.c

index f5938d616d75176cb7f42e5500fee4f03a4ebafc..57a940399de05487635a204ff60a25bd4f8967bb 100644 (file)
@@ -111,11 +111,11 @@ INFO OPTIONS
 
 -t::
 --threads::
-       dump thread list in perf.data
+       dump only the thread list in perf.data
 
 -m::
 --map::
-       dump map of lock instances (address:name table)
+       dump only the map of lock instances (address:name table)
 
 
 CONTENTION OPTIONS
index 7007d26fe654846b7ad2bec6fecf0a1a2371cdda..0253184b3b588744287bd684bca85536f6fea2a4 100644 (file)
@@ -1477,20 +1477,16 @@ static void dump_map(void)
                fprintf(lock_output, " %#llx: %s\n", (unsigned long long)st->addr, st->name);
 }
 
-static int dump_info(void)
+static void dump_info(void)
 {
-       int rc = 0;
-
        if (info_threads)
                dump_threads();
-       else if (info_map)
+
+       if (info_map) {
+               if (info_threads)
+                       fputc('\n', lock_output);
                dump_map();
-       else {
-               rc = -1;
-               pr_err("Unknown type of information\n");
        }
-
-       return rc;
 }
 
 static const struct evsel_str_handler lock_tracepoints[] = {
@@ -1992,7 +1988,7 @@ static int __cmd_report(bool display_info)
 
        setup_pager();
        if (display_info) /* used for info subcommand */
-               err = dump_info();
+               dump_info();
        else {
                combine_result();
                sort_result();
@@ -2568,9 +2564,9 @@ int cmd_lock(int argc, const char **argv)
 
        const struct option info_options[] = {
        OPT_BOOLEAN('t', "threads", &info_threads,
-                   "dump thread list in perf.data"),
+                   "dump the thread list in perf.data"),
        OPT_BOOLEAN('m', "map", &info_map,
-                   "map of lock instances (address:name table)"),
+                   "dump the map of lock instances (address:name table)"),
        OPT_PARENT(lock_options)
        };
 
@@ -2684,6 +2680,13 @@ int cmd_lock(int argc, const char **argv)
                        if (argc)
                                usage_with_options(info_usage, info_options);
                }
+
+               /* If neither threads nor map requested, display both */
+               if (!info_threads && !info_map) {
+                       info_threads = true;
+                       info_map = true;
+               }
+
                /* recycling report_lock_ops */
                trace_handler = &report_lock_ops;
                rc = __cmd_report(true);