[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231031120526.11502-3-nick.forrington@arm.com>
Date: Tue, 31 Oct 2023 12:05:25 +0000
From: Nick Forrington <nick.forrington@....com>
To: linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org
Cc: Nick Forrington <nick.forrington@....com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 2/2] perf lock info: Enforce exactly one of --map and --thread
Improve error reporting for command line arguments.
Display error/usage if neither --map or --thread are specified (rather
than a non user-friendly error "Unknown type of information").
Display error/usage if both --map and --thread are specified (rather
than ignoring "--map" and displaying only thread information).
Signed-off-by: Nick Forrington <nick.forrington@....com>
---
tools/perf/builtin-lock.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 3aa8ba5ad928..cf29f648d291 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -2021,6 +2021,27 @@ static int check_lock_report_options(const struct option *options,
return 0;
}
+static int check_lock_info_options(const struct option *options,
+ const char * const *usage)
+{
+ if (!info_map && !info_threads) {
+ pr_err("Requires one of --map or --threads\n");
+ parse_options_usage(usage, options, "map", 0);
+ parse_options_usage(NULL, options, "threads", 0);
+ return -1;
+
+ }
+
+ if (info_map && info_threads) {
+ pr_err("Cannot show map and threads together\n");
+ parse_options_usage(usage, options, "map", 0);
+ parse_options_usage(NULL, options, "threads", 0);
+ return -1;
+ }
+
+ return 0;
+}
+
static int check_lock_contention_options(const struct option *options,
const char * const *usage)
@@ -2709,6 +2730,10 @@ int cmd_lock(int argc, const char **argv)
if (argc)
usage_with_options(info_usage, info_options);
}
+
+ if (check_lock_info_options(info_options, info_usage) < 0)
+ return -1;
+
/* recycling report_lock_ops */
trace_handler = &report_lock_ops;
rc = __cmd_report(true);
--
2.42.0
Powered by blists - more mailing lists