* [PATCH 1/2] perf script: Show proper message when failed list scripts
@ 2016-08-04 11:25 He Kuang
2016-08-04 11:25 ` [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe He Kuang
2016-08-16 18:14 ` [tip:perf/urgent] perf script: Show proper message when failed list scripts tip-bot for He Kuang
0 siblings, 2 replies; 6+ messages in thread
From: He Kuang @ 2016-08-04 11:25 UTC (permalink / raw)
To: acme, peterz, mingo, alexander.shishkin; +Cc: wangnan0, hekuang, linux-kernel
Perf shows the usage message when perf scripts folder failed to open,
which misleads users to let them think the command is mistyped. This
patch shows proper message and guide the users to check PERF_EXEC_PATH
environment in that case.
Before:
$ perf script --list
Usage: perf script [<options>]
or: perf script [<options>] record <script> [<record-options>] <command>
or: perf script [<options>] report <script> [script-args]
or: perf script [<options>] <script> [<record-options>] <command>
or: perf script [<options>] <top-script> [script-args]
-l, --list list available scripts
After:
$ perf script --list
open(/home/user/perf-core/scripts) failed.
Check for "PERF_EXEC_PATH" env to set scripts dir.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
tools/perf/builtin-script.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 971ff91..d47aef9 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1690,8 +1690,13 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
scripts_dir = opendir(scripts_path);
- if (!scripts_dir)
- return -1;
+ if (!scripts_dir) {
+ fprintf(stdout,
+ "open(%s) failed.\n"
+ "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n",
+ scripts_path);
+ exit(-1);
+ }
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
--
1.8.5.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe
2016-08-04 11:25 [PATCH 1/2] perf script: Show proper message when failed list scripts He Kuang
@ 2016-08-04 11:25 ` He Kuang
2016-08-15 10:25 ` Hekuang
2016-08-16 18:15 ` [tip:perf/urgent] " tip-bot for He Kuang
2016-08-16 18:14 ` [tip:perf/urgent] perf script: Show proper message when failed list scripts tip-bot for He Kuang
1 sibling, 2 replies; 6+ messages in thread
From: He Kuang @ 2016-08-04 11:25 UTC (permalink / raw)
To: acme, peterz, mingo, alexander.shishkin; +Cc: wangnan0, hekuang, linux-kernel
Because perf data from pipe do not have a header with evsel attr, we
should not check that and disable symbol_conf.use_callchain. Otherwise,
perf script won't show callchains even if the data stream contains
callchain.
Before:
$ perf record -g -o - uname |perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
uname 1828 182630.186578: 250000 cpu-clock: ..b9499 setup_arg_pages
uname 1828 182630.186850: 250000 cpu-clock: ..83b20 ___might_sleep
uname 1828 182630.187153: 250000 cpu-clock: ..4b6be file_map_prot_ch
...
After:
$ perf record -g -o - uname |perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
uname 1833 182675.927099: 250000 cpu-clock:
ba5520 _raw_spin_lock+0xfe200040 ([kernel.kallsyms])
389dd4 expand_downwards+0xfe200154 ([kernel.kallsyms])
389f34 expand_stack+0xfe200024 ([kernel.kallsyms])
3b957e setup_arg_pages+0xfe20019e ([kernel.kallsyms])
40c80f load_elf_binary+0xfe20042f ([kernel.kallsyms])
...
Signed-off-by: He Kuang <hekuang@huawei.com>
---
tools/perf/builtin-script.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index d47aef9..ec8df8f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
if (!no_callchain) {
bool use_callchain = false;
+ bool not_pipe = false;
evlist__for_each_entry(session->evlist, evsel) {
+ not_pipe = true;
if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
use_callchain = true;
break;
}
}
- if (!use_callchain)
+ if (not_pipe && !use_callchain)
symbol_conf.use_callchain = false;
}
--
1.8.5.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe
2016-08-04 11:25 ` [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe He Kuang
@ 2016-08-15 10:25 ` Hekuang
2016-08-15 16:24 ` Arnaldo Carvalho de Melo
2016-08-16 18:15 ` [tip:perf/urgent] " tip-bot for He Kuang
1 sibling, 1 reply; 6+ messages in thread
From: Hekuang @ 2016-08-15 10:25 UTC (permalink / raw)
To: acme, peterz, mingo, alexander.shishkin; +Cc: wangnan0, linux-kernel
ping.
在 2016/8/4 19:25, He Kuang 写道:
> Because perf data from pipe do not have a header with evsel attr, we
> should not check that and disable symbol_conf.use_callchain. Otherwise,
> perf script won't show callchains even if the data stream contains
> callchain.
>
> Before:
> $ perf record -g -o - uname |perf script
> Linux
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.000 MB - ]
> uname 1828 182630.186578: 250000 cpu-clock: ..b9499 setup_arg_pages
> uname 1828 182630.186850: 250000 cpu-clock: ..83b20 ___might_sleep
> uname 1828 182630.187153: 250000 cpu-clock: ..4b6be file_map_prot_ch
> ...
>
> After:
> $ perf record -g -o - uname |perf script
> Linux
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.000 MB - ]
> uname 1833 182675.927099: 250000 cpu-clock:
> ba5520 _raw_spin_lock+0xfe200040 ([kernel.kallsyms])
> 389dd4 expand_downwards+0xfe200154 ([kernel.kallsyms])
> 389f34 expand_stack+0xfe200024 ([kernel.kallsyms])
> 3b957e setup_arg_pages+0xfe20019e ([kernel.kallsyms])
> 40c80f load_elf_binary+0xfe20042f ([kernel.kallsyms])
> ...
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
> tools/perf/builtin-script.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index d47aef9..ec8df8f 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
>
> if (!no_callchain) {
> bool use_callchain = false;
> + bool not_pipe = false;
>
> evlist__for_each_entry(session->evlist, evsel) {
> + not_pipe = true;
> if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
> use_callchain = true;
> break;
> }
> }
> - if (!use_callchain)
> + if (not_pipe && !use_callchain)
> symbol_conf.use_callchain = false;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe
2016-08-15 10:25 ` Hekuang
@ 2016-08-15 16:24 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-15 16:24 UTC (permalink / raw)
To: Hekuang; +Cc: peterz, mingo, alexander.shishkin, wangnan0, linux-kernel
Em Mon, Aug 15, 2016 at 06:25:15PM +0800, Hekuang escreveu:
> ping.
Thanks, tested and applied both patches.
- Arnaldo
> 在 2016/8/4 19:25, He Kuang 写道:
> > Because perf data from pipe do not have a header with evsel attr, we
> > should not check that and disable symbol_conf.use_callchain. Otherwise,
> > perf script won't show callchains even if the data stream contains
> > callchain.
> >
> > Before:
> > $ perf record -g -o - uname |perf script
> > Linux
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.000 MB - ]
> > uname 1828 182630.186578: 250000 cpu-clock: ..b9499 setup_arg_pages
> > uname 1828 182630.186850: 250000 cpu-clock: ..83b20 ___might_sleep
> > uname 1828 182630.187153: 250000 cpu-clock: ..4b6be file_map_prot_ch
> > ...
> >
> > After:
> > $ perf record -g -o - uname |perf script
> > Linux
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.000 MB - ]
> > uname 1833 182675.927099: 250000 cpu-clock:
> > ba5520 _raw_spin_lock+0xfe200040 ([kernel.kallsyms])
> > 389dd4 expand_downwards+0xfe200154 ([kernel.kallsyms])
> > 389f34 expand_stack+0xfe200024 ([kernel.kallsyms])
> > 3b957e setup_arg_pages+0xfe20019e ([kernel.kallsyms])
> > 40c80f load_elf_binary+0xfe20042f ([kernel.kallsyms])
> > ...
> >
> > Signed-off-by: He Kuang <hekuang@huawei.com>
> > ---
> > tools/perf/builtin-script.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index d47aef9..ec8df8f 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
> > if (!no_callchain) {
> > bool use_callchain = false;
> > + bool not_pipe = false;
> > evlist__for_each_entry(session->evlist, evsel) {
> > + not_pipe = true;
> > if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
> > use_callchain = true;
> > break;
> > }
> > }
> > - if (!use_callchain)
> > + if (not_pipe && !use_callchain)
> > symbol_conf.use_callchain = false;
> > }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:perf/urgent] perf script: Show proper message when failed list scripts
2016-08-04 11:25 [PATCH 1/2] perf script: Show proper message when failed list scripts He Kuang
2016-08-04 11:25 ` [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe He Kuang
@ 2016-08-16 18:14 ` tip-bot for He Kuang
1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for He Kuang @ 2016-08-16 18:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hekuang, acme, tglx, mingo, peterz,
alexander.shishkin, wangnan0, hpa
Commit-ID: 88ded4d8d94a550624e1827478e13fecf97a7b0a
Gitweb: http://git.kernel.org/tip/88ded4d8d94a550624e1827478e13fecf97a7b0a
Author: He Kuang <hekuang@huawei.com>
AuthorDate: Thu, 4 Aug 2016 11:25:42 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 15 Aug 2016 13:17:10 -0300
perf script: Show proper message when failed list scripts
Perf shows the usage message when perf scripts folder failed to open,
which misleads users to let them think the command is being mistyped.
This patch shows a proper message and guides users to check the
PERF_EXEC_PATH environment variable in that case.
Before:
$ perf script --list
Usage: perf script [<options>]
or: perf script [<options>] record <script> [<record-options>] <command>
or: perf script [<options>] report <script> [script-args]
or: perf script [<options>] <script> [<record-options>] <command>
or: perf script [<options>] <top-script> [script-args]
-l, --list list available scripts
After:
$ perf script --list
open(/home/user/perf-core/scripts) failed.
Check for "PERF_EXEC_PATH" env to set scripts dir.
Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1470309943-153909-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-script.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9c640a8..45c51eb 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1690,8 +1690,13 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
scripts_dir = opendir(scripts_path);
- if (!scripts_dir)
- return -1;
+ if (!scripts_dir) {
+ fprintf(stdout,
+ "open(%s) failed.\n"
+ "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n",
+ scripts_path);
+ exit(-1);
+ }
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip:perf/urgent] perf script: Don't disable use_callchain if input is pipe
2016-08-04 11:25 ` [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe He Kuang
2016-08-15 10:25 ` Hekuang
@ 2016-08-16 18:15 ` tip-bot for He Kuang
1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for He Kuang @ 2016-08-16 18:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, acme, alexander.shishkin, peterz, wangnan0, tglx, mingo,
hekuang, linux-kernel
Commit-ID: 71ac899b5ed7edfd8fa2a4e075194380b1de2d7f
Gitweb: http://git.kernel.org/tip/71ac899b5ed7edfd8fa2a4e075194380b1de2d7f
Author: He Kuang <hekuang@huawei.com>
AuthorDate: Thu, 4 Aug 2016 11:25:43 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 15 Aug 2016 13:23:49 -0300
perf script: Don't disable use_callchain if input is pipe
Because perf data from pipe do not have a header with evsel attr, we
should not check that and disable symbol_conf.use_callchain. Otherwise,
perf script won't show callchains even if the data stream contains
callchain.
Before:
$ perf record -g -o - uname |perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
uname 1828 182630.186578: 250000 cpu-clock: ..b9499 setup_arg_pages
uname 1828 182630.186850: 250000 cpu-clock: ..83b20 ___might_sleep
uname 1828 182630.187153: 250000 cpu-clock: ..4b6be file_map_prot_ch
...
After:
$ perf record -g -o - uname |perf script
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
uname 1833 182675.927099: 250000 cpu-clock:
ba5520 _raw_spin_lock+0xfe200040 ([kernel.kallsyms])
389dd4 expand_downwards+0xfe200154 ([kernel.kallsyms])
389f34 expand_stack+0xfe200024 ([kernel.kallsyms])
3b957e setup_arg_pages+0xfe20019e ([kernel.kallsyms])
40c80f load_elf_binary+0xfe20042f ([kernel.kallsyms])
...
Signed-off-by: He Kuang <hekuang@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1470309943-153909-2-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-script.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 45c51eb..c859e59 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
if (!no_callchain) {
bool use_callchain = false;
+ bool not_pipe = false;
evlist__for_each_entry(session->evlist, evsel) {
+ not_pipe = true;
if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
use_callchain = true;
break;
}
}
- if (!use_callchain)
+ if (not_pipe && !use_callchain)
symbol_conf.use_callchain = false;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-16 18:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-04 11:25 [PATCH 1/2] perf script: Show proper message when failed list scripts He Kuang
2016-08-04 11:25 ` [PATCH 2/2] perf script: Don't disable use_callchain if input is pipe He Kuang
2016-08-15 10:25 ` Hekuang
2016-08-15 16:24 ` Arnaldo Carvalho de Melo
2016-08-16 18:15 ` [tip:perf/urgent] " tip-bot for He Kuang
2016-08-16 18:14 ` [tip:perf/urgent] perf script: Show proper message when failed list scripts tip-bot for He Kuang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox