All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1)
@ 2017-02-17  8:17 Namhyung Kim
  2017-02-17  8:17 ` [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

Hello,

The -q/--quiet option is to suppress headers or messages (in stdio) so
that it can be copied to other place if users just want to see the
numbers.  This was suggested by Arnaldo.

Note that this patchset only implements it in a couple of commands.
If it seems ok, it can be applied to others later.

The code also is available at 'perf/quiet-v1' branch in my tree

  git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung


Namhyung Kim (6):
  perf utils: Add perf_quiet_option()
  perf utils: Check verbose flag properly
  perf report: Add -q/--quiet option
  perf diff: Add -q/--quiet option
  perf annotate: Add -q/--quiet option
  perf record: Honor quiet option properly

 tools/perf/Documentation/perf-annotate.txt |  4 ++++
 tools/perf/Documentation/perf-diff.txt     |  4 ++++
 tools/perf/Documentation/perf-report.txt   |  4 ++++
 tools/perf/builtin-annotate.c              |  4 ++++
 tools/perf/builtin-diff.c                  | 14 ++++++++++----
 tools/perf/builtin-record.c                |  3 +++
 tools/perf/builtin-report.c                | 21 ++++++++++++++++-----
 tools/perf/util/annotate.c                 |  2 +-
 tools/perf/util/debug.c                    | 17 +++++++++++++++++
 tools/perf/util/debug.h                    |  1 +
 tools/perf/util/dso.c                      |  2 +-
 tools/perf/util/hist.c                     |  6 +++---
 tools/perf/util/pmu.c                      |  8 ++++----
 tools/perf/util/sort.c                     |  8 ++++----
 tools/perf/util/symbol-elf.c               |  2 +-
 15 files changed, 77 insertions(+), 23 deletions(-)

-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/6] perf utils: Add perf_quiet_option()
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-21  8:15   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2017-02-17  8:17 ` [PATCH 2/6] perf utils: Check verbose flag properly Namhyung Kim
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

The perf_quiet_option() is to suppress all messages.  It's intended to
be called just after parsing options.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/debug.c | 17 +++++++++++++++++
 tools/perf/util/debug.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c1838b643108..03eb81f30d0d 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -203,11 +203,28 @@ int perf_debug_option(const char *str)
 		v = (v < 0) || (v > 10) ? 0 : v;
 	}
 
+	if (quiet)
+		v = -1;
+
 	*var->ptr = v;
 	free(s);
 	return 0;
 }
 
+int perf_quiet_option(void)
+{
+	struct debug_variable *var = &debug_variables[0];
+
+	/* disable all debug messages */
+	while (var->name) {
+		*var->ptr = -1;
+		var++;
+	}
+
+	quiet = true;
+	return 0;
+}
+
 #define DEBUG_WRAPPER(__n, __l)				\
 static int pr_ ## __n ## _wrapper(const char *fmt, ...)	\
 {							\
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index d242adc3d5a2..98832f5531d3 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -54,5 +54,6 @@ int veprintf(int level, int var, const char *fmt, va_list args);
 
 int perf_debug_option(const char *str);
 void perf_debug_setup(void);
+int perf_quiet_option(void);
 
 #endif	/* __PERF_DEBUG_H */
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 2/6] perf utils: Check verbose flag properly
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
  2017-02-17  8:17 ` [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-20 14:35   ` Arnaldo Carvalho de Melo
  2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

It now can have negative value to suppress the message entirely.  So it
needs to check it being positive.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/dso.c        | 2 +-
 tools/perf/util/hist.c       | 6 +++---
 tools/perf/util/pmu.c        | 8 ++++----
 tools/perf/util/sort.c       | 8 ++++----
 tools/perf/util/symbol-elf.c | 2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 28d41e709128..1a03e9e310a4 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1058,7 +1058,7 @@ int dso__name_len(const struct dso *dso)
 {
 	if (!dso)
 		return strlen("[unknown]");
-	if (verbose)
+	if (verbose > 0)
 		return dso->long_name_len;
 
 	return dso->short_name_len;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 32c6a939e4cc..eaf72a938fb4 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -69,7 +69,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	 */
 	if (h->ms.sym) {
 		symlen = h->ms.sym->namelen + 4;
-		if (verbose)
+		if (verbose > 0)
 			symlen += BITS_PER_LONG / 4 + 2 + 3;
 		hists__new_col_len(hists, HISTC_SYMBOL, symlen);
 	} else {
@@ -93,7 +93,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	if (h->branch_info) {
 		if (h->branch_info->from.sym) {
 			symlen = (int)h->branch_info->from.sym->namelen + 4;
-			if (verbose)
+			if (verbose > 0)
 				symlen += BITS_PER_LONG / 4 + 2 + 3;
 			hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
 
@@ -107,7 +107,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 
 		if (h->branch_info->to.sym) {
 			symlen = (int)h->branch_info->to.sym->namelen + 4;
-			if (verbose)
+			if (verbose > 0)
 				symlen += BITS_PER_LONG / 4 + 2 + 3;
 			hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
 
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 49bfee0e3d9e..7ba31ff44b75 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -745,7 +745,7 @@ static int pmu_resolve_param_term(struct parse_events_term *term,
 		}
 	}
 
-	if (verbose)
+	if (verbose > 0)
 		printf("Required parameter '%s' not specified\n", term->config);
 
 	return -1;
@@ -803,7 +803,7 @@ static int pmu_config_term(struct list_head *formats,
 
 	format = pmu_find_format(formats, term->config);
 	if (!format) {
-		if (verbose)
+		if (verbose > 0)
 			printf("Invalid event/parameter '%s'\n", term->config);
 		if (err) {
 			char *pmu_term = pmu_formats_string(formats);
@@ -838,7 +838,7 @@ static int pmu_config_term(struct list_head *formats,
 		val = term->val.num;
 	else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) {
 		if (strcmp(term->val.str, "?")) {
-			if (verbose) {
+			if (verbose > 0) {
 				pr_info("Invalid sysfs entry %s=%s\n",
 						term->config, term->val.str);
 			}
@@ -1223,7 +1223,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 			printf("%*s", 8, "[");
 			wordwrap(aliases[j].desc, 8, columns, 0);
 			printf("]\n");
-			if (verbose)
+			if (verbose > 0)
 				printf("%*s%s/%s/\n", 8, "", aliases[j].pmu, aliases[j].str);
 		} else
 			printf("  %-50s [Kernel PMU event]\n", aliases[j].name);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index df622f4e301e..0ff622288d24 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -151,7 +151,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r)
 	if (!dso_l || !dso_r)
 		return cmp_null(dso_r, dso_l);
 
-	if (verbose) {
+	if (verbose > 0) {
 		dso_name_l = dso_l->long_name;
 		dso_name_r = dso_r->long_name;
 	} else {
@@ -172,8 +172,8 @@ static int _hist_entry__dso_snprintf(struct map *map, char *bf,
 				     size_t size, unsigned int width)
 {
 	if (map && map->dso) {
-		const char *dso_name = !verbose ? map->dso->short_name :
-			map->dso->long_name;
+		const char *dso_name = verbose > 0 ? map->dso->long_name :
+			map->dso->short_name;
 		return repsep_snprintf(bf, size, "%-*.*s", width, width, dso_name);
 	}
 
@@ -261,7 +261,7 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
 {
 	size_t ret = 0;
 
-	if (verbose) {
+	if (verbose > 0) {
 		char o = map ? dso__symtab_origin(map->dso) : '!';
 		ret += repsep_snprintf(bf, size, "%-#*llx %c ",
 				       BITS_PER_LONG / 4 + 2, ip, o);
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index adbc6c02c3aa..4e59ddeb4eda 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -213,7 +213,7 @@ static bool want_demangle(bool is_kernel_sym)
 
 static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
 {
-	int demangle_flags = verbose ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
+	int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
 	char *demangled = NULL;
 
 	/*
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 3/6] perf report: Add -q/--quiet option
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
  2017-02-17  8:17 ` [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim
  2017-02-17  8:17 ` [PATCH 2/6] perf utils: Check verbose flag properly Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-17 11:09   ` Jiri Olsa
                     ` (2 more replies)
  2017-02-17  8:17 ` [PATCH 4/6] perf diff: " Namhyung Kim
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-report.txt |  4 ++++
 tools/perf/builtin-report.c              | 21 ++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index f2914f03ae7b..c04cc0647c16 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -25,6 +25,10 @@ OPTIONS
 --verbose::
         Be more verbose. (show symbol address, etc)
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -n::
 --show-nr-samples::
 	Show the number of samples for each symbol
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dbd7fa028861..0a88670e56f3 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -320,6 +320,9 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
 	size_t size = sizeof(buf);
 	int socked_id = hists->socket_filter;
 
+	if (quiet)
+		return 0;
+
 	if (symbol_conf.filter_relative) {
 		nr_samples = hists->stats.nr_non_filtered_samples;
 		nr_events = hists->stats.total_non_filtered_period;
@@ -372,7 +375,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 {
 	struct perf_evsel *pos;
 
-	fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples);
+	if (!quiet) {
+		fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
+			evlist->stats.total_lost_samples);
+	}
+
 	evlist__for_each_entry(evlist, pos) {
 		struct hists *hists = evsel__hists(pos);
 		const char *evname = perf_evsel__name(pos);
@@ -382,7 +389,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 			continue;
 
 		hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
-		hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout,
+		hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
 			       symbol_conf.use_callchain);
 		fprintf(stdout, "\n\n");
 	}
@@ -716,6 +723,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "input file name"),
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -863,6 +871,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		report.symbol_filter_str = argv[0];
 	}
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol_conf.vmlinux_name &&
 	    access(symbol_conf.vmlinux_name, R_OK)) {
 		pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
@@ -983,14 +994,14 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		goto error;
 	}
 
-	if (report.header || report.header_only) {
+	if ((report.header || report.header_only) && !quiet) {
 		perf_session__fprintf_info(session, stdout,
 					   report.show_full_info);
 		if (report.header_only) {
 			ret = 0;
 			goto error;
 		}
-	} else if (use_browser == 0) {
+	} else if (use_browser == 0 && !quiet) {
 		fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
 		      stdout);
 	}
@@ -1009,7 +1020,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
  		 * providing it only in verbose mode not to bloat too
  		 * much struct symbol.
  		 */
-		if (verbose) {
+		if (verbose > 0) {
 			/*
 			 * XXX: Need to provide a less kludgy way to ask for
 			 * more space per symbol, the u32 is for the index on
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/6] perf diff: Add -q/--quiet option
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
                   ` (2 preceding siblings ...)
  2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-21  8:17   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2017-02-17  8:17 ` [PATCH 5/6] perf annotate: " Namhyung Kim
  2017-02-17  8:17 ` [PATCH 6/6] perf record: Honor quiet option properly Namhyung Kim
  5 siblings, 1 reply; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-diff.txt |  4 ++++
 tools/perf/builtin-diff.c              | 14 ++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index 66dbe3dee74b..a79c84ae61aa 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -73,6 +73,10 @@ OPTIONS
 	Be verbose, for instance, show the raw counts in addition to the
 	diff.
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -f::
 --force::
         Don't do ownership validation.
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 70a289347591..1b96a3122228 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -691,7 +691,7 @@ static void hists__process(struct hists *hists)
 	hists__precompute(hists);
 	hists__output_resort(hists, NULL);
 
-	hists__fprintf(hists, true, 0, 0, 0, stdout,
+	hists__fprintf(hists, !quiet, 0, 0, 0, stdout,
 		       symbol_conf.use_callchain);
 }
 
@@ -739,12 +739,14 @@ static void data_process(void)
 				hists__link(hists_base, hists);
 		}
 
-		fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
-			perf_evsel__name(evsel_base));
+		if (!quiet) {
+			fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
+				perf_evsel__name(evsel_base));
+		}
 
 		first = false;
 
-		if (verbose || data__files_cnt > 2)
+		if (verbose > 0 || ((data__files_cnt > 2) && !quiet))
 			data__fprintf();
 
 		/* Don't sort callchain for perf diff */
@@ -807,6 +809,7 @@ static const char * const diff_usage[] = {
 static const struct option options[] = {
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
 		    "Show only items with match in baseline"),
 	OPT_CALLBACK('c', "compute", &compute,
@@ -1328,6 +1331,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	argc = parse_options(argc, argv, options, diff_usage, 0);
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol__init(NULL) < 0)
 		return -1;
 
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 5/6] perf annotate: Add -q/--quiet option
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
                   ` (3 preceding siblings ...)
  2017-02-17  8:17 ` [PATCH 4/6] perf diff: " Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-21  8:17   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2017-02-17  8:17 ` [PATCH 6/6] perf record: Honor quiet option properly Namhyung Kim
  5 siblings, 1 reply; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-annotate.txt | 4 ++++
 tools/perf/builtin-annotate.c              | 4 ++++
 tools/perf/util/annotate.c                 | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 8ffbd272952d..a89273d8e744 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -39,6 +39,10 @@ OPTIONS
 --verbose::
         Be more verbose. (Show symbol address, etc)
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -D::
 --dump-raw-trace::
         Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ebb628332a6e..4f52d85f5ebc 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -410,6 +410,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
@@ -463,6 +464,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		annotate.sym_hist_filter = argv[0];
 	}
 
+	if (quiet)
+		perf_quiet_option();
+
 	file.path  = input_name;
 
 	annotate.session = perf_session__new(&file, false, &annotate.tool);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 06cc04e5806a..273f21fa32b5 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1768,7 +1768,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
-	if (verbose)
+	if (verbose > 0)
 		symbol__annotate_hits(sym, evsel);
 
 	list_for_each_entry(pos, &notes->src->source, node) {
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 6/6] perf record: Honor quiet option properly
  2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
                   ` (4 preceding siblings ...)
  2017-02-17  8:17 ` [PATCH 5/6] perf annotate: " Namhyung Kim
@ 2017-02-17  8:17 ` Namhyung Kim
  2017-02-21  8:18   ` [tip:perf/urgent] perf record: Honor --quiet " tip-bot for Namhyung Kim
  5 siblings, 1 reply; 19+ messages in thread
From: Namhyung Kim @ 2017-02-17  8:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

It should call perf_quiet_option() to suppress messages.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-record.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6cd6776052e7..47ca5ff02c35 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1677,6 +1677,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	argc = parse_options(argc, argv, record_options, record_usage,
 			    PARSE_OPT_STOP_AT_NON_OPTION);
+	if (quiet)
+		perf_quiet_option();
+
 	if (!argc && target__none(&rec->opts.target))
 		usage_with_options(record_usage, record_options);
 
-- 
2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/6] perf report: Add -q/--quiet option
  2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
@ 2017-02-17 11:09   ` Jiri Olsa
  2017-02-19  0:21     ` Namhyung Kim
  2017-02-20 19:08   ` Arnaldo Carvalho de Melo
  2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2 siblings, 1 reply; 19+ messages in thread
From: Jiri Olsa @ 2017-02-17 11:09 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, kernel-team

On Fri, Feb 17, 2017 at 05:17:39PM +0900, Namhyung Kim wrote:
> The -q/--quiet option is to suppress any message.  Sometimes users just
> want to see the numbers and it can be used for that case.

could you put in some example of the new output?

thanks,
jirka

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/6] perf report: Add -q/--quiet option
  2017-02-17 11:09   ` Jiri Olsa
@ 2017-02-19  0:21     ` Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-19  0:21 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, kernel-team

Hi Jiri,

On Fri, Feb 17, 2017 at 12:09:35PM +0100, Jiri Olsa wrote:
> On Fri, Feb 17, 2017 at 05:17:39PM +0900, Namhyung Kim wrote:
> > The -q/--quiet option is to suppress any message.  Sometimes users just
> > want to see the numbers and it can be used for that case.
> 
> could you put in some example of the new output?

Sure.


>From bb28410a27be6d6fb15ec4498094301693115f1d Mon Sep 17 00:00:00 2001
From: Namhyung Kim <namhyung@kernel.org>
Date: Fri, 17 Feb 2017 16:38:28 +0900
Subject: [PATCH] perf report: Add -q/--quiet option

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Before:

  $ perf report | head -15
  Failed to open /lib/modules/3.19.3-3-ARCH/kernel/fs/ext4/ext4.ko.gz, continuing without symbols
  Failed to open /lib/modules/3.19.3-3-ARCH/kernel/fs/jbd2/jbd2.ko.gz, continuing without symbols
  Failed to open /tmp/perf-14507.map, continuing without symbols
  ...
  # To display the perf.data header info, please use --header/--header-only options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 39K of event 'cycles'
  # Event count (approx.): 30444796573
  #
  # Overhead  Command      Shared Object        Symbol
  # ........  ...........  ...................  .........................
  #
       9.28%  swapper      [kernel.vmlinux]     [k] intel_idle
       5.64%  swapper      [kernel.vmlinux]     [k] native_write_msr_safe
       1.93%  swapper      [kernel.vmlinux]     [k] __switch_to
       1.89%  swapper      [kernel.vmlinux]     [k] menu_select
       1.75%  sched-pipe   [kernel.vmlinux]     [k] __switch_to

After:

  $ perf report -q | head
       9.28%  swapper      [kernel.vmlinux]     [k] intel_idle
       5.64%  swapper      [kernel.vmlinux]     [k] native_write_msr_safe
       1.93%  swapper      [kernel.vmlinux]     [k] __switch_to
       1.89%  swapper      [kernel.vmlinux]     [k] menu_select
       1.75%  sched-pipe   [kernel.vmlinux]     [k] __switch_to
       1.67%  swapper      [kernel.vmlinux]     [k] cpu_startup_entry
       1.48%  sched-pipe   [kernel.vmlinux]     [k] enqueue_entity
       1.46%  swapper      [kernel.vmlinux]     [k] __schedule
       1.36%  swapper      [kernel.vmlinux]     [k] native_read_tsc
       1.34%  sched-pipe   [kernel.vmlinux]     [k] __schedule

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-report.txt |  4 ++++
 tools/perf/builtin-report.c              | 21 ++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index f2914f03ae7b..c04cc0647c16 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -25,6 +25,10 @@ OPTIONS
 --verbose::
         Be more verbose. (show symbol address, etc)
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -n::
 --show-nr-samples::
 	Show the number of samples for each symbol
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dbd7fa028861..0a88670e56f3 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -320,6 +320,9 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
 	size_t size = sizeof(buf);
 	int socked_id = hists->socket_filter;
 
+	if (quiet)
+		return 0;
+
 	if (symbol_conf.filter_relative) {
 		nr_samples = hists->stats.nr_non_filtered_samples;
 		nr_events = hists->stats.total_non_filtered_period;
@@ -372,7 +375,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 {
 	struct perf_evsel *pos;
 
-	fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples);
+	if (!quiet) {
+		fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
+			evlist->stats.total_lost_samples);
+	}
+
 	evlist__for_each_entry(evlist, pos) {
 		struct hists *hists = evsel__hists(pos);
 		const char *evname = perf_evsel__name(pos);
@@ -382,7 +389,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 			continue;
 
 		hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
-		hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout,
+		hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
 			       symbol_conf.use_callchain);
 		fprintf(stdout, "\n\n");
 	}
@@ -716,6 +723,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "input file name"),
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -863,6 +871,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		report.symbol_filter_str = argv[0];
 	}
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol_conf.vmlinux_name &&
 	    access(symbol_conf.vmlinux_name, R_OK)) {
 		pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
@@ -983,14 +994,14 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		goto error;
 	}
 
-	if (report.header || report.header_only) {
+	if ((report.header || report.header_only) && !quiet) {
 		perf_session__fprintf_info(session, stdout,
 					   report.show_full_info);
 		if (report.header_only) {
 			ret = 0;
 			goto error;
 		}
-	} else if (use_browser == 0) {
+	} else if (use_browser == 0 && !quiet) {
 		fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
 		      stdout);
 	}
@@ -1009,7 +1020,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
  		 * providing it only in verbose mode not to bloat too
  		 * much struct symbol.
  		 */
-		if (verbose) {
+		if (verbose > 0) {
 			/*
 			 * XXX: Need to provide a less kludgy way to ask for
 			 * more space per symbol, the u32 is for the index on
-- 
2.11.0

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/6] perf utils: Check verbose flag properly
  2017-02-17  8:17 ` [PATCH 2/6] perf utils: Check verbose flag properly Namhyung Kim
@ 2017-02-20 14:35   ` Arnaldo Carvalho de Melo
  2017-02-21  1:38     ` Namhyung Kim
  2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  1 sibling, 1 reply; 19+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-02-20 14:35 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

Em Fri, Feb 17, 2017 at 05:17:38PM +0900, Namhyung Kim escreveu:
> It now can have negative value to suppress the message entirely.  So it
> needs to check it being positive.

find tools/perf -name "*.[chly]" | xargs grep -w verbose 

Shows several other places, I'm trying to plug those, fixed it up in
your patch and left a committer note, please check and see if all is
right.

- Arnaldo

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 70a289347591..7ad0d78ea743 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -744,7 +744,7 @@ static void data_process(void)
 
 		first = false;
 
-		if (verbose || data__files_cnt > 2)
+		if (verbose > 0 || data__files_cnt > 2)
 			data__fprintf();
 
 		/* Don't sort callchain for perf diff */
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index cd7bc4d104e2..6114e07ca613 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -42,8 +42,8 @@ static int parse_record_events(const struct option *opt,
 
 		fprintf(stderr, "%-13s%-*s%s\n",
 			e->tag,
-			verbose ? 25 : 0,
-			verbose ? perf_mem_events__name(j) : "",
+			verbose > 0 ? 25 : 0,
+			verbose > 0 ? perf_mem_events__name(j) : "",
 			e->supported ? ": available" : "");
 	}
 	exit(0);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b87bbef73394..451b11e35c26 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -432,7 +432,7 @@ static int record__open(struct record *rec)
 try_again:
 		if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
 			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s\n", msg);
 				goto try_again;
 			}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dbd7fa028861..a94488114bbf 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1009,7 +1009,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
  		 * providing it only in verbose mode not to bloat too
  		 * much struct symbol.
  		 */
-		if (verbose) {
+		if (verbose > 0) {
 			/*
 			 * XXX: Need to provide a less kludgy way to ask for
 			 * more space per symbol, the u32 is for the index on
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 270eb2d8ca6b..b94cf0de715a 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -460,7 +460,7 @@ static struct task_desc *register_pid(struct perf_sched *sched,
 	BUG_ON(!sched->tasks);
 	sched->tasks[task->nr] = task;
 
-	if (verbose)
+	if (verbose > 0)
 		printf("registered task #%ld, PID %ld (%s)\n", sched->nr_tasks, pid, comm);
 
 	return task;
@@ -794,7 +794,7 @@ replay_wakeup_event(struct perf_sched *sched,
 	const u32 pid	 = perf_evsel__intval(evsel, sample, "pid");
 	struct task_desc *waker, *wakee;
 
-	if (verbose) {
+	if (verbose > 0) {
 		printf("sched_wakeup event %p\n", evsel);
 
 		printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid);
@@ -822,7 +822,7 @@ static int replay_switch_event(struct perf_sched *sched,
 	int cpu = sample->cpu;
 	s64 delta;
 
-	if (verbose)
+	if (verbose > 0)
 		printf("sched_switch event %p\n", evsel);
 
 	if (cpu >= MAX_CPUS || cpu < 0)
@@ -870,7 +870,7 @@ static int replay_fork_event(struct perf_sched *sched,
 		goto out_put;
 	}
 
-	if (verbose) {
+	if (verbose > 0) {
 		printf("fork event\n");
 		printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid);
 		printf("...  child: %s/%d\n", thread__comm_str(child), child->tid);
@@ -1573,7 +1573,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
 
 	timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp));
 	color_fprintf(stdout, color, "  %12s secs ", stimestamp);
-	if (new_shortname || (verbose && sched_in->tid)) {
+	if (new_shortname || (verbose > 0 && sched_in->tid)) {
 		const char *pid_color = color;
 
 		if (thread__has_color(sched_in))
@@ -2050,7 +2050,7 @@ static void save_task_callchain(struct perf_sched *sched,
 
 	if (thread__resolve_callchain(thread, cursor, evsel, sample,
 				      NULL, NULL, sched->max_stack + 2) != 0) {
-		if (verbose)
+		if (verbose > 0)
 			error("Failed to resolve callchain. Skipping\n");
 
 		return;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 9989b03c21f2..13b54999ad79 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -573,7 +573,7 @@ static int __run_perf_stat(int argc, const char **argv)
 			if (errno == EINVAL || errno == ENOSYS ||
 			    errno == ENOENT || errno == EOPNOTSUPP ||
 			    errno == ENXIO) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    perf_evsel__name(counter));
 				counter->supported = false;
@@ -582,7 +582,7 @@ static int __run_perf_stat(int argc, const char **argv)
 				    !(counter->leader->nr_members > 1))
 					continue;
 			} else if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
-                                if (verbose)
+                                if (verbose > 0)
                                         ui__warning("%s\n", msg);
                                 goto try_again;
                         }
@@ -2539,7 +2539,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	status = 0;
 	for (run_idx = 0; forever || run_idx < run_count; run_idx++) {
-		if (run_count != 1 && verbose)
+		if (run_count != 1 && verbose > 0)
 			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
 				run_idx + 1);
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a7fd7af3a6d..ab9077915763 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -871,7 +871,7 @@ static int perf_top__start_counters(struct perf_top *top)
 		if (perf_evsel__open(counter, top->evlist->cpus,
 				     top->evlist->threads) < 0) {
 			if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s\n", msg);
 				goto try_again;
 			}
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 40ef9b293d1b..256f1fac6f7e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1399,7 +1399,7 @@ static struct syscall *trace__syscall_info(struct trace *trace,
 	return &trace->syscalls.table[id];
 
 out_cant_read:
-	if (verbose) {
+	if (verbose > 0) {
 		fprintf(trace->output, "Problems reading syscall %d", id);
 		if (id <= trace->syscalls.max && trace->syscalls.table[id].name != NULL)
 			fprintf(trace->output, "(%s)", trace->syscalls.table[id].name);
@@ -1801,10 +1801,10 @@ static void print_location(FILE *f, struct perf_sample *sample,
 			   bool print_dso, bool print_sym)
 {
 
-	if ((verbose || print_dso) && al->map)
+	if ((verbose > 0 || print_dso) && al->map)
 		fprintf(f, "%s@", al->map->dso->long_name);
 
-	if ((verbose || print_sym) && al->sym)
+	if ((verbose > 0 || print_sym) && al->sym)
 		fprintf(f, "%s+0x%" PRIx64, al->sym->name,
 			al->addr - al->sym->start);
 	else if (al->map)
diff --git a/tools/perf/pmu-events/json.c b/tools/perf/pmu-events/json.c
index f67bbb0aa36e..0544398d6e2d 100644
--- a/tools/perf/pmu-events/json.c
+++ b/tools/perf/pmu-events/json.c
@@ -49,7 +49,7 @@ static char *mapfile(const char *fn, size_t *size)
 	int err;
 	int fd = open(fn, O_RDONLY);
 
-	if (fd < 0 && verbose && fn) {
+	if (fd < 0 && verbose > 0 && fn) {
 		pr_err("Error opening events file '%s': %s\n", fn,
 				strerror(errno));
 	}
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 28d1605b0338..88dc51f4c27b 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -144,7 +144,7 @@ static int run_dir(const char *d, const char *perf)
 	int vcnt = min(verbose, (int) sizeof(v) - 1);
 	char cmd[3*PATH_MAX];
 
-	if (verbose)
+	if (verbose > 0)
 		vcnt++;
 
 	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 37e326bfd2dc..83c4669cbc5b 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -299,7 +299,7 @@ static int run_test(struct test *test, int subtest)
 		if (!dont_fork) {
 			pr_debug("test child forked, pid %d\n", getpid());
 
-			if (!verbose) {
+			if (verbose <= 0) {
 				int nullfd = open("/dev/null", O_WRONLY);
 
 				if (nullfd >= 0) {
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index ff5bc6363a79..d1f693041324 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -599,7 +599,7 @@ static int do_test_code_reading(bool try_kcore)
 				continue;
 			}
 
-			if (verbose) {
+			if (verbose > 0) {
 				char errbuf[512];
 				perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
 				pr_debug("perf_evlist__open() failed!\n%s\n", errbuf);
diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
index a2b5ff9bf83d..bc5982f42dc3 100644
--- a/tools/perf/tests/fdarray.c
+++ b/tools/perf/tests/fdarray.c
@@ -19,7 +19,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
 {
 	int printed = 0;
 
-	if (!verbose)
+	if (verbose <= 0)
 		return 0;
 
 	printed += fprintf(fp, "\n%s: ", prefix);
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index d357dab72e68..482b5365e68d 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -76,7 +76,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
 	 * Skip this test if user's .perfconfig doesn't set [llvm] section
 	 * and clang is not found in $PATH, and this is not perf test -v
 	 */
-	if (!force && (verbose == 0 &&
+	if (!force && (verbose <= 0 &&
 		       !llvm_param.user_set_param &&
 		       llvm__search_clang())) {
 		pr_debug("No clang and no verbosive, skip this test\n");
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index aa9276bfe3e9..1dc838014422 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1808,7 +1808,7 @@ static void debug_warn(const char *warn, va_list params)
 {
 	char msg[1024];
 
-	if (!verbose)
+	if (verbose <= 0)
 		return;
 
 	vsnprintf(msg, sizeof(msg), warn, params);
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 541da7a68f91..87893f3ba5f1 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -172,13 +172,13 @@ int test__PERF_RECORD(int subtest __maybe_unused)
 
 				err = perf_evlist__parse_sample(evlist, event, &sample);
 				if (err < 0) {
-					if (verbose)
+					if (verbose > 0)
 						perf_event__fprintf(event, stderr);
 					pr_debug("Couldn't parse sample\n");
 					goto out_delete_evlist;
 				}
 
-				if (verbose) {
+				if (verbose > 0) {
 					pr_info("%" PRIu64" %d ", sample.time, sample.cpu);
 					perf_event__fprintf(event, stderr);
 				}
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index 7a52834ee0d0..fa79509da535 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -15,7 +15,7 @@ int test__python_use(int subtest __maybe_unused)
 	int ret;
 
 	if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
-		     PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
+		     PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
 		return -1;
 
 	ret = system(cmd) ? -1 : 0;
diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index a4a4b4625ac3..f2d2e542d0ee 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -109,7 +109,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 	TEST_ASSERT_VAL("failed to allocate thread_map",
 			threads);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to remove thread",
@@ -117,7 +117,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 
 	TEST_ASSERT_VAL("thread_map count != 1", threads->nr == 1);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to remove thread",
@@ -125,7 +125,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 
 	TEST_ASSERT_VAL("thread_map count != 0", threads->nr == 0);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to not remove thread",
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index a5082331f246..862b043e5924 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -168,7 +168,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
 		err = -1;
 	}
 
-	if (!verbose)
+	if (verbose <= 0)
 		goto out;
 
 	header_printed = false;
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
index 98a34664bb7e..9ce142de536d 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -73,7 +73,7 @@ static int map_browser__run(struct map_browser *browser)
 
 	if (ui_browser__show(&browser->b, browser->map->dso->long_name,
 			     "Press ESC to exit, %s / to search",
-			     verbose ? "" : "restart with -v to use") < 0)
+			     verbose > 0 ? "" : "restart with -v to use") < 0)
 		return -1;
 
 	while (1) {
@@ -81,7 +81,7 @@ static int map_browser__run(struct map_browser *browser)
 
 		switch (key) {
 		case '/':
-			if (verbose)
+			if (verbose > 0)
 				map_browser__search(browser);
 		default:
 			break;
@@ -117,7 +117,7 @@ int map__browse(struct map *map)
 
 		if (maxaddr < pos->end)
 			maxaddr = pos->end;
-		if (verbose) {
+		if (verbose > 0) {
 			u32 *idx = symbol__browser_index(pos);
 			*idx = mb.b.nr_entries;
 		}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 18cfcdc90356..5d632dca672a 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -648,7 +648,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
 		ret += fmt->width(fmt, &dummy_hpp, hists);
 	}
 
-	if (verbose && hists__has(hists, sym)) /* Addr + origin */
+	if (verbose > 0 && hists__has(hists, sym)) /* Addr + origin */
 		ret += 3 + BITS_PER_LONG / 4;
 
 	return ret;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 06cc04e5806a..273f21fa32b5 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1768,7 +1768,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
-	if (verbose)
+	if (verbose > 0)
 		symbol__annotate_hits(sym, evsel);
 
 	list_for_each_entry(pos, &notes->src->source, node) {
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 35f5b7b7715c..28fb62c32678 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -594,7 +594,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
 	pr_debug("try to find information at %" PRIx64 " in %s\n", addr,
 		 tp->module ? : "kernel");
 
-	dinfo = debuginfo_cache__open(tp->module, verbose == 0);
+	dinfo = debuginfo_cache__open(tp->module, verbose <= 0);
 	if (dinfo)
 		ret = debuginfo__find_probe_point(dinfo,
 						 (unsigned long)addr, pp);
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 39345c2ddfc2..0d51334a9b46 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -344,7 +344,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
 	for (i = 0; i < 3; i++)
 		update_stats(&ps->res_stats[i], count[i]);
 
-	if (verbose) {
+	if (verbose > 0) {
 		fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
 			perf_evsel__name(counter), count[0], count[1], count[2]);
 	}

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/6] perf report: Add -q/--quiet option
  2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
  2017-02-17 11:09   ` Jiri Olsa
@ 2017-02-20 19:08   ` Arnaldo Carvalho de Melo
  2017-02-21  1:40     ` Namhyung Kim
  2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  2 siblings, 1 reply; 19+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-02-20 19:08 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

Em Fri, Feb 17, 2017 at 05:17:39PM +0900, Namhyung Kim escreveu:
> The -q/--quiet option is to suppress any message.  Sometimes users just
> want to see the numbers and it can be used for that case.



#
# (Tip: Customize output of perf script with: perf script -F event,ip,sym)
#
(END)


This still appears, at the end :-\

- Arnaldo
 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/Documentation/perf-report.txt |  4 ++++
>  tools/perf/builtin-report.c              | 21 ++++++++++++++++-----
>  2 files changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index f2914f03ae7b..c04cc0647c16 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -25,6 +25,10 @@ OPTIONS
>  --verbose::
>          Be more verbose. (show symbol address, etc)
>  
> +-q::
> +--quiet::
> +	Do not show any message.  (Suppress -v)
> +
>  -n::
>  --show-nr-samples::
>  	Show the number of samples for each symbol
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index dbd7fa028861..0a88670e56f3 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -320,6 +320,9 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
>  	size_t size = sizeof(buf);
>  	int socked_id = hists->socket_filter;
>  
> +	if (quiet)
> +		return 0;
> +
>  	if (symbol_conf.filter_relative) {
>  		nr_samples = hists->stats.nr_non_filtered_samples;
>  		nr_events = hists->stats.total_non_filtered_period;
> @@ -372,7 +375,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
>  {
>  	struct perf_evsel *pos;
>  
> -	fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples);
> +	if (!quiet) {
> +		fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
> +			evlist->stats.total_lost_samples);
> +	}
> +
>  	evlist__for_each_entry(evlist, pos) {
>  		struct hists *hists = evsel__hists(pos);
>  		const char *evname = perf_evsel__name(pos);
> @@ -382,7 +389,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
>  			continue;
>  
>  		hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
> -		hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout,
> +		hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
>  			       symbol_conf.use_callchain);
>  		fprintf(stdout, "\n\n");
>  	}
> @@ -716,6 +723,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
>  		    "input file name"),
>  	OPT_INCR('v', "verbose", &verbose,
>  		    "be more verbose (show symbol address, etc)"),
> +	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
>  	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
>  		    "dump raw trace in ASCII"),
>  	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
> @@ -863,6 +871,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
>  		report.symbol_filter_str = argv[0];
>  	}
>  
> +	if (quiet)
> +		perf_quiet_option();
> +
>  	if (symbol_conf.vmlinux_name &&
>  	    access(symbol_conf.vmlinux_name, R_OK)) {
>  		pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
> @@ -983,14 +994,14 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
>  		goto error;
>  	}
>  
> -	if (report.header || report.header_only) {
> +	if ((report.header || report.header_only) && !quiet) {
>  		perf_session__fprintf_info(session, stdout,
>  					   report.show_full_info);
>  		if (report.header_only) {
>  			ret = 0;
>  			goto error;
>  		}
> -	} else if (use_browser == 0) {
> +	} else if (use_browser == 0 && !quiet) {
>  		fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
>  		      stdout);
>  	}
> @@ -1009,7 +1020,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
>   		 * providing it only in verbose mode not to bloat too
>   		 * much struct symbol.
>   		 */
> -		if (verbose) {
> +		if (verbose > 0) {
>  			/*
>  			 * XXX: Need to provide a less kludgy way to ask for
>  			 * more space per symbol, the u32 is for the index on
> -- 
> 2.11.1

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/6] perf utils: Check verbose flag properly
  2017-02-20 14:35   ` Arnaldo Carvalho de Melo
@ 2017-02-21  1:38     ` Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-21  1:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

Hi Arnaldo,

On Mon, Feb 20, 2017 at 11:35:44AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Feb 17, 2017 at 05:17:38PM +0900, Namhyung Kim escreveu:
> > It now can have negative value to suppress the message entirely.  So it
> > needs to check it being positive.
> 
> find tools/perf -name "*.[chly]" | xargs grep -w verbose 
> 
> Shows several other places, I'm trying to plug those, fixed it up in
> your patch and left a committer note, please check and see if all is
> right.

Looks ok to me.  But most of them are part of builtin commands so it
should be added with -q option.  I'll cook a patchset for them.

Thanks,
Namhyung


> 
> - Arnaldo
> 
> diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
> index 70a289347591..7ad0d78ea743 100644
> --- a/tools/perf/builtin-diff.c
> +++ b/tools/perf/builtin-diff.c
> @@ -744,7 +744,7 @@ static void data_process(void)
>  
>  		first = false;
>  
> -		if (verbose || data__files_cnt > 2)
> +		if (verbose > 0 || data__files_cnt > 2)
>  			data__fprintf();
>  
>  		/* Don't sort callchain for perf diff */
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index cd7bc4d104e2..6114e07ca613 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -42,8 +42,8 @@ static int parse_record_events(const struct option *opt,
>  
>  		fprintf(stderr, "%-13s%-*s%s\n",
>  			e->tag,
> -			verbose ? 25 : 0,
> -			verbose ? perf_mem_events__name(j) : "",
> +			verbose > 0 ? 25 : 0,
> +			verbose > 0 ? perf_mem_events__name(j) : "",
>  			e->supported ? ": available" : "");
>  	}
>  	exit(0);
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index b87bbef73394..451b11e35c26 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -432,7 +432,7 @@ static int record__open(struct record *rec)
>  try_again:
>  		if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
>  			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
> -				if (verbose)
> +				if (verbose > 0)
>  					ui__warning("%s\n", msg);
>  				goto try_again;
>  			}
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index dbd7fa028861..a94488114bbf 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -1009,7 +1009,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
>   		 * providing it only in verbose mode not to bloat too
>   		 * much struct symbol.
>   		 */
> -		if (verbose) {
> +		if (verbose > 0) {
>  			/*
>  			 * XXX: Need to provide a less kludgy way to ask for
>  			 * more space per symbol, the u32 is for the index on
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index 270eb2d8ca6b..b94cf0de715a 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -460,7 +460,7 @@ static struct task_desc *register_pid(struct perf_sched *sched,
>  	BUG_ON(!sched->tasks);
>  	sched->tasks[task->nr] = task;
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		printf("registered task #%ld, PID %ld (%s)\n", sched->nr_tasks, pid, comm);
>  
>  	return task;
> @@ -794,7 +794,7 @@ replay_wakeup_event(struct perf_sched *sched,
>  	const u32 pid	 = perf_evsel__intval(evsel, sample, "pid");
>  	struct task_desc *waker, *wakee;
>  
> -	if (verbose) {
> +	if (verbose > 0) {
>  		printf("sched_wakeup event %p\n", evsel);
>  
>  		printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid);
> @@ -822,7 +822,7 @@ static int replay_switch_event(struct perf_sched *sched,
>  	int cpu = sample->cpu;
>  	s64 delta;
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		printf("sched_switch event %p\n", evsel);
>  
>  	if (cpu >= MAX_CPUS || cpu < 0)
> @@ -870,7 +870,7 @@ static int replay_fork_event(struct perf_sched *sched,
>  		goto out_put;
>  	}
>  
> -	if (verbose) {
> +	if (verbose > 0) {
>  		printf("fork event\n");
>  		printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid);
>  		printf("...  child: %s/%d\n", thread__comm_str(child), child->tid);
> @@ -1573,7 +1573,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
>  
>  	timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp));
>  	color_fprintf(stdout, color, "  %12s secs ", stimestamp);
> -	if (new_shortname || (verbose && sched_in->tid)) {
> +	if (new_shortname || (verbose > 0 && sched_in->tid)) {
>  		const char *pid_color = color;
>  
>  		if (thread__has_color(sched_in))
> @@ -2050,7 +2050,7 @@ static void save_task_callchain(struct perf_sched *sched,
>  
>  	if (thread__resolve_callchain(thread, cursor, evsel, sample,
>  				      NULL, NULL, sched->max_stack + 2) != 0) {
> -		if (verbose)
> +		if (verbose > 0)
>  			error("Failed to resolve callchain. Skipping\n");
>  
>  		return;
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 9989b03c21f2..13b54999ad79 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -573,7 +573,7 @@ static int __run_perf_stat(int argc, const char **argv)
>  			if (errno == EINVAL || errno == ENOSYS ||
>  			    errno == ENOENT || errno == EOPNOTSUPP ||
>  			    errno == ENXIO) {
> -				if (verbose)
> +				if (verbose > 0)
>  					ui__warning("%s event is not supported by the kernel.\n",
>  						    perf_evsel__name(counter));
>  				counter->supported = false;
> @@ -582,7 +582,7 @@ static int __run_perf_stat(int argc, const char **argv)
>  				    !(counter->leader->nr_members > 1))
>  					continue;
>  			} else if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
> -                                if (verbose)
> +                                if (verbose > 0)
>                                          ui__warning("%s\n", msg);
>                                  goto try_again;
>                          }
> @@ -2539,7 +2539,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
>  
>  	status = 0;
>  	for (run_idx = 0; forever || run_idx < run_count; run_idx++) {
> -		if (run_count != 1 && verbose)
> +		if (run_count != 1 && verbose > 0)
>  			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
>  				run_idx + 1);
>  
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 5a7fd7af3a6d..ab9077915763 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -871,7 +871,7 @@ static int perf_top__start_counters(struct perf_top *top)
>  		if (perf_evsel__open(counter, top->evlist->cpus,
>  				     top->evlist->threads) < 0) {
>  			if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
> -				if (verbose)
> +				if (verbose > 0)
>  					ui__warning("%s\n", msg);
>  				goto try_again;
>  			}
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 40ef9b293d1b..256f1fac6f7e 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -1399,7 +1399,7 @@ static struct syscall *trace__syscall_info(struct trace *trace,
>  	return &trace->syscalls.table[id];
>  
>  out_cant_read:
> -	if (verbose) {
> +	if (verbose > 0) {
>  		fprintf(trace->output, "Problems reading syscall %d", id);
>  		if (id <= trace->syscalls.max && trace->syscalls.table[id].name != NULL)
>  			fprintf(trace->output, "(%s)", trace->syscalls.table[id].name);
> @@ -1801,10 +1801,10 @@ static void print_location(FILE *f, struct perf_sample *sample,
>  			   bool print_dso, bool print_sym)
>  {
>  
> -	if ((verbose || print_dso) && al->map)
> +	if ((verbose > 0 || print_dso) && al->map)
>  		fprintf(f, "%s@", al->map->dso->long_name);
>  
> -	if ((verbose || print_sym) && al->sym)
> +	if ((verbose > 0 || print_sym) && al->sym)
>  		fprintf(f, "%s+0x%" PRIx64, al->sym->name,
>  			al->addr - al->sym->start);
>  	else if (al->map)
> diff --git a/tools/perf/pmu-events/json.c b/tools/perf/pmu-events/json.c
> index f67bbb0aa36e..0544398d6e2d 100644
> --- a/tools/perf/pmu-events/json.c
> +++ b/tools/perf/pmu-events/json.c
> @@ -49,7 +49,7 @@ static char *mapfile(const char *fn, size_t *size)
>  	int err;
>  	int fd = open(fn, O_RDONLY);
>  
> -	if (fd < 0 && verbose && fn) {
> +	if (fd < 0 && verbose > 0 && fn) {
>  		pr_err("Error opening events file '%s': %s\n", fn,
>  				strerror(errno));
>  	}
> diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
> index 28d1605b0338..88dc51f4c27b 100644
> --- a/tools/perf/tests/attr.c
> +++ b/tools/perf/tests/attr.c
> @@ -144,7 +144,7 @@ static int run_dir(const char *d, const char *perf)
>  	int vcnt = min(verbose, (int) sizeof(v) - 1);
>  	char cmd[3*PATH_MAX];
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		vcnt++;
>  
>  	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 37e326bfd2dc..83c4669cbc5b 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -299,7 +299,7 @@ static int run_test(struct test *test, int subtest)
>  		if (!dont_fork) {
>  			pr_debug("test child forked, pid %d\n", getpid());
>  
> -			if (!verbose) {
> +			if (verbose <= 0) {
>  				int nullfd = open("/dev/null", O_WRONLY);
>  
>  				if (nullfd >= 0) {
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index ff5bc6363a79..d1f693041324 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -599,7 +599,7 @@ static int do_test_code_reading(bool try_kcore)
>  				continue;
>  			}
>  
> -			if (verbose) {
> +			if (verbose > 0) {
>  				char errbuf[512];
>  				perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
>  				pr_debug("perf_evlist__open() failed!\n%s\n", errbuf);
> diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
> index a2b5ff9bf83d..bc5982f42dc3 100644
> --- a/tools/perf/tests/fdarray.c
> +++ b/tools/perf/tests/fdarray.c
> @@ -19,7 +19,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
>  {
>  	int printed = 0;
>  
> -	if (!verbose)
> +	if (verbose <= 0)
>  		return 0;
>  
>  	printed += fprintf(fp, "\n%s: ", prefix);
> diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
> index d357dab72e68..482b5365e68d 100644
> --- a/tools/perf/tests/llvm.c
> +++ b/tools/perf/tests/llvm.c
> @@ -76,7 +76,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
>  	 * Skip this test if user's .perfconfig doesn't set [llvm] section
>  	 * and clang is not found in $PATH, and this is not perf test -v
>  	 */
> -	if (!force && (verbose == 0 &&
> +	if (!force && (verbose <= 0 &&
>  		       !llvm_param.user_set_param &&
>  		       llvm__search_clang())) {
>  		pr_debug("No clang and no verbosive, skip this test\n");
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index aa9276bfe3e9..1dc838014422 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -1808,7 +1808,7 @@ static void debug_warn(const char *warn, va_list params)
>  {
>  	char msg[1024];
>  
> -	if (!verbose)
> +	if (verbose <= 0)
>  		return;
>  
>  	vsnprintf(msg, sizeof(msg), warn, params);
> diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
> index 541da7a68f91..87893f3ba5f1 100644
> --- a/tools/perf/tests/perf-record.c
> +++ b/tools/perf/tests/perf-record.c
> @@ -172,13 +172,13 @@ int test__PERF_RECORD(int subtest __maybe_unused)
>  
>  				err = perf_evlist__parse_sample(evlist, event, &sample);
>  				if (err < 0) {
> -					if (verbose)
> +					if (verbose > 0)
>  						perf_event__fprintf(event, stderr);
>  					pr_debug("Couldn't parse sample\n");
>  					goto out_delete_evlist;
>  				}
>  
> -				if (verbose) {
> +				if (verbose > 0) {
>  					pr_info("%" PRIu64" %d ", sample.time, sample.cpu);
>  					perf_event__fprintf(event, stderr);
>  				}
> diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
> index 7a52834ee0d0..fa79509da535 100644
> --- a/tools/perf/tests/python-use.c
> +++ b/tools/perf/tests/python-use.c
> @@ -15,7 +15,7 @@ int test__python_use(int subtest __maybe_unused)
>  	int ret;
>  
>  	if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
> -		     PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
> +		     PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
>  		return -1;
>  
>  	ret = system(cmd) ? -1 : 0;
> diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
> index a4a4b4625ac3..f2d2e542d0ee 100644
> --- a/tools/perf/tests/thread-map.c
> +++ b/tools/perf/tests/thread-map.c
> @@ -109,7 +109,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
>  	TEST_ASSERT_VAL("failed to allocate thread_map",
>  			threads);
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		thread_map__fprintf(threads, stderr);
>  
>  	TEST_ASSERT_VAL("failed to remove thread",
> @@ -117,7 +117,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
>  
>  	TEST_ASSERT_VAL("thread_map count != 1", threads->nr == 1);
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		thread_map__fprintf(threads, stderr);
>  
>  	TEST_ASSERT_VAL("failed to remove thread",
> @@ -125,7 +125,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
>  
>  	TEST_ASSERT_VAL("thread_map count != 0", threads->nr == 0);
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		thread_map__fprintf(threads, stderr);
>  
>  	TEST_ASSERT_VAL("failed to not remove thread",
> diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
> index a5082331f246..862b043e5924 100644
> --- a/tools/perf/tests/vmlinux-kallsyms.c
> +++ b/tools/perf/tests/vmlinux-kallsyms.c
> @@ -168,7 +168,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
>  		err = -1;
>  	}
>  
> -	if (!verbose)
> +	if (verbose <= 0)
>  		goto out;
>  
>  	header_printed = false;
> diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
> index 98a34664bb7e..9ce142de536d 100644
> --- a/tools/perf/ui/browsers/map.c
> +++ b/tools/perf/ui/browsers/map.c
> @@ -73,7 +73,7 @@ static int map_browser__run(struct map_browser *browser)
>  
>  	if (ui_browser__show(&browser->b, browser->map->dso->long_name,
>  			     "Press ESC to exit, %s / to search",
> -			     verbose ? "" : "restart with -v to use") < 0)
> +			     verbose > 0 ? "" : "restart with -v to use") < 0)
>  		return -1;
>  
>  	while (1) {
> @@ -81,7 +81,7 @@ static int map_browser__run(struct map_browser *browser)
>  
>  		switch (key) {
>  		case '/':
> -			if (verbose)
> +			if (verbose > 0)
>  				map_browser__search(browser);
>  		default:
>  			break;
> @@ -117,7 +117,7 @@ int map__browse(struct map *map)
>  
>  		if (maxaddr < pos->end)
>  			maxaddr = pos->end;
> -		if (verbose) {
> +		if (verbose > 0) {
>  			u32 *idx = symbol__browser_index(pos);
>  			*idx = mb.b.nr_entries;
>  		}
> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> index 18cfcdc90356..5d632dca672a 100644
> --- a/tools/perf/ui/hist.c
> +++ b/tools/perf/ui/hist.c
> @@ -648,7 +648,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
>  		ret += fmt->width(fmt, &dummy_hpp, hists);
>  	}
>  
> -	if (verbose && hists__has(hists, sym)) /* Addr + origin */
> +	if (verbose > 0 && hists__has(hists, sym)) /* Addr + origin */
>  		ret += 3 + BITS_PER_LONG / 4;
>  
>  	return ret;
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 06cc04e5806a..273f21fa32b5 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -1768,7 +1768,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
>  	printf("%-*.*s----\n",
>  	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
>  
> -	if (verbose)
> +	if (verbose > 0)
>  		symbol__annotate_hits(sym, evsel);
>  
>  	list_for_each_entry(pos, &notes->src->source, node) {
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 35f5b7b7715c..28fb62c32678 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -594,7 +594,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
>  	pr_debug("try to find information at %" PRIx64 " in %s\n", addr,
>  		 tp->module ? : "kernel");
>  
> -	dinfo = debuginfo_cache__open(tp->module, verbose == 0);
> +	dinfo = debuginfo_cache__open(tp->module, verbose <= 0);
>  	if (dinfo)
>  		ret = debuginfo__find_probe_point(dinfo,
>  						 (unsigned long)addr, pp);
> diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
> index 39345c2ddfc2..0d51334a9b46 100644
> --- a/tools/perf/util/stat.c
> +++ b/tools/perf/util/stat.c
> @@ -344,7 +344,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
>  	for (i = 0; i < 3; i++)
>  		update_stats(&ps->res_stats[i], count[i]);
>  
> -	if (verbose) {
> +	if (verbose > 0) {
>  		fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
>  			perf_evsel__name(counter), count[0], count[1], count[2]);
>  	}

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/6] perf report: Add -q/--quiet option
  2017-02-20 19:08   ` Arnaldo Carvalho de Melo
@ 2017-02-21  1:40     ` Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: Namhyung Kim @ 2017-02-21  1:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team

On Mon, Feb 20, 2017 at 04:08:01PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Feb 17, 2017 at 05:17:39PM +0900, Namhyung Kim escreveu:
> > The -q/--quiet option is to suppress any message.  Sometimes users just
> > want to see the numbers and it can be used for that case.
> 
> 
> 
> #
> # (Tip: Customize output of perf script with: perf script -F event,ip,sym)
> #
> (END)
> 
> 
> This still appears, at the end :-\

Ah, right.  Will fix.

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf utils: Add perf_quiet_option()
  2017-02-17  8:17 ` [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim
@ 2017-02-21  8:15   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, linux-kernel, a.p.zijlstra, tglx, hpa, namhyung, acme, mingo

Commit-ID:  80df1988201ac6648609eba13d48aef9f7974c10
Gitweb:     http://git.kernel.org/tip/80df1988201ac6648609eba13d48aef9f7974c10
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:37 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:16:32 -0300

perf utils: Add perf_quiet_option()

The perf_quiet_option() is to suppress all messages.  It's intended to
be called just after parsing options.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/debug.c | 17 +++++++++++++++++
 tools/perf/util/debug.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c1838b6..03eb81f 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -203,11 +203,28 @@ int perf_debug_option(const char *str)
 		v = (v < 0) || (v > 10) ? 0 : v;
 	}
 
+	if (quiet)
+		v = -1;
+
 	*var->ptr = v;
 	free(s);
 	return 0;
 }
 
+int perf_quiet_option(void)
+{
+	struct debug_variable *var = &debug_variables[0];
+
+	/* disable all debug messages */
+	while (var->name) {
+		*var->ptr = -1;
+		var++;
+	}
+
+	quiet = true;
+	return 0;
+}
+
 #define DEBUG_WRAPPER(__n, __l)				\
 static int pr_ ## __n ## _wrapper(const char *fmt, ...)	\
 {							\
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index d242adc..98832f5 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -54,5 +54,6 @@ int veprintf(int level, int var, const char *fmt, va_list args);
 
 int perf_debug_option(const char *str);
 void perf_debug_setup(void);
+int perf_quiet_option(void);
 
 #endif	/* __PERF_DEBUG_H */

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf utils: Check verbose flag properly
  2017-02-17  8:17 ` [PATCH 2/6] perf utils: Check verbose flag properly Namhyung Kim
  2017-02-20 14:35   ` Arnaldo Carvalho de Melo
@ 2017-02-21  8:16   ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, namhyung, linux-kernel, acme, mingo, hpa, tglx, a.p.zijlstra

Commit-ID:  bb963e16507ca7670f0bb47ccaada8874b2ba6a1
Gitweb:     http://git.kernel.org/tip/bb963e16507ca7670f0bb47ccaada8874b2ba6a1
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:38 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:35:54 -0300

perf utils: Check verbose flag properly

It now can have negative value to suppress the message entirely.  So it
needs to check it being positive.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-3-namhyung@kernel.org
[ Adjust fuzz on tools/perf/util/pmu.c, add > 0 checks in many other places ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-diff.c           |  2 +-
 tools/perf/builtin-mem.c            |  4 ++--
 tools/perf/builtin-record.c         |  2 +-
 tools/perf/builtin-report.c         |  2 +-
 tools/perf/builtin-sched.c          | 12 ++++++------
 tools/perf/builtin-stat.c           |  6 +++---
 tools/perf/builtin-top.c            |  2 +-
 tools/perf/builtin-trace.c          |  6 +++---
 tools/perf/pmu-events/json.c        |  2 +-
 tools/perf/tests/attr.c             |  2 +-
 tools/perf/tests/builtin-test.c     |  2 +-
 tools/perf/tests/code-reading.c     |  2 +-
 tools/perf/tests/fdarray.c          |  2 +-
 tools/perf/tests/llvm.c             |  2 +-
 tools/perf/tests/parse-events.c     |  2 +-
 tools/perf/tests/perf-record.c      |  4 ++--
 tools/perf/tests/python-use.c       |  2 +-
 tools/perf/tests/thread-map.c       |  6 +++---
 tools/perf/tests/vmlinux-kallsyms.c |  2 +-
 tools/perf/ui/browsers/map.c        |  6 +++---
 tools/perf/ui/hist.c                |  2 +-
 tools/perf/util/annotate.c          |  2 +-
 tools/perf/util/dso.c               |  2 +-
 tools/perf/util/hist.c              |  6 +++---
 tools/perf/util/pmu.c               |  8 ++++----
 tools/perf/util/probe-event.c       |  2 +-
 tools/perf/util/sort.c              |  8 ++++----
 tools/perf/util/stat.c              |  2 +-
 tools/perf/util/symbol-elf.c        |  2 +-
 29 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 70a2893..7ad0d78 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -744,7 +744,7 @@ static void data_process(void)
 
 		first = false;
 
-		if (verbose || data__files_cnt > 2)
+		if (verbose > 0 || data__files_cnt > 2)
 			data__fprintf();
 
 		/* Don't sort callchain for perf diff */
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index cd7bc4d..6114e07 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -42,8 +42,8 @@ static int parse_record_events(const struct option *opt,
 
 		fprintf(stderr, "%-13s%-*s%s\n",
 			e->tag,
-			verbose ? 25 : 0,
-			verbose ? perf_mem_events__name(j) : "",
+			verbose > 0 ? 25 : 0,
+			verbose > 0 ? perf_mem_events__name(j) : "",
 			e->supported ? ": available" : "");
 	}
 	exit(0);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b87bbef..451b11e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -432,7 +432,7 @@ static int record__open(struct record *rec)
 try_again:
 		if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
 			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s\n", msg);
 				goto try_again;
 			}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dbd7fa0..a944881 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1009,7 +1009,7 @@ repeat:
  		 * providing it only in verbose mode not to bloat too
  		 * much struct symbol.
  		 */
-		if (verbose) {
+		if (verbose > 0) {
 			/*
 			 * XXX: Need to provide a less kludgy way to ask for
 			 * more space per symbol, the u32 is for the index on
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 270eb2d..b94cf0d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -460,7 +460,7 @@ static struct task_desc *register_pid(struct perf_sched *sched,
 	BUG_ON(!sched->tasks);
 	sched->tasks[task->nr] = task;
 
-	if (verbose)
+	if (verbose > 0)
 		printf("registered task #%ld, PID %ld (%s)\n", sched->nr_tasks, pid, comm);
 
 	return task;
@@ -794,7 +794,7 @@ replay_wakeup_event(struct perf_sched *sched,
 	const u32 pid	 = perf_evsel__intval(evsel, sample, "pid");
 	struct task_desc *waker, *wakee;
 
-	if (verbose) {
+	if (verbose > 0) {
 		printf("sched_wakeup event %p\n", evsel);
 
 		printf(" ... pid %d woke up %s/%d\n", sample->tid, comm, pid);
@@ -822,7 +822,7 @@ static int replay_switch_event(struct perf_sched *sched,
 	int cpu = sample->cpu;
 	s64 delta;
 
-	if (verbose)
+	if (verbose > 0)
 		printf("sched_switch event %p\n", evsel);
 
 	if (cpu >= MAX_CPUS || cpu < 0)
@@ -870,7 +870,7 @@ static int replay_fork_event(struct perf_sched *sched,
 		goto out_put;
 	}
 
-	if (verbose) {
+	if (verbose > 0) {
 		printf("fork event\n");
 		printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid);
 		printf("...  child: %s/%d\n", thread__comm_str(child), child->tid);
@@ -1573,7 +1573,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
 
 	timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp));
 	color_fprintf(stdout, color, "  %12s secs ", stimestamp);
-	if (new_shortname || (verbose && sched_in->tid)) {
+	if (new_shortname || (verbose > 0 && sched_in->tid)) {
 		const char *pid_color = color;
 
 		if (thread__has_color(sched_in))
@@ -2050,7 +2050,7 @@ static void save_task_callchain(struct perf_sched *sched,
 
 	if (thread__resolve_callchain(thread, cursor, evsel, sample,
 				      NULL, NULL, sched->max_stack + 2) != 0) {
-		if (verbose)
+		if (verbose > 0)
 			error("Failed to resolve callchain. Skipping\n");
 
 		return;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 9989b03..13b5499 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -573,7 +573,7 @@ try_again:
 			if (errno == EINVAL || errno == ENOSYS ||
 			    errno == ENOENT || errno == EOPNOTSUPP ||
 			    errno == ENXIO) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s event is not supported by the kernel.\n",
 						    perf_evsel__name(counter));
 				counter->supported = false;
@@ -582,7 +582,7 @@ try_again:
 				    !(counter->leader->nr_members > 1))
 					continue;
 			} else if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
-                                if (verbose)
+                                if (verbose > 0)
                                         ui__warning("%s\n", msg);
                                 goto try_again;
                         }
@@ -2539,7 +2539,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	status = 0;
 	for (run_idx = 0; forever || run_idx < run_count; run_idx++) {
-		if (run_count != 1 && verbose)
+		if (run_count != 1 && verbose > 0)
 			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
 				run_idx + 1);
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a7fd7a..ab90779 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -871,7 +871,7 @@ try_again:
 		if (perf_evsel__open(counter, top->evlist->cpus,
 				     top->evlist->threads) < 0) {
 			if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) {
-				if (verbose)
+				if (verbose > 0)
 					ui__warning("%s\n", msg);
 				goto try_again;
 			}
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 40ef9b2..256f1fa 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1399,7 +1399,7 @@ static struct syscall *trace__syscall_info(struct trace *trace,
 	return &trace->syscalls.table[id];
 
 out_cant_read:
-	if (verbose) {
+	if (verbose > 0) {
 		fprintf(trace->output, "Problems reading syscall %d", id);
 		if (id <= trace->syscalls.max && trace->syscalls.table[id].name != NULL)
 			fprintf(trace->output, "(%s)", trace->syscalls.table[id].name);
@@ -1801,10 +1801,10 @@ static void print_location(FILE *f, struct perf_sample *sample,
 			   bool print_dso, bool print_sym)
 {
 
-	if ((verbose || print_dso) && al->map)
+	if ((verbose > 0 || print_dso) && al->map)
 		fprintf(f, "%s@", al->map->dso->long_name);
 
-	if ((verbose || print_sym) && al->sym)
+	if ((verbose > 0 || print_sym) && al->sym)
 		fprintf(f, "%s+0x%" PRIx64, al->sym->name,
 			al->addr - al->sym->start);
 	else if (al->map)
diff --git a/tools/perf/pmu-events/json.c b/tools/perf/pmu-events/json.c
index f67bbb0..0544398 100644
--- a/tools/perf/pmu-events/json.c
+++ b/tools/perf/pmu-events/json.c
@@ -49,7 +49,7 @@ static char *mapfile(const char *fn, size_t *size)
 	int err;
 	int fd = open(fn, O_RDONLY);
 
-	if (fd < 0 && verbose && fn) {
+	if (fd < 0 && verbose > 0 && fn) {
 		pr_err("Error opening events file '%s': %s\n", fn,
 				strerror(errno));
 	}
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 28d1605..88dc51f 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -144,7 +144,7 @@ static int run_dir(const char *d, const char *perf)
 	int vcnt = min(verbose, (int) sizeof(v) - 1);
 	char cmd[3*PATH_MAX];
 
-	if (verbose)
+	if (verbose > 0)
 		vcnt++;
 
 	snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 37e326b..83c4669 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -299,7 +299,7 @@ static int run_test(struct test *test, int subtest)
 		if (!dont_fork) {
 			pr_debug("test child forked, pid %d\n", getpid());
 
-			if (!verbose) {
+			if (verbose <= 0) {
 				int nullfd = open("/dev/null", O_WRONLY);
 
 				if (nullfd >= 0) {
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index ff5bc63..d1f6930 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -599,7 +599,7 @@ static int do_test_code_reading(bool try_kcore)
 				continue;
 			}
 
-			if (verbose) {
+			if (verbose > 0) {
 				char errbuf[512];
 				perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
 				pr_debug("perf_evlist__open() failed!\n%s\n", errbuf);
diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
index a2b5ff9..bc5982f 100644
--- a/tools/perf/tests/fdarray.c
+++ b/tools/perf/tests/fdarray.c
@@ -19,7 +19,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
 {
 	int printed = 0;
 
-	if (!verbose)
+	if (verbose <= 0)
 		return 0;
 
 	printed += fprintf(fp, "\n%s: ", prefix);
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index d357dab..482b536 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -76,7 +76,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
 	 * Skip this test if user's .perfconfig doesn't set [llvm] section
 	 * and clang is not found in $PATH, and this is not perf test -v
 	 */
-	if (!force && (verbose == 0 &&
+	if (!force && (verbose <= 0 &&
 		       !llvm_param.user_set_param &&
 		       llvm__search_clang())) {
 		pr_debug("No clang and no verbosive, skip this test\n");
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index aa9276b..1dc8380 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1808,7 +1808,7 @@ static void debug_warn(const char *warn, va_list params)
 {
 	char msg[1024];
 
-	if (!verbose)
+	if (verbose <= 0)
 		return;
 
 	vsnprintf(msg, sizeof(msg), warn, params);
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 541da7a..87893f3 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -172,13 +172,13 @@ int test__PERF_RECORD(int subtest __maybe_unused)
 
 				err = perf_evlist__parse_sample(evlist, event, &sample);
 				if (err < 0) {
-					if (verbose)
+					if (verbose > 0)
 						perf_event__fprintf(event, stderr);
 					pr_debug("Couldn't parse sample\n");
 					goto out_delete_evlist;
 				}
 
-				if (verbose) {
+				if (verbose > 0) {
 					pr_info("%" PRIu64" %d ", sample.time, sample.cpu);
 					perf_event__fprintf(event, stderr);
 				}
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index 7a52834..fa79509 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -15,7 +15,7 @@ int test__python_use(int subtest __maybe_unused)
 	int ret;
 
 	if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s",
-		     PYTHONPATH, PYTHON, verbose ? "" : "2> /dev/null") < 0)
+		     PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0)
 		return -1;
 
 	ret = system(cmd) ? -1 : 0;
diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index a4a4b46..f2d2e54 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -109,7 +109,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 	TEST_ASSERT_VAL("failed to allocate thread_map",
 			threads);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to remove thread",
@@ -117,7 +117,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 
 	TEST_ASSERT_VAL("thread_map count != 1", threads->nr == 1);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to remove thread",
@@ -125,7 +125,7 @@ int test__thread_map_remove(int subtest __maybe_unused)
 
 	TEST_ASSERT_VAL("thread_map count != 0", threads->nr == 0);
 
-	if (verbose)
+	if (verbose > 0)
 		thread_map__fprintf(threads, stderr);
 
 	TEST_ASSERT_VAL("failed to not remove thread",
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index a508233..862b043 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -168,7 +168,7 @@ next_pair:
 		err = -1;
 	}
 
-	if (!verbose)
+	if (verbose <= 0)
 		goto out;
 
 	header_printed = false;
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
index 98a3466..9ce142d 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -73,7 +73,7 @@ static int map_browser__run(struct map_browser *browser)
 
 	if (ui_browser__show(&browser->b, browser->map->dso->long_name,
 			     "Press ESC to exit, %s / to search",
-			     verbose ? "" : "restart with -v to use") < 0)
+			     verbose > 0 ? "" : "restart with -v to use") < 0)
 		return -1;
 
 	while (1) {
@@ -81,7 +81,7 @@ static int map_browser__run(struct map_browser *browser)
 
 		switch (key) {
 		case '/':
-			if (verbose)
+			if (verbose > 0)
 				map_browser__search(browser);
 		default:
 			break;
@@ -117,7 +117,7 @@ int map__browse(struct map *map)
 
 		if (maxaddr < pos->end)
 			maxaddr = pos->end;
-		if (verbose) {
+		if (verbose > 0) {
 			u32 *idx = symbol__browser_index(pos);
 			*idx = mb.b.nr_entries;
 		}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 18cfcdc9..5d632dc 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -648,7 +648,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
 		ret += fmt->width(fmt, &dummy_hpp, hists);
 	}
 
-	if (verbose && hists__has(hists, sym)) /* Addr + origin */
+	if (verbose > 0 && hists__has(hists, sym)) /* Addr + origin */
 		ret += 3 + BITS_PER_LONG / 4;
 
 	return ret;
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 06cc04e..273f21f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1768,7 +1768,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
-	if (verbose)
+	if (verbose > 0)
 		symbol__annotate_hits(sym, evsel);
 
 	list_for_each_entry(pos, &notes->src->source, node) {
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 28d41e7..1a03e9e 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1058,7 +1058,7 @@ int dso__name_len(const struct dso *dso)
 {
 	if (!dso)
 		return strlen("[unknown]");
-	if (verbose)
+	if (verbose > 0)
 		return dso->long_name_len;
 
 	return dso->short_name_len;
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 32c6a93..eaf72a9 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -69,7 +69,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	 */
 	if (h->ms.sym) {
 		symlen = h->ms.sym->namelen + 4;
-		if (verbose)
+		if (verbose > 0)
 			symlen += BITS_PER_LONG / 4 + 2 + 3;
 		hists__new_col_len(hists, HISTC_SYMBOL, symlen);
 	} else {
@@ -93,7 +93,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 	if (h->branch_info) {
 		if (h->branch_info->from.sym) {
 			symlen = (int)h->branch_info->from.sym->namelen + 4;
-			if (verbose)
+			if (verbose > 0)
 				symlen += BITS_PER_LONG / 4 + 2 + 3;
 			hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
 
@@ -107,7 +107,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
 
 		if (h->branch_info->to.sym) {
 			symlen = (int)h->branch_info->to.sym->namelen + 4;
-			if (verbose)
+			if (verbose > 0)
 				symlen += BITS_PER_LONG / 4 + 2 + 3;
 			hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
 
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 63cb46c..12f84dd 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -745,7 +745,7 @@ static int pmu_resolve_param_term(struct parse_events_term *term,
 		}
 	}
 
-	if (verbose)
+	if (verbose > 0)
 		printf("Required parameter '%s' not specified\n", term->config);
 
 	return -1;
@@ -803,7 +803,7 @@ static int pmu_config_term(struct list_head *formats,
 
 	format = pmu_find_format(formats, term->config);
 	if (!format) {
-		if (verbose)
+		if (verbose > 0)
 			printf("Invalid event/parameter '%s'\n", term->config);
 		if (err) {
 			char *pmu_term = pmu_formats_string(formats);
@@ -847,7 +847,7 @@ static int pmu_config_term(struct list_head *formats,
 		val = term->val.num;
 	} else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) {
 		if (strcmp(term->val.str, "?")) {
-			if (verbose) {
+			if (verbose > 0) {
 				pr_info("Invalid sysfs entry %s=%s\n",
 						term->config, term->val.str);
 			}
@@ -1232,7 +1232,7 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
 			printf("%*s", 8, "[");
 			wordwrap(aliases[j].desc, 8, columns, 0);
 			printf("]\n");
-			if (verbose)
+			if (verbose > 0)
 				printf("%*s%s/%s/\n", 8, "", aliases[j].pmu, aliases[j].str);
 		} else
 			printf("  %-50s [Kernel PMU event]\n", aliases[j].name);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 35f5b7b..28fb62c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -594,7 +594,7 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
 	pr_debug("try to find information at %" PRIx64 " in %s\n", addr,
 		 tp->module ? : "kernel");
 
-	dinfo = debuginfo_cache__open(tp->module, verbose == 0);
+	dinfo = debuginfo_cache__open(tp->module, verbose <= 0);
 	if (dinfo)
 		ret = debuginfo__find_probe_point(dinfo,
 						 (unsigned long)addr, pp);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index df622f4..0ff6222 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -151,7 +151,7 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r)
 	if (!dso_l || !dso_r)
 		return cmp_null(dso_r, dso_l);
 
-	if (verbose) {
+	if (verbose > 0) {
 		dso_name_l = dso_l->long_name;
 		dso_name_r = dso_r->long_name;
 	} else {
@@ -172,8 +172,8 @@ static int _hist_entry__dso_snprintf(struct map *map, char *bf,
 				     size_t size, unsigned int width)
 {
 	if (map && map->dso) {
-		const char *dso_name = !verbose ? map->dso->short_name :
-			map->dso->long_name;
+		const char *dso_name = verbose > 0 ? map->dso->long_name :
+			map->dso->short_name;
 		return repsep_snprintf(bf, size, "%-*.*s", width, width, dso_name);
 	}
 
@@ -261,7 +261,7 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
 {
 	size_t ret = 0;
 
-	if (verbose) {
+	if (verbose > 0) {
 		char o = map ? dso__symtab_origin(map->dso) : '!';
 		ret += repsep_snprintf(bf, size, "%-#*llx %c ",
 				       BITS_PER_LONG / 4 + 2, ip, o);
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 39345c2d..0d51334 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -344,7 +344,7 @@ int perf_stat_process_counter(struct perf_stat_config *config,
 	for (i = 0; i < 3; i++)
 		update_stats(&ps->res_stats[i], count[i]);
 
-	if (verbose) {
+	if (verbose > 0) {
 		fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
 			perf_evsel__name(counter), count[0], count[1], count[2]);
 	}
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index adbc6c0..4e59dde 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -213,7 +213,7 @@ static bool want_demangle(bool is_kernel_sym)
 
 static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
 {
-	int demangle_flags = verbose ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
+	int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
 	char *demangled = NULL;
 
 	/*

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf report: Add -q/--quiet option
  2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
  2017-02-17 11:09   ` Jiri Olsa
  2017-02-20 19:08   ` Arnaldo Carvalho de Melo
@ 2017-02-21  8:16   ` tip-bot for Namhyung Kim
  2 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, tglx, mingo, acme, jolsa, linux-kernel, hpa, namhyung

Commit-ID:  27fafab59a60b6f02491f2ff44cafd4f2335e487
Gitweb:     http://git.kernel.org/tip/27fafab59a60b6f02491f2ff44cafd4f2335e487
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:39 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:46:58 -0300

perf report: Add -q/--quiet option

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Before:

  $ perf report | head -15
  Failed to open /lib/modules/3.19.3-3-ARCH/kernel/fs/ext4/ext4.ko.gz, continuing without symbols
  Failed to open /lib/modules/3.19.3-3-ARCH/kernel/fs/jbd2/jbd2.ko.gz, continuing without symbols
  Failed to open /tmp/perf-14507.map, continuing without symbols
  ...
  # To display the perf.data header info, please use --header/--header-only options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 39K of event 'cycles'
  # Event count (approx.): 30444796573
  #
  # Overhead  Command      Shared Object        Symbol
  # ........  ...........  ...................  .........................
  #
       9.28%  swapper	   [kernel.vmlinux]     [k] intel_idle
       5.64%  swapper	   [kernel.vmlinux]     [k] native_write_msr_safe
       1.93%  swapper	   [kernel.vmlinux]     [k] __switch_to
       1.89%  swapper	   [kernel.vmlinux]     [k] menu_select
       1.75%  sched-pipe   [kernel.vmlinux]     [k] __switch_to

After:

  $ perf report -q | head
       9.28%  swapper	   [kernel.vmlinux]     [k] intel_idle
       5.64%  swapper	   [kernel.vmlinux]     [k] native_write_msr_safe
       1.93%  swapper	   [kernel.vmlinux]     [k] __switch_to
       1.89%  swapper	   [kernel.vmlinux]     [k] menu_select
       1.75%  sched-pipe   [kernel.vmlinux]     [k] __switch_to
       1.67%  swapper	   [kernel.vmlinux]     [k] cpu_startup_entry
       1.48%  sched-pipe   [kernel.vmlinux]     [k] enqueue_entity
       1.46%  swapper	   [kernel.vmlinux]     [k] __schedule
       1.36%  swapper	   [kernel.vmlinux]     [k] native_read_tsc
       1.34%  sched-pipe   [kernel.vmlinux]     [k] __schedule

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-4-namhyung@kernel.org
[ Removed builtin-report.c verbose > 0 hunk added to the previous patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-report.txt |  4 ++++
 tools/perf/builtin-report.c              | 19 +++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index f2914f0..c04cc06 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -25,6 +25,10 @@ OPTIONS
 --verbose::
         Be more verbose. (show symbol address, etc)
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -n::
 --show-nr-samples::
 	Show the number of samples for each symbol
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index a944881..0a88670 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -320,6 +320,9 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
 	size_t size = sizeof(buf);
 	int socked_id = hists->socket_filter;
 
+	if (quiet)
+		return 0;
+
 	if (symbol_conf.filter_relative) {
 		nr_samples = hists->stats.nr_non_filtered_samples;
 		nr_events = hists->stats.total_non_filtered_period;
@@ -372,7 +375,11 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 {
 	struct perf_evsel *pos;
 
-	fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples);
+	if (!quiet) {
+		fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
+			evlist->stats.total_lost_samples);
+	}
+
 	evlist__for_each_entry(evlist, pos) {
 		struct hists *hists = evsel__hists(pos);
 		const char *evname = perf_evsel__name(pos);
@@ -382,7 +389,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
 			continue;
 
 		hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
-		hists__fprintf(hists, true, 0, 0, rep->min_percent, stdout,
+		hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
 			       symbol_conf.use_callchain);
 		fprintf(stdout, "\n\n");
 	}
@@ -716,6 +723,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "input file name"),
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
@@ -863,6 +871,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 		report.symbol_filter_str = argv[0];
 	}
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol_conf.vmlinux_name &&
 	    access(symbol_conf.vmlinux_name, R_OK)) {
 		pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
@@ -983,14 +994,14 @@ repeat:
 		goto error;
 	}
 
-	if (report.header || report.header_only) {
+	if ((report.header || report.header_only) && !quiet) {
 		perf_session__fprintf_info(session, stdout,
 					   report.show_full_info);
 		if (report.header_only) {
 			ret = 0;
 			goto error;
 		}
-	} else if (use_browser == 0) {
+	} else if (use_browser == 0 && !quiet) {
 		fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
 		      stdout);
 	}

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf diff: Add -q/--quiet option
  2017-02-17  8:17 ` [PATCH 4/6] perf diff: " Namhyung Kim
@ 2017-02-21  8:17   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, mingo, acme, hpa, namhyung, tglx, linux-kernel, jolsa

Commit-ID:  63b42fce864a468ee02e6647474c4df9bfdc6166
Gitweb:     http://git.kernel.org/tip/63b42fce864a468ee02e6647474c4df9bfdc6166
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:40 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:47:08 -0300

perf diff: Add -q/--quiet option

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Committer notes:

Before:

  # perf diff | head -10
  Failed to open /tmp/perf-6678.map, continuing without symbols
  Failed to open /tmp/perf-6678.map, continuing without symbols
  Failed to open /tmp/perf-2646.map, continuing without symbols
  # Event 'cycles'
  #
  # Baseline  Delta Abs  Shared Object               Symbol
  # ........  .........  ..........................  ............................................
  #
       5.36%     -1.76%  [kernel.vmlinux]            [k] intel_idle
       2.80%     +1.48%  firefox                     [.] 0x00000000000101fe
      57.12%     -1.25%  libxul.so                   [.] 0x00000000009bea92
       1.36%     -1.11%  [kernel.vmlinux]            [k] __schedule
       4.26%     -1.00%  perf-6678.map               [.] 0x00007fac4b0e9320

After:

  # perf diff -q | head -10
       5.36%     -1.76%  [kernel.vmlinux]            [k] intel_idle
       2.80%     +1.48%  firefox                     [.] 0x00000000000101fe
      57.12%     -1.25%  libxul.so                   [.] 0x00000000009bea92
       1.36%     -1.11%  [kernel.vmlinux]            [k] __schedule
       4.26%     -1.00%  perf-6678.map               [.] 0x00007fac4b0e9320
       1.86%     +0.95%  [kernel.vmlinux]            [k] update_blocked_averages
       0.80%     -0.70%  [kernel.vmlinux]            [k] native_sched_clock
       0.74%     -0.58%  [kernel.vmlinux]            [k] native_write_msr
       0.76%     -0.56%  qemu-system-x86_64          [.] 0x00000000002395c0
                 +0.54%  libpulsecommon-10.0.so      [.] 0x000000000002d91b
  #

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-5-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-diff.txt |  4 ++++
 tools/perf/builtin-diff.c              | 14 ++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index 66dbe3de..a79c84a 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -73,6 +73,10 @@ OPTIONS
 	Be verbose, for instance, show the raw counts in addition to the
 	diff.
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -f::
 --force::
         Don't do ownership validation.
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 7ad0d78..1b96a31 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -691,7 +691,7 @@ static void hists__process(struct hists *hists)
 	hists__precompute(hists);
 	hists__output_resort(hists, NULL);
 
-	hists__fprintf(hists, true, 0, 0, 0, stdout,
+	hists__fprintf(hists, !quiet, 0, 0, 0, stdout,
 		       symbol_conf.use_callchain);
 }
 
@@ -739,12 +739,14 @@ static void data_process(void)
 				hists__link(hists_base, hists);
 		}
 
-		fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
-			perf_evsel__name(evsel_base));
+		if (!quiet) {
+			fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
+				perf_evsel__name(evsel_base));
+		}
 
 		first = false;
 
-		if (verbose > 0 || data__files_cnt > 2)
+		if (verbose > 0 || ((data__files_cnt > 2) && !quiet))
 			data__fprintf();
 
 		/* Don't sort callchain for perf diff */
@@ -807,6 +809,7 @@ static const char * const diff_usage[] = {
 static const struct option options[] = {
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
 		    "Show only items with match in baseline"),
 	OPT_CALLBACK('c', "compute", &compute,
@@ -1328,6 +1331,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	argc = parse_options(argc, argv, options, diff_usage, 0);
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol__init(NULL) < 0)
 		return -1;
 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf annotate: Add -q/--quiet option
  2017-02-17  8:17 ` [PATCH 5/6] perf annotate: " Namhyung Kim
@ 2017-02-21  8:17   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, linux-kernel, jolsa, hpa, acme, tglx, namhyung, mingo

Commit-ID:  eddaef88961bbf2c0301f3216689d51fa7d0d472
Gitweb:     http://git.kernel.org/tip/eddaef88961bbf2c0301f3216689d51fa7d0d472
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:41 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:47:18 -0300

perf annotate: Add -q/--quiet option

The -q/--quiet option is to suppress any message.  Sometimes users just
want to see the numbers and it can be used for that case.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-annotate.txt | 4 ++++
 tools/perf/builtin-annotate.c              | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 8ffbd27..a89273d 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -39,6 +39,10 @@ OPTIONS
 --verbose::
         Be more verbose. (Show symbol address, etc)
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -D::
 --dump-raw-trace::
         Dump raw trace in ASCII.
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ebb6283..4f52d85 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -410,6 +410,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"),
 	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
 		    "dump raw trace in ASCII"),
 	OPT_BOOLEAN(0, "gtk", &annotate.use_gtk, "Use the GTK interface"),
@@ -463,6 +464,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		annotate.sym_hist_filter = argv[0];
 	}
 
+	if (quiet)
+		perf_quiet_option();
+
 	file.path  = input_name;
 
 	annotate.session = perf_session__new(&file, false, &annotate.tool);

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [tip:perf/urgent] perf record: Honor --quiet option properly
  2017-02-17  8:17 ` [PATCH 6/6] perf record: Honor quiet option properly Namhyung Kim
@ 2017-02-21  8:18   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Namhyung Kim @ 2017-02-21  8:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, hpa, acme, namhyung, a.p.zijlstra, linux-kernel, mingo, tglx

Commit-ID:  68ba32352d51474d163d58e084b62a12bb610b21
Gitweb:     http://git.kernel.org/tip/68ba32352d51474d163d58e084b62a12bb610b21
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Fri, 17 Feb 2017 17:17:42 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Feb 2017 11:50:36 -0300

perf record: Honor --quiet option properly

It should call perf_quiet_option() to suppress messages.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170217081742.17417-7-namhyung@kernel.org
[ Fix merge clash with 483635a9d080 ("perf record: Add -a as default target") ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 451b11e..bc84a37 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1677,6 +1677,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	argc = parse_options(argc, argv, record_options, record_usage,
 			    PARSE_OPT_STOP_AT_NON_OPTION);
+	if (quiet)
+		perf_quiet_option();
 
 	/* Make system wide (-a) the default target. */
 	if (!argc && target__none(&rec->opts.target))

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-02-21  8:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17  8:17 [PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim
2017-02-17  8:17 ` [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim
2017-02-21  8:15   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2017-02-17  8:17 ` [PATCH 2/6] perf utils: Check verbose flag properly Namhyung Kim
2017-02-20 14:35   ` Arnaldo Carvalho de Melo
2017-02-21  1:38     ` Namhyung Kim
2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2017-02-17  8:17 ` [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim
2017-02-17 11:09   ` Jiri Olsa
2017-02-19  0:21     ` Namhyung Kim
2017-02-20 19:08   ` Arnaldo Carvalho de Melo
2017-02-21  1:40     ` Namhyung Kim
2017-02-21  8:16   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2017-02-17  8:17 ` [PATCH 4/6] perf diff: " Namhyung Kim
2017-02-21  8:17   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2017-02-17  8:17 ` [PATCH 5/6] perf annotate: " Namhyung Kim
2017-02-21  8:17   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2017-02-17  8:17 ` [PATCH 6/6] perf record: Honor quiet option properly Namhyung Kim
2017-02-21  8:18   ` [tip:perf/urgent] perf record: Honor --quiet " tip-bot for Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.