Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1594434 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2017-03-07 18:00 +0100 |
| Last post | 2017-03-07 20:40 +0100 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCHSET 00/23] perf tools: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-03-07 18:00 +0100
[PATCH 23/23] perf trace: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-03-07 20:20 +0100
[PATCH 09/23] perf ftrace: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-03-07 20:40 +0100
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2017-03-07 18:00 +0100 |
| Subject | [PATCHSET 00/23] perf tools: Add -q/--quiet option |
| Message-ID | <tip46-X4-13@gated-at.bofh.it> |
Hello, This patchset adds -q/--quiet option for most commands. I skipped commands missing -v/--verbose option. While the -q option in this patchset just suppresses warning messages, some command might want to mute other outputs too. I added a few obvious ones and if you have some thought, please let me know. The patch 1, 4 and 5 are fixes and can be applied separately. The code is available on the 'perf/quiet-v2' branche on my tree git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git Thanks, Namhyung Namhyung Kim (23): perf report: Hide tip message when -q option is given perf buildid-cache: Add -q/--quiet option perf buildid-list: Add -q/--quiet option perf c2c: Fix help message of --stats option perf c2c: Fix display bug when using pipe perf c2c: Add -q/--quiet option perf data: Add -q/--quiet option perf evlist: Add -q/--quiet option perf ftrace: Add -q/--quiet option perf inject: Add -q/--quiet option perf kallsyms: Add -q/--quiet option perf kmem: Add -q/--quiet option perf kvm: Add -q/--quiet option perf list: Add -q/--quiet option perf lock: Add -q/--quiet option perf mem: Add -q/--quiet option perf sched: Add -q/--quiet option perf script: Use pr_err() for error messages perf script: Add -q/--quiet option perf stat: Use pr_err() for error messages perf stat: Add -q/--quiet option perf top: Add -q/--quiet option perf trace: Add -q/--quiet option tools/perf/Documentation/perf-buildid-cache.txt | 4 ++ tools/perf/Documentation/perf-buildid-list.txt | 3 ++ tools/perf/Documentation/perf-c2c.txt | 8 ++++ tools/perf/Documentation/perf-data.txt | 4 ++ tools/perf/Documentation/perf-evlist.txt | 4 ++ tools/perf/Documentation/perf-ftrace.txt | 4 ++ tools/perf/Documentation/perf-inject.txt | 3 ++ tools/perf/Documentation/perf-kallsyms.txt | 4 ++ tools/perf/Documentation/perf-kmem.txt | 4 ++ tools/perf/Documentation/perf-kvm.txt | 3 ++ tools/perf/Documentation/perf-list.txt | 9 +++- tools/perf/Documentation/perf-lock.txt | 8 ++++ tools/perf/Documentation/perf-mem.txt | 8 ++++ tools/perf/Documentation/perf-sched.txt | 8 ++++ tools/perf/Documentation/perf-script.txt | 8 ++++ tools/perf/Documentation/perf-stat.txt | 4 ++ tools/perf/Documentation/perf-top.txt | 4 ++ tools/perf/Documentation/perf-trace.txt | 4 ++ tools/perf/builtin-buildid-cache.c | 4 ++ tools/perf/builtin-buildid-list.c | 4 ++ tools/perf/builtin-c2c.c | 16 +++++-- tools/perf/builtin-data.c | 4 ++ tools/perf/builtin-evlist.c | 8 +++- tools/perf/builtin-ftrace.c | 7 ++- tools/perf/builtin-inject.c | 10 ++++- tools/perf/builtin-kallsyms.c | 7 ++- tools/perf/builtin-kmem.c | 4 ++ tools/perf/builtin-kvm.c | 10 ++++- tools/perf/builtin-list.c | 9 +++- tools/perf/builtin-lock.c | 33 ++++++++------ tools/perf/builtin-mem.c | 6 ++- tools/perf/builtin-report.c | 3 +- tools/perf/builtin-sched.c | 12 +++++ tools/perf/builtin-script.c | 45 ++++++++++--------- tools/perf/builtin-stat.c | 59 ++++++++++++++++--------- tools/perf/builtin-top.c | 6 ++- tools/perf/builtin-trace.c | 33 +++++++++----- 37 files changed, 291 insertions(+), 83 deletions(-) -- 2.11.0
[toc] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2017-03-07 20:20 +0100 |
| Subject | [PATCH 23/23] perf trace: Add -q/--quiet option |
| Message-ID | <tisOl-3ze-13@gated-at.bofh.it> |
| In reply to | #1594434 |
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.
Also check the quiet variable when printing error messages.
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-trace.txt | 4 ++++
tools/perf/builtin-trace.c | 33 ++++++++++++++++++++++-----------
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index afd728672b6f..4ac21b6194e7 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -70,6 +70,10 @@ filter out the startup phase of the program, which is often very different.
--verbose=::
Verbosity level.
+-q::
+--quiet::
+ Do not show any message. (Suppress -v)
+
--no-inherit::
Child tasks do not inherit counters.
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 256f1fac6f7e..00e1349c73bf 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1242,7 +1242,7 @@ static int trace__validate_ev_qualifier(struct trace *trace)
trace->ev_qualifier_ids.entries = malloc(trace->ev_qualifier_ids.nr *
sizeof(trace->ev_qualifier_ids.entries[0]));
- if (trace->ev_qualifier_ids.entries == NULL) {
+ if (trace->ev_qualifier_ids.entries == NULL && !quiet) {
fputs("Error:\tNot enough memory for allocating events qualifier ids\n",
trace->output);
err = -EINVAL;
@@ -1257,7 +1257,8 @@ static int trace__validate_ev_qualifier(struct trace *trace)
if (id < 0) {
if (err == 0) {
- fputs("Error:\tInvalid syscall ", trace->output);
+ if (!quiet)
+ fputs("Error:\tInvalid syscall ", trace->output);
err = -EINVAL;
} else {
fputs(", ", trace->output);
@@ -1270,8 +1271,10 @@ static int trace__validate_ev_qualifier(struct trace *trace)
}
if (err < 0) {
- fputs("\nHint:\ttry 'perf list syscalls:sys_enter_*'"
- "\nHint:\tand: 'man syscalls'\n", trace->output);
+ if (verbose >= 0) {
+ fputs("\nHint:\ttry 'perf list syscalls:sys_enter_*'"
+ "\nHint:\tand: 'man syscalls'\n", trace->output);
+ }
zfree(&trace->ev_qualifier_ids.entries);
trace->ev_qualifier_ids.nr = 0;
}
@@ -2604,7 +2607,7 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
size_t printed = trace__fprintf_threads_header(fp);
struct rb_node *nd;
- if (threads == NULL) {
+ if (threads == NULL && !quiet) {
fprintf(fp, "%s", "Error sorting output by nr_events!\n");
return 0;
}
@@ -2761,7 +2764,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
};
trace->ev_qualifier = strlist__new(lists[1], &slist_config);
- if (trace->ev_qualifier == NULL) {
+ if (trace->ev_qualifier == NULL && !quiet) {
fputs("Not enough memory to parse event qualifier", trace->output);
goto out;
}
@@ -2849,6 +2852,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
trace__set_duration),
OPT_BOOLEAN(0, "sched", &trace.sched, "show blocking scheduler events"),
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_BOOLEAN('T', "time", &trace.full_time,
"Show full timestamp, not time relative to first start"),
OPT_BOOLEAN('s', "summary", &trace.summary_only,
@@ -2898,6 +2902,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
argc = parse_options_subcommand(argc, argv, trace_options, trace_subcommands,
trace_usage, PARSE_OPT_STOP_AT_NON_OPTION);
+ if (quiet)
+ perf_quiet_option();
err = bpf__setup_stdout(trace.evlist);
if (err) {
@@ -2957,7 +2963,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
if (output_name != NULL) {
err = trace__open_output(&trace, output_name);
if (err < 0) {
- perror("failed to create output file");
+ pr_err("failed to create output file: %s\n",
+ str_error_r(errno, bf, sizeof(bf)));
goto out;
}
}
@@ -2966,15 +2973,19 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
err = target__validate(&trace.opts.target);
if (err) {
- target__strerror(&trace.opts.target, err, bf, sizeof(bf));
- fprintf(trace.output, "%s", bf);
+ if (!quiet) {
+ target__strerror(&trace.opts.target, err, bf, sizeof(bf));
+ fprintf(trace.output, "%s", bf);
+ }
goto out_close;
}
err = target__parse_uid(&trace.opts.target);
if (err) {
- target__strerror(&trace.opts.target, err, bf, sizeof(bf));
- fprintf(trace.output, "%s", bf);
+ if (!quiet) {
+ target__strerror(&trace.opts.target, err, bf, sizeof(bf));
+ fprintf(trace.output, "%s", bf);
+ }
goto out_close;
}
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2017-03-07 20:40 +0100 |
| Subject | [PATCH 09/23] perf ftrace: Add -q/--quiet option |
| Message-ID | <tit7I-3FT-13@gated-at.bofh.it> |
| In reply to | #1594434 |
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@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-ftrace.txt | 4 ++++
tools/perf/builtin-ftrace.c | 7 +++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt
index 6e6a8b22c859..361836114268 100644
--- a/tools/perf/Documentation/perf-ftrace.txt
+++ b/tools/perf/Documentation/perf-ftrace.txt
@@ -30,6 +30,10 @@ OPTIONS
--verbose=::
Verbosity level.
+-q::
+--quiet::
+ Do not show any message.
+
-p::
--pid=::
Trace on existing process id (comma separated list).
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 6087295f8827..2d8e8924cfe6 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -321,8 +321,8 @@ int cmd_ftrace(int argc, const char **argv, const char *prefix __maybe_unused)
"tracer to use: function_graph(default) or function"),
OPT_STRING('p', "pid", &ftrace.target.pid, "pid",
"trace on existing process id"),
- OPT_INCR('v', "verbose", &verbose,
- "be more verbose"),
+ OPT_INCR('v', "verbose", &verbose, "be more verbose"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "do not show any message"),
OPT_BOOLEAN('a', "all-cpus", &ftrace.target.system_wide,
"system-wide collection from all CPUs"),
OPT_STRING('C', "cpu", &ftrace.target.cpu_list, "cpu",
@@ -339,6 +339,9 @@ int cmd_ftrace(int argc, const char **argv, const char *prefix __maybe_unused)
if (!argc && target__none(&ftrace.target))
usage_with_options(ftrace_usage, ftrace_options);
+ if (quiet)
+ perf_quiet_option();
+
ret = target__validate(&ftrace.target);
if (ret) {
char errbuf[512];
--
2.11.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web