[PATCH 06/23] perf c2c: Add -q/--quiet option

From: Namhyung Kim
Date: Tue Mar 07 2017 - 11:08:45 EST


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

Before:

$ perf c2c report | head
/usr/lib/mutter/libmutter-clutter-1.0.so with build id 32c8c08c8720ccc486a9b2d6169c8ef121652074 not found, continuing without symbols
/usr/lib/mutter/libmutter-cogl-1.0.so with build id c490779d992d60a58a8ddfa15bbe9b4a9c22749f not found, continuing without symbols
...
=================================================
Trace Event Information
=================================================
Total records : 136
Locked Load/Store Operations : 6
Load Operations : 62
Loads - uncacheable : 0
Loads - IO : 1
Loads - Miss : 7
Loads - no mapping : 2

After:

$ perf c2c report -q | head
=================================================
Trace Event Information
=================================================
Total records : 136
Locked Load/Store Operations : 6
Load Operations : 62
Loads - uncacheable : 0
Loads - IO : 1
Loads - Miss : 7
Loads - no mapping : 2

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

diff --git a/tools/perf/Documentation/perf-c2c.txt b/tools/perf/Documentation/perf-c2c.txt
index 2da07e51e119..5f529c810e43 100644
--- a/tools/perf/Documentation/perf-c2c.txt
+++ b/tools/perf/Documentation/perf-c2c.txt
@@ -44,6 +44,10 @@ RECORD OPTIONS
--verbose::
Be more verbose (show counter open errors, etc).

+-q::
+--quiet::
+ Do not show any message.
+
-l::
--ldlat::
Configure mem-loads latency.
@@ -66,6 +70,10 @@ REPORT OPTIONS
--verbose::
Be more verbose (show counter open errors, etc).

+-q::
+--quiet::
+ Do not show any message.
+
-i::
--input::
Specify the input file to process.
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 5cd6d7a047b9..211f9f29620c 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -103,6 +103,7 @@ static const char *display_str[DISPLAY_MAX] = {

static const struct option c2c_options[] = {
OPT_INCR('v', "verbose", &verbose, "be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_END()
};

@@ -184,7 +185,7 @@ he__get_c2c_hists(struct hist_entry *he,
static void c2c_he__set_cpu(struct c2c_hist_entry *c2c_he,
struct perf_sample *sample)
{
- if (WARN_ONCE(sample->cpu == (unsigned int) -1,
+ if (WARN_ONCE((sample->cpu == (unsigned int) -1) && !quiet,
"WARNING: no sample cpu value"))
return;

@@ -1932,7 +1933,8 @@ static int setup_nodes(struct perf_session *session)
for (cpu = 0; cpu < map->nr; cpu++) {
set_bit(map->map[cpu], set);

- if (WARN_ONCE(cpu2node[map->map[cpu]] != -1, "node/cpu topology bug"))
+ if (WARN_ONCE((cpu2node[map->map[cpu]] != -1) && !quiet,
+ "node/cpu topology bug"))
return -EINVAL;

cpu2node[map->map[cpu]] = node;
@@ -2561,6 +2563,9 @@ static int perf_c2c__report(int argc, const char **argv)
if (argc)
usage_with_options(report_c2c_usage, options);

+ if (quiet)
+ perf_quiet_option();
+
if (c2c.stats_only)
c2c.use_stdio = true;

@@ -2707,6 +2712,9 @@ static int perf_c2c__record(int argc, const char **argv)
if (!rec_argv)
return -1;

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

if (!event_set) {
--
2.11.0