* [PATCH] perf record: Add support to collect callchains from kernel or user space only.
@ 2019-05-30 13:29 ufo19890607
2019-06-06 6:05 ` 禹舟键
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: ufo19890607 @ 2019-05-30 13:29 UTC (permalink / raw)
To: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0
Cc: linux-perf-users, linux-kernel, acme
From: yuzhoujian <yuzhoujian@didichuxing.com>
One can just record callchains in the kernel or user space with
this new options. We can use it together with "--all-kernel" options.
This two options is used just like print_stack(sys) or print_ustack(usr)
for systemtap.
Show below is the usage of this new option combined with "--all-kernel"
options.
1. Configure all used events to run in kernel space and just
collect kernel callchains.
$ perf record -a -g --all-kernel --kernel-callchains
2. Configure all used events to run in kernel space and just
collect user callchains.
$ perf record -a -g --all-kernel --user-callchains
Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
---
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/builtin-record.c | 4 ++++
tools/perf/perf.h | 2 ++
tools/perf/util/evsel.c | 4 ++++
4 files changed, 16 insertions(+)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index de269430720a..b647eb3db0c6 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
--all-user::
Configure all used events to run in user space.
+--kernel-callchains::
+Collect callchains from kernel space.
+
+--user-callchains::
+Collect callchains from user space.
+
--timestamp-filename
Append timestamp to output file name.
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e2c3a585a61e..dca55997934e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -2191,6 +2191,10 @@ static struct option __record_options[] = {
OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
"Configure all used events to run in user space.",
PARSE_OPT_EXCLUSIVE),
+ OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains,
+ "collect kernel callchains"),
+ OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains,
+ "collect user callchains"),
OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
"clang binary to use for compiling BPF scriptlets"),
OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index d59dee61b64d..711e009381ec 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -61,6 +61,8 @@ struct record_opts {
bool record_switch_events;
bool all_kernel;
bool all_user;
+ bool kernel_callchains;
+ bool user_callchains;
bool tail_synthesize;
bool overwrite;
bool ignore_missing_thread;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a6f572a40deb..a606b2833e27 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
attr->sample_max_stack = param->max_stack;
+ if (opts->kernel_callchains)
+ attr->exclude_callchain_user = 1;
+ if (opts->user_callchains)
+ attr->exclude_callchain_kernel = 1;
if (param->record_mode == CALLCHAIN_LBR) {
if (!opts->branch_stack) {
if (attr->exclude_user) {
--
2.14.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-05-30 13:29 [PATCH] perf record: Add support to collect callchains from kernel or user space only ufo19890607
@ 2019-06-06 6:05 ` 禹舟键
2019-06-06 7:25 ` Jiri Olsa
2019-06-06 14:26 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 8+ messages in thread
From: 禹舟键 @ 2019-06-06 6:05 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
David Ahern, Namhyung Kim, Milian Wolff, Arnaldo Carvalho de Melo,
Wind Yu, Adrian Hunter, Wang Nan
Cc: linux-perf-users, linux-kernel, acme
PING
ufo19890607 <ufo19890607@gmail.com> 于2019年5月30日周四 下午9:29写道:
>
> From: yuzhoujian <yuzhoujian@didichuxing.com>
>
> One can just record callchains in the kernel or user space with
> this new options. We can use it together with "--all-kernel" options.
> This two options is used just like print_stack(sys) or print_ustack(usr)
> for systemtap.
>
> Show below is the usage of this new option combined with "--all-kernel"
> options.
> 1. Configure all used events to run in kernel space and just
> collect kernel callchains.
> $ perf record -a -g --all-kernel --kernel-callchains
> 2. Configure all used events to run in kernel space and just
> collect user callchains.
> $ perf record -a -g --all-kernel --user-callchains
>
> Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> ---
> tools/perf/Documentation/perf-record.txt | 6 ++++++
> tools/perf/builtin-record.c | 4 ++++
> tools/perf/perf.h | 2 ++
> tools/perf/util/evsel.c | 4 ++++
> 4 files changed, 16 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index de269430720a..b647eb3db0c6 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
> --all-user::
> Configure all used events to run in user space.
>
> +--kernel-callchains::
> +Collect callchains from kernel space.
> +
> +--user-callchains::
> +Collect callchains from user space.
> +
> --timestamp-filename
> Append timestamp to output file name.
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index e2c3a585a61e..dca55997934e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -2191,6 +2191,10 @@ static struct option __record_options[] = {
> OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
> "Configure all used events to run in user space.",
> PARSE_OPT_EXCLUSIVE),
> + OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains,
> + "collect kernel callchains"),
> + OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains,
> + "collect user callchains"),
> OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
> "clang binary to use for compiling BPF scriptlets"),
> OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index d59dee61b64d..711e009381ec 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -61,6 +61,8 @@ struct record_opts {
> bool record_switch_events;
> bool all_kernel;
> bool all_user;
> + bool kernel_callchains;
> + bool user_callchains;
> bool tail_synthesize;
> bool overwrite;
> bool ignore_missing_thread;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a6f572a40deb..a606b2833e27 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
>
> attr->sample_max_stack = param->max_stack;
>
> + if (opts->kernel_callchains)
> + attr->exclude_callchain_user = 1;
> + if (opts->user_callchains)
> + attr->exclude_callchain_kernel = 1;
> if (param->record_mode == CALLCHAIN_LBR) {
> if (!opts->branch_stack) {
> if (attr->exclude_user) {
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-05-30 13:29 [PATCH] perf record: Add support to collect callchains from kernel or user space only ufo19890607
2019-06-06 6:05 ` 禹舟键
@ 2019-06-06 7:25 ` Jiri Olsa
2019-06-06 14:26 ` Arnaldo Carvalho de Melo
2 siblings, 0 replies; 8+ messages in thread
From: Jiri Olsa @ 2019-06-06 7:25 UTC (permalink / raw)
To: ufo19890607
Cc: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0,
linux-perf-users, linux-kernel, acme
On Thu, May 30, 2019 at 02:29:22PM +0100, ufo19890607 wrote:
> From: yuzhoujian <yuzhoujian@didichuxing.com>
>
> One can just record callchains in the kernel or user space with
> this new options. We can use it together with "--all-kernel" options.
> This two options is used just like print_stack(sys) or print_ustack(usr)
> for systemtap.
>
> Show below is the usage of this new option combined with "--all-kernel"
> options.
> 1. Configure all used events to run in kernel space and just
> collect kernel callchains.
> $ perf record -a -g --all-kernel --kernel-callchains
> 2. Configure all used events to run in kernel space and just
> collect user callchains.
> $ perf record -a -g --all-kernel --user-callchains
>
> Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
> ---
> tools/perf/Documentation/perf-record.txt | 6 ++++++
> tools/perf/builtin-record.c | 4 ++++
> tools/perf/perf.h | 2 ++
> tools/perf/util/evsel.c | 4 ++++
> 4 files changed, 16 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index de269430720a..b647eb3db0c6 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
> --all-user::
> Configure all used events to run in user space.
>
> +--kernel-callchains::
> +Collect callchains from kernel space.
> +
> +--user-callchains::
> +Collect callchains from user space.
> +
> --timestamp-filename
> Append timestamp to output file name.
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index e2c3a585a61e..dca55997934e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -2191,6 +2191,10 @@ static struct option __record_options[] = {
> OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
> "Configure all used events to run in user space.",
> PARSE_OPT_EXCLUSIVE),
> + OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains,
> + "collect kernel callchains"),
> + OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains,
> + "collect user callchains"),
> OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
> "clang binary to use for compiling BPF scriptlets"),
> OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index d59dee61b64d..711e009381ec 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -61,6 +61,8 @@ struct record_opts {
> bool record_switch_events;
> bool all_kernel;
> bool all_user;
> + bool kernel_callchains;
> + bool user_callchains;
> bool tail_synthesize;
> bool overwrite;
> bool ignore_missing_thread;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a6f572a40deb..a606b2833e27 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
>
> attr->sample_max_stack = param->max_stack;
>
> + if (opts->kernel_callchains)
> + attr->exclude_callchain_user = 1;
> + if (opts->user_callchains)
> + attr->exclude_callchain_kernel = 1;
> if (param->record_mode == CALLCHAIN_LBR) {
> if (!opts->branch_stack) {
> if (attr->exclude_user) {
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-05-30 13:29 [PATCH] perf record: Add support to collect callchains from kernel or user space only ufo19890607
2019-06-06 6:05 ` 禹舟键
2019-06-06 7:25 ` Jiri Olsa
@ 2019-06-06 14:26 ` Arnaldo Carvalho de Melo
2019-06-06 14:29 ` Arnaldo Carvalho de Melo
2019-06-06 14:46 ` Jiri Olsa
2 siblings, 2 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-06-06 14:26 UTC (permalink / raw)
To: ufo19890607
Cc: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0,
linux-perf-users, linux-kernel, acme
Em Thu, May 30, 2019 at 02:29:22PM +0100, ufo19890607 escreveu:
> From: yuzhoujian <yuzhoujian@didichuxing.com>
>
> One can just record callchains in the kernel or user space with
> this new options. We can use it together with "--all-kernel" options.
> This two options is used just like print_stack(sys) or print_ustack(usr)
> for systemtap.
>
> Show below is the usage of this new option combined with "--all-kernel"
> options.
> 1. Configure all used events to run in kernel space and just
> collect kernel callchains.
> $ perf record -a -g --all-kernel --kernel-callchains
> 2. Configure all used events to run in kernel space and just
> collect user callchains.
> $ perf record -a -g --all-kernel --user-callchains
>
> Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> ---
> tools/perf/Documentation/perf-record.txt | 6 ++++++
> tools/perf/builtin-record.c | 4 ++++
> tools/perf/perf.h | 2 ++
> tools/perf/util/evsel.c | 4 ++++
> 4 files changed, 16 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index de269430720a..b647eb3db0c6 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
> --all-user::
> Configure all used events to run in user space.
>
> +--kernel-callchains::
> +Collect callchains from kernel space.
Ok, changing this to:
Collect callchains only from kernel space. I.e. this option sets
perf_event_attr.exclude_callchain_user to 1,
perf_event_attr.exclude_callchain_kernel to 0.
> +
> +--user-callchains::
> +Collect callchains from user space.
And this one to:
Collect callchains only from user space. I.e. this option sets
perf_event_attr.exclude_callchain_kernel to 1,
perf_event_attr.exclude_callchain_user to 0.
So that the user don't try using:
pref record --user-callchains --kernel-callchains
expecting to get both user and kernel callchains and instead gets
nothing.
Ok?
- Arnaldo
> +
> --timestamp-filename
> Append timestamp to output file name.
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index e2c3a585a61e..dca55997934e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -2191,6 +2191,10 @@ static struct option __record_options[] = {
> OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
> "Configure all used events to run in user space.",
> PARSE_OPT_EXCLUSIVE),
> + OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains,
> + "collect kernel callchains"),
> + OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains,
> + "collect user callchains"),
> OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
> "clang binary to use for compiling BPF scriptlets"),
> OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index d59dee61b64d..711e009381ec 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -61,6 +61,8 @@ struct record_opts {
> bool record_switch_events;
> bool all_kernel;
> bool all_user;
> + bool kernel_callchains;
> + bool user_callchains;
> bool tail_synthesize;
> bool overwrite;
> bool ignore_missing_thread;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index a6f572a40deb..a606b2833e27 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
>
> attr->sample_max_stack = param->max_stack;
>
> + if (opts->kernel_callchains)
> + attr->exclude_callchain_user = 1;
> + if (opts->user_callchains)
> + attr->exclude_callchain_kernel = 1;
> if (param->record_mode == CALLCHAIN_LBR) {
> if (!opts->branch_stack) {
> if (attr->exclude_user) {
> --
> 2.14.1
--
- Arnaldo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-06-06 14:26 ` Arnaldo Carvalho de Melo
@ 2019-06-06 14:29 ` Arnaldo Carvalho de Melo
2019-06-06 14:46 ` Jiri Olsa
1 sibling, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-06-06 14:29 UTC (permalink / raw)
To: ufo19890607
Cc: peterz, mingo, alexander.shishkin, jolsa, dsahern, namhyung,
milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter, wangnan0,
linux-perf-users, linux-kernel, acme
Em Thu, Jun 06, 2019 at 11:26:44AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, May 30, 2019 at 02:29:22PM +0100, ufo19890607 escreveu:
> > From: yuzhoujian <yuzhoujian@didichuxing.com>
> >
> > One can just record callchains in the kernel or user space with
> > this new options. We can use it together with "--all-kernel" options.
> > This two options is used just like print_stack(sys) or print_ustack(usr)
> > for systemtap.
> >
> > Show below is the usage of this new option combined with "--all-kernel"
> > options.
> > 1. Configure all used events to run in kernel space and just
> > collect kernel callchains.
> > $ perf record -a -g --all-kernel --kernel-callchains
> > 2. Configure all used events to run in kernel space and just
> > collect user callchains.
> > $ perf record -a -g --all-kernel --user-callchains
> >
> > Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> > ---
> > tools/perf/Documentation/perf-record.txt | 6 ++++++
> > tools/perf/builtin-record.c | 4 ++++
> > tools/perf/perf.h | 2 ++
> > tools/perf/util/evsel.c | 4 ++++
> > 4 files changed, 16 insertions(+)
> >
> > diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> > index de269430720a..b647eb3db0c6 100644
> > --- a/tools/perf/Documentation/perf-record.txt
> > +++ b/tools/perf/Documentation/perf-record.txt
> > @@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
> > --all-user::
> > Configure all used events to run in user space.
> >
> > +--kernel-callchains::
> > +Collect callchains from kernel space.
>
> Ok, changing this to:
>
> Collect callchains only from kernel space. I.e. this option sets
> perf_event_attr.exclude_callchain_user to 1,
> perf_event_attr.exclude_callchain_kernel to 0.
>
> > +
> > +--user-callchains::
> > +Collect callchains from user space.
>
> And this one to:
> Collect callchains only from user space. I.e. this option sets
>
> perf_event_attr.exclude_callchain_kernel to 1,
> perf_event_attr.exclude_callchain_user to 0.
Yeah, each of this options just sets the exclude bit for the undesired
callchains, not setting 0 for the desired, so I'm fixing up the doc I
suggested accordingly, my comment below remains valid tho:
>
> So that the user don't try using:
>
> pref record --user-callchains --kernel-callchains
>
> expecting to get both user and kernel callchains and instead gets
> nothing.
>
> Ok?
>
> - Arnaldo
>
> > +
> > --timestamp-filename
> > Append timestamp to output file name.
> >
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index e2c3a585a61e..dca55997934e 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -2191,6 +2191,10 @@ static struct option __record_options[] = {
> > OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
> > "Configure all used events to run in user space.",
> > PARSE_OPT_EXCLUSIVE),
> > + OPT_BOOLEAN(0, "kernel-callchains", &record.opts.kernel_callchains,
> > + "collect kernel callchains"),
> > + OPT_BOOLEAN(0, "user-callchains", &record.opts.user_callchains,
> > + "collect user callchains"),
> > OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
> > "clang binary to use for compiling BPF scriptlets"),
> > OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> > diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> > index d59dee61b64d..711e009381ec 100644
> > --- a/tools/perf/perf.h
> > +++ b/tools/perf/perf.h
> > @@ -61,6 +61,8 @@ struct record_opts {
> > bool record_switch_events;
> > bool all_kernel;
> > bool all_user;
> > + bool kernel_callchains;
> > + bool user_callchains;
> > bool tail_synthesize;
> > bool overwrite;
> > bool ignore_missing_thread;
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index a6f572a40deb..a606b2833e27 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -680,6 +680,10 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
> >
> > attr->sample_max_stack = param->max_stack;
> >
> > + if (opts->kernel_callchains)
> > + attr->exclude_callchain_user = 1;
> > + if (opts->user_callchains)
> > + attr->exclude_callchain_kernel = 1;
> > if (param->record_mode == CALLCHAIN_LBR) {
> > if (!opts->branch_stack) {
> > if (attr->exclude_user) {
> > --
> > 2.14.1
>
> --
>
> - Arnaldo
--
- Arnaldo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-06-06 14:26 ` Arnaldo Carvalho de Melo
2019-06-06 14:29 ` Arnaldo Carvalho de Melo
@ 2019-06-06 14:46 ` Jiri Olsa
2019-06-06 18:15 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2019-06-06 14:46 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: ufo19890607, peterz, mingo, alexander.shishkin, jolsa, dsahern,
namhyung, milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter,
wangnan0, linux-perf-users, linux-kernel, acme
On Thu, Jun 06, 2019 at 11:26:44AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 30, 2019 at 02:29:22PM +0100, ufo19890607 escreveu:
> > From: yuzhoujian <yuzhoujian@didichuxing.com>
> >
> > One can just record callchains in the kernel or user space with
> > this new options. We can use it together with "--all-kernel" options.
> > This two options is used just like print_stack(sys) or print_ustack(usr)
> > for systemtap.
> >
> > Show below is the usage of this new option combined with "--all-kernel"
> > options.
> > 1. Configure all used events to run in kernel space and just
> > collect kernel callchains.
> > $ perf record -a -g --all-kernel --kernel-callchains
> > 2. Configure all used events to run in kernel space and just
> > collect user callchains.
> > $ perf record -a -g --all-kernel --user-callchains
> >
> > Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> > ---
> > tools/perf/Documentation/perf-record.txt | 6 ++++++
> > tools/perf/builtin-record.c | 4 ++++
> > tools/perf/perf.h | 2 ++
> > tools/perf/util/evsel.c | 4 ++++
> > 4 files changed, 16 insertions(+)
> >
> > diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> > index de269430720a..b647eb3db0c6 100644
> > --- a/tools/perf/Documentation/perf-record.txt
> > +++ b/tools/perf/Documentation/perf-record.txt
> > @@ -490,6 +490,12 @@ Configure all used events to run in kernel space.
> > --all-user::
> > Configure all used events to run in user space.
> >
> > +--kernel-callchains::
> > +Collect callchains from kernel space.
>
> Ok, changing this to:
>
> Collect callchains only from kernel space. I.e. this option sets
> perf_event_attr.exclude_callchain_user to 1,
> perf_event_attr.exclude_callchain_kernel to 0.
>
> > +
> > +--user-callchains::
> > +Collect callchains from user space.
>
> And this one to:
> Collect callchains only from user space. I.e. this option sets
>
> perf_event_attr.exclude_callchain_kernel to 1,
> perf_event_attr.exclude_callchain_user to 0.
>
>
> So that the user don't try using:
>
> pref record --user-callchains --kernel-callchains
>
> expecting to get both user and kernel callchains and instead gets
> nothing.
good catch.. we should add the logic to keep both (default)
in this case.. so do nothing ;-)
jirka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-06-06 14:46 ` Jiri Olsa
@ 2019-06-06 18:15 ` Arnaldo Carvalho de Melo
2019-06-10 7:45 ` 禹舟键
0 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-06-06 18:15 UTC (permalink / raw)
To: Jiri Olsa
Cc: ufo19890607, peterz, mingo, alexander.shishkin, jolsa, dsahern,
namhyung, milian.wolff, arnaldo.melo, yuzhoujian, adrian.hunter,
wangnan0, linux-perf-users, linux-kernel, acme
Em Thu, Jun 06, 2019 at 04:46:14PM +0200, Jiri Olsa escreveu:
> On Thu, Jun 06, 2019 at 11:26:44AM -0300, Arnaldo Carvalho de Melo wrote:
> > So that the user don't try using:
> > pref record --user-callchains --kernel-callchains
> > expecting to get both user and kernel callchains and instead gets
> > nothing.
> good catch.. we should add the logic to keep both (default)
> in this case.. so do nothing ;-)
Yeah, not using both or using both should amount to the same behaviour.
Can be done with a patch on top of what I have in my tree now.
- Arnaldo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] perf record: Add support to collect callchains from kernel or user space only.
2019-06-06 18:15 ` Arnaldo Carvalho de Melo
@ 2019-06-10 7:45 ` 禹舟键
0 siblings, 0 replies; 8+ messages in thread
From: 禹舟键 @ 2019-06-10 7:45 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
Jiri Olsa, David Ahern, Namhyung Kim, Milian Wolff, Wind Yu,
Adrian Hunter, Wang Nan, linux-perf-users, linux-kernel, acme
Hi Arnaldo, Jirka
> perf_event_attr.exclude_callchain_kernel to 0
I don't think we should set 0 for the desired callchins, because we
will set exclude_callchain_user to 1 if perf_evsel is function event.
void perf_evsel__config(struct perf_evsel *evsel, struct record_opts
*opts, struct callchain_param *callchain)
{
...
if (perf_evsel__is_function_event(evsel))
evsel->attr.exclude_callchain_user = 1;
if (callchain && callchain->enabled && !evsel->no_aux_samples)
perf_evsel__config_callchain(evsel, opts, callchain);
}
If we set exclude_callchain_user to 0 , it will catch user callchain
for function_event. So, it will be best to just set the
exclude_callchain_xxx to 1.
> So that the user don't try using:
> perf record --user-callchains --kernel-callchains
> expecting to get both user and kernel callchains and instead gets
> nothing.
I will add a note in the doc.
Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> 于2019年6月7日周五 上午2:15写道:
>
> Em Thu, Jun 06, 2019 at 04:46:14PM +0200, Jiri Olsa escreveu:
> > On Thu, Jun 06, 2019 at 11:26:44AM -0300, Arnaldo Carvalho de Melo wrote:
> > > So that the user don't try using:
>
> > > pref record --user-callchains --kernel-callchains
>
> > > expecting to get both user and kernel callchains and instead gets
> > > nothing.
>
> > good catch.. we should add the logic to keep both (default)
> > in this case.. so do nothing ;-)
>
> Yeah, not using both or using both should amount to the same behaviour.
>
> Can be done with a patch on top of what I have in my tree now.
>
> - Arnaldo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-06-10 7:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 13:29 [PATCH] perf record: Add support to collect callchains from kernel or user space only ufo19890607
2019-06-06 6:05 ` 禹舟键
2019-06-06 7:25 ` Jiri Olsa
2019-06-06 14:26 ` Arnaldo Carvalho de Melo
2019-06-06 14:29 ` Arnaldo Carvalho de Melo
2019-06-06 14:46 ` Jiri Olsa
2019-06-06 18:15 ` Arnaldo Carvalho de Melo
2019-06-10 7:45 ` 禹舟键
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox