[PATCH 16/23] perf mem: Add -q/--quiet option

From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:20:57 EST


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

Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-mem.txt | 8 ++++++++
tools/perf/builtin-mem.c | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index 73496320fca3..5ad90572299c 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -59,6 +59,14 @@ OPTIONS
--ldload::
Specify desired latency for loads event.

+-v::
+--verbose::
+ Be more verbose. (show debug messages, etc)
+
+-q::
+--quiet::
+ Do not show any message. (Suppress -v)
+
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 6114e07ca613..24d084327c1e 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -70,6 +70,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
OPT_UINTEGER(0, "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('U', "all-user", &all_user, "collect only user level data"),
OPT_BOOLEAN('K', "all-kernel", &all_kernel, "collect only kernel level data"),
OPT_END()
@@ -83,6 +84,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
if (!rec_argv)
return -1;

+ if (quiet)
+ perf_quiet_option();
+
rec_argv[i++] = "record";

if (mem->operation & MEM_OPERATION_LOAD)
@@ -144,7 +148,7 @@ dump_raw_samples(struct perf_tool *tool,
struct addr_location al;
const char *fmt;

- if (machine__resolve(machine, &al, sample) < 0) {
+ if (machine__resolve(machine, &al, sample) < 0 && !quiet) {
fprintf(stderr, "problem processing %d event, skipping it.\n",
event->header.type);
return -1;
--
2.11.0