[PATCH 08/23] perf evlist: Add -q/--quiet option
From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:20:12 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.
Before:
$ perf evlist -i perf.data.kmem
kmem:kmalloc
kmem:kmalloc_node
kmem:kfree
kmem:kmem_cache_alloc
kmem:kmem_cache_alloc_node
kmem:kmem_cache_free
kmem:mm_page_alloc
kmem:mm_page_free
# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
After:
$ perf evlist -i perf.data.kmem -q
kmem:kmalloc
kmem:kmalloc_node
kmem:kfree
kmem:kmem_cache_alloc
kmem:kmem_cache_alloc_node
kmem:kmem_cache_free
kmem:mm_page_alloc
kmem:mm_page_free
Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-evlist.txt | 4 ++++
tools/perf/builtin-evlist.c | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-evlist.txt b/tools/perf/Documentation/perf-evlist.txt
index 6f7200fb85cf..033aac0d4d79 100644
--- a/tools/perf/Documentation/perf-evlist.txt
+++ b/tools/perf/Documentation/perf-evlist.txt
@@ -28,6 +28,10 @@ OPTIONS
--verbose=::
Show all fields.
+-q::
+--quiet::
+ Do not show any message.
+
-g::
--group::
Show event group information.
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index e09c4287fe87..37c2cf7d395f 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -39,7 +39,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
has_tracepoint = true;
}
- if (has_tracepoint && !details->trace_fields)
+ if (has_tracepoint && !details->trace_fields && !quiet)
printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
perf_session__delete(session);
@@ -54,6 +54,7 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('F', "freq", &details.freq, "Show the sample frequency"),
OPT_BOOLEAN('v', "verbose", &details.verbose,
"Show all event attr details"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('g', "group", &details.event_group,
"Show event group information"),
OPT_BOOLEAN('f', "force", &details.force, "don't complain, do it"),
@@ -69,6 +70,11 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc)
usage_with_options(evlist_usage, options);
+ if (quiet) {
+ perf_quiet_option();
+ details.verbose = false;
+ }
+
if (details.event_group && (details.verbose || details.freq)) {
usage_with_options_msg(evlist_usage, options,
"--group option is not compatible with other options\n");
--
2.11.0