2018-03-12 11:38:28

by Yisheng Xie

[permalink] [raw]
Subject: [PATCH 1/2] perf top: Fix top.call-graph works abnormal

When try to add call-graph for top into .perfconfig file, like:

[top]
call-graph = fp

find it cannot work for perf_top_config() do not parse this option.

Fix it by call perf_default_config() when config top.call-graph.

Fixes: b8cbb349061e (perf config: Bring perf_default_config to the very beginning at main())
Signed-off-by: Yisheng Xie <[email protected]>
---
tools/perf/builtin-top.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 35ac016..fd6e238 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1224,8 +1224,10 @@ static int __cmd_top(struct perf_top *top)

static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
{
- if (!strcmp(var, "top.call-graph"))
- var = "call-graph.record-mode"; /* fall-through */
+ if (!strcmp(var, "top.call-graph")) {
+ var = "call-graph.record-mode";
+ return perf_default_config(var, value, cb);
+ }
if (!strcmp(var, "top.children")) {
symbol_conf.cumulate_callchain = perf_config_bool(var, value);
return 0;
--
1.7.12.4



2018-03-12 11:37:08

by Yisheng Xie

[permalink] [raw]
Subject: [PATCH 2/2] perf record: Avoid duplicate call of perf_default_config()

We have brought perf_default_config to the very beginning at main(), so
it no need to call perf_default_config() once more for most of config in
perf-record but only for record.call-graph.

Signed-off-by: Yisheng Xie <[email protected]>
---
tools/perf/builtin-record.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a217623..811cfc1 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1260,10 +1260,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
return -1;
return 0;
}
- if (!strcmp(var, "record.call-graph"))
- var = "call-graph.record-mode"; /* fall-through */
+ if (!strcmp(var, "record.call-graph")) {
+ var = "call-graph.record-mode";
+ return perf_default_config(var, value, cb);
+ }

- return perf_default_config(var, value, cb);
+ return 0;
}

struct clockid_map {
--
1.7.12.4


2018-03-12 14:09:06

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/2] perf record: Avoid duplicate call of perf_default_config()

Em Mon, Mar 12, 2018 at 07:25:57PM +0800, Yisheng Xie escreveu:
> We have brought perf_default_config to the very beginning at main(), so
> it no need to call perf_default_config() once more for most of config in
> perf-record but only for record.call-graph.

Thanks, applied.

> Signed-off-by: Yisheng Xie <[email protected]>
> ---
> tools/perf/builtin-record.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index a217623..811cfc1 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1260,10 +1260,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
> return -1;
> return 0;
> }
> - if (!strcmp(var, "record.call-graph"))
> - var = "call-graph.record-mode"; /* fall-through */
> + if (!strcmp(var, "record.call-graph")) {
> + var = "call-graph.record-mode";
> + return perf_default_config(var, value, cb);
> + }
>
> - return perf_default_config(var, value, cb);
> + return 0;
> }
>
> struct clockid_map {
> --
> 1.7.12.4

2018-03-12 14:13:38

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 1/2] perf top: Fix top.call-graph works abnormal

Em Mon, Mar 12, 2018 at 07:25:56PM +0800, Yisheng Xie escreveu:
> When try to add call-graph for top into .perfconfig file, like:
>
> [top]
> call-graph = fp
>
> find it cannot work for perf_top_config() do not parse this option.

Thanks, applied.

- Arnaldo

Subject: [tip:perf/core] perf record: Avoid duplicate call of perf_default_config()

Commit-ID: cff17205d6bd363703034510a84d66044aff176e
Gitweb: https://git.kernel.org/tip/cff17205d6bd363703034510a84d66044aff176e
Author: Yisheng Xie <[email protected]>
AuthorDate: Mon, 12 Mar 2018 19:25:57 +0800
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 16 Mar 2018 13:55:58 -0300

perf record: Avoid duplicate call of perf_default_config()

We have brought perf_default_config to the very beginning at main(), so
it no need to call perf_default_config() once more for most of config in
perf-record but only for record.call-graph.

Signed-off-by: Yisheng Xie <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-record.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b81494587120..d33103291b02 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1279,10 +1279,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
return -1;
return 0;
}
- if (!strcmp(var, "record.call-graph"))
- var = "call-graph.record-mode"; /* fall-through */
+ if (!strcmp(var, "record.call-graph")) {
+ var = "call-graph.record-mode";
+ return perf_default_config(var, value, cb);
+ }

- return perf_default_config(var, value, cb);
+ return 0;
}

struct clockid_map {

Subject: [tip:perf/core] perf top: Fix top.call-graph config option reading

Commit-ID: a3a4a3b37c9b911af4c375b2475cea0fd2b84d38
Gitweb: https://git.kernel.org/tip/a3a4a3b37c9b911af4c375b2475cea0fd2b84d38
Author: Yisheng Xie <[email protected]>
AuthorDate: Mon, 12 Mar 2018 19:25:56 +0800
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 16 Mar 2018 13:56:04 -0300

perf top: Fix top.call-graph config option reading

When trying to add the "call-graph" variable for top into the
.perfconfig file, like:

[top]
call-graph = fp

I that perf_top_config() do not parse this variable.

Fix it by calling perf_default_config() when the top.call-graph variable
is set.

Signed-off-by: Yisheng Xie <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Fixes: b8cbb349061e ("perf config: Bring perf_default_config to the very beginning at main()")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-top.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0a26b56afcc5..113c298ed38b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1223,8 +1223,10 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)

static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
{
- if (!strcmp(var, "top.call-graph"))
- var = "call-graph.record-mode"; /* fall-through */
+ if (!strcmp(var, "top.call-graph")) {
+ var = "call-graph.record-mode";
+ return perf_default_config(var, value, cb);
+ }
if (!strcmp(var, "top.children")) {
symbol_conf.cumulate_callchain = perf_config_bool(var, value);
return 0;