Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1594339

[PATCH 08/23] perf evlist: Add -q/--quiet option

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 08/23] perf evlist: Add -q/--quiet option
Date 2017-03-07 16:30 +0100
Message-ID <tipdL-11m-5@gated-at.bofh.it> (permalink)
References <tip46-X4-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 08/23] perf evlist: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-03-07 16:30 +0100

csiph-web