[PATCH 22/23] perf top: Add -q/--quiet option
From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:21:37 EST
The -q/--quiet option is to suppress any message. Sometimes users just
want to run the command and it can be used for that case.
Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-top.txt | 4 ++++
tools/perf/builtin-top.c | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index e71d63843f45..eda5b58b1cd4 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -109,6 +109,10 @@ Default is to monitor all CPUS.
--verbose::
Be more verbose (show counter open errors, etc).
+-q::
+--quiet::
+ Do not show any message. (Suppress -v)
+
-z::
--zero::
Zero history across display updates.
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index ab9077915763..18b68c8495d6 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -372,7 +372,7 @@ static void perf_top__prompt_symbol(struct perf_top *top, const char *msg)
}
if (!found) {
- fprintf(stderr, "Sorry, %s is not active.\n", buf);
+ pr_err("Sorry, %s is not active.\n", buf);
sleep(1);
} else
perf_top__parse_source(top, found);
@@ -1142,6 +1142,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "stdio", &top.use_stdio, "Use the stdio interface"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
" Please refer the man page for the complete list."),
@@ -1224,6 +1225,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc)
usage_with_options(top_usage, options);
+ if (quiet)
+ perf_quiet_option();
+
if (!top.evlist->nr_entries &&
perf_evlist__add_default(top.evlist) < 0) {
pr_err("Not enough memory for event selector list\n");
--
2.11.0