Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1253501 > unrolled thread
| Started by | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| First post | 2015-10-22 08:30 +0200 |
| Last post | 2015-10-23 10:40 +0200 |
| Articles | 7 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/3] perf top: Support call-graph display options also Namhyung Kim <namhyung@kernel.org> - 2015-10-22 08:30 +0200
Re: [PATCH 2/3] perf top: Support call-graph display options also Ingo Molnar <mingo@kernel.org> - 2015-10-22 10:30 +0200
Re: [PATCH 2/3] perf top: Support call-graph display options also Namhyung Kim <namhyung@kernel.org> - 2015-10-22 14:30 +0200
Re: [PATCH 2/3] perf top: Support call-graph display options also Taeung Song <treeze.taeung@gmail.com> - 2015-10-22 16:00 +0200
Re: [PATCH 2/3] perf top: Support call-graph display options also Namhyung Kim <namhyung@kernel.org> - 2015-10-22 16:40 +0200
Re: [PATCH 2/3] perf top: Support call-graph display options also Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-22 20:40 +0200
[tip:perf/core] perf top: Support call-graph display options also tip-bot for Namhyung Kim <tipbot@zytor.com> - 2015-10-23 10:40 +0200
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2015-10-22 08:30 +0200 |
| Subject | [PATCH 2/3] perf top: Support call-graph display options also |
| Message-ID | <qmhxU-2nM-5@gated-at.bofh.it> |
Currently 'perf top --call-graph' option is same as 'perf record'. But
'perf top' also need to receive display options in 'perf report'. To do
that, change parse_callchain_report_opt() to allow record options too.
Now perf top can receive display options like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph
<mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]>
setup and enables call-graph (stack chain/backtrace)
recording: fp dwarf lbr, output_type (graph, flat,
fractal, or none), min percent threshold, optional
print limit, callchain order, key (function or
address), add branches
$ perf top --call-graph callee,graph,fp
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-top.txt | 5 +++--
tools/perf/builtin-top.c | 26 ++++++++++++++++++-----
tools/perf/util/callchain.c | 40 ++++++++++++++++++++++++++++++++---
tools/perf/util/callchain.h | 1 +
4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index f6a23eb294e7..556cec09bf50 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -160,9 +160,10 @@ Default is to monitor all CPUS.
-g::
Enables call-graph (stack chain/backtrace) recording.
---call-graph::
+--call-graph [mode,type,min[,limit],order[,key][,branch]]::
Setup and enable call-graph (stack chain/backtrace) recording,
- implies -g.
+ implies -g. See `--call-graph` section in perf-record and
+ perf-report man pages for details.
--children::
Accumulate callchain of children to parent entry so that then can
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6f641fd68296..1de381d3f29f 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1053,8 +1053,22 @@ callchain_opt(const struct option *opt, const char *arg, int unset)
static int
parse_callchain_opt(const struct option *opt, const char *arg, int unset)
{
- symbol_conf.use_callchain = true;
- return record_parse_callchain_opt(opt, arg, unset);
+ struct record_opts *record = (struct record_opts *)opt->value;
+
+ record->callgraph_set = true;
+ callchain_param.enabled = !unset;
+ callchain_param.record_mode = CALLCHAIN_FP;
+
+ /*
+ * --no-call-graph
+ */
+ if (unset) {
+ symbol_conf.use_callchain = false;
+ callchain_param.record_mode = CALLCHAIN_NONE;
+ return 0;
+ }
+
+ return parse_callchain_top_opt(arg);
}
static int perf_top_config(const char *var, const char *value, void *cb)
@@ -1079,6 +1093,8 @@ parse_percent_limit(const struct option *opt, const char *arg,
return 0;
}
+const char top_callchain_help[] = CALLCHAIN_RECORD_HELP ", " CALLCHAIN_REPORT_HELP;
+
int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
{
char errbuf[BUFSIZ];
@@ -1154,11 +1170,11 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
- NULL, "enables call-graph recording",
+ NULL, "enables call-graph recording and display",
&callchain_opt),
OPT_CALLBACK(0, "call-graph", &top.record_opts,
- "mode[,dump_size]", record_callchain_help,
- &parse_callchain_opt),
+ "mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]",
+ top_callchain_help, &parse_callchain_opt),
OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
"Accumulate callchains of children and show total overhead as well"),
OPT_INTEGER(0, "max-stack", &top.max_stack,
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 773fe13ce627..842be32899ee 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -77,12 +77,14 @@ static int parse_callchain_sort_key(const char *value)
return -1;
}
-int
-parse_callchain_report_opt(const char *arg)
+static int
+__parse_callchain_report_opt(const char *arg, bool allow_record_opt)
{
char *tok;
char *endptr;
bool minpcnt_set = false;
+ bool record_opt_set = false;
+ bool try_stack_size = false;
symbol_conf.use_callchain = true;
@@ -100,6 +102,28 @@ parse_callchain_report_opt(const char *arg)
!parse_callchain_order(tok) ||
!parse_callchain_sort_key(tok)) {
/* parsing ok - move on to the next */
+ try_stack_size = false;
+ goto next;
+ } else if (allow_record_opt && !record_opt_set) {
+ if (parse_callchain_record(tok, &callchain_param))
+ goto try_numbers;
+
+ /* assume that number followed by 'dwarf' is stack size */
+ if (callchain_param.record_mode == CALLCHAIN_DWARF)
+ try_stack_size = true;
+
+ record_opt_set = true;
+ goto next;
+ }
+
+try_numbers:
+ if (try_stack_size) {
+ unsigned long size = 0;
+
+ if (get_stack_size(tok, &size) < 0)
+ return -1;
+ callchain_param.dump_size = size;
+ try_stack_size = false;
} else if (!minpcnt_set) {
/* try to get the min percent */
callchain_param.min_percent = strtod(tok, &endptr);
@@ -112,7 +136,7 @@ parse_callchain_report_opt(const char *arg)
if (tok == endptr)
return -1;
}
-
+next:
arg = NULL;
}
@@ -123,6 +147,16 @@ parse_callchain_report_opt(const char *arg)
return 0;
}
+int parse_callchain_report_opt(const char *arg)
+{
+ return __parse_callchain_report_opt(arg, false);
+}
+
+int parse_callchain_top_opt(const char *arg)
+{
+ return __parse_callchain_report_opt(arg, true);
+}
+
int perf_callchain_config(const char *var, const char *value)
{
char *endptr;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index c9e3a2e85a72..836d59a001bc 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -192,6 +192,7 @@ extern const char record_callchain_help[];
extern int parse_callchain_record(const char *arg, struct callchain_param *param);
int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
int parse_callchain_report_opt(const char *arg);
+int parse_callchain_top_opt(const char *arg);
int perf_callchain_config(const char *var, const char *value);
static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
--
2.6.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-10-22 10:30 +0200 |
| Message-ID | <qmjq1-59y-3@gated-at.bofh.it> |
| In reply to | #1253501 |
* Namhyung Kim <namhyung@kernel.org> wrote:
> Currently 'perf top --call-graph' option is same as 'perf record'. But
> 'perf top' also need to receive display options in 'perf report'. To do
> that, change parse_callchain_report_opt() to allow record options too.
>
> Now perf top can receive display options like below:
>
> $ perf top --call-graph
> Error: option `call-graph' requires a value
>
> Usage: perf top [<options>]
>
> --call-graph
> <mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]>
> setup and enables call-graph (stack chain/backtrace)
> recording: fp dwarf lbr, output_type (graph, flat,
> fractal, or none), min percent threshold, optional
> print limit, callchain order, key (function or
> address), add branches
Yeah, so this fix is nice, and I think we should also do another patch to fix the
help text output to be the following:
--call-graph
<record_mode[,record_size],print_style,limit[,print_limit],call_order[,sort_key]>
Set up and enable call graph (call chain, stack backtrace) recording:
record_mode: call graph recording mode (fp|dwarf|lbr)
record_size: if rec_mode == dwarf, maximum depth of stack recording (bytes),
default: 8192 bytes.
print_style: call graph printing style (graph|flat|fractal|none)
limit: minimum call graph inclusion threshold (percent)
print_limit: printing threshold (percent)
call_order: call graph order (caller|callee)
sort_key: sorting key (function|address|branch)
Default: fp,graph,0.5,0.0,caller,function
Note that this text evolved a bit over what I sent in my previous mail.
Also note that I think we should sync up the perf config options to be the same as
the option name shortcuts used in this help text.
Side note: to improve perf config usability, we should probably also recognize
underscores in perf config entries, i.e. the following variants should both work:
print_percent = 1
print-percent = 1
Right now only the second one will match.
Thanks,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2015-10-22 14:30 +0200 |
| Message-ID | <qmnai-2ka-7@gated-at.bofh.it> |
| In reply to | #1253573 |
On Thu, Oct 22, 2015 at 5:23 PM, Ingo Molnar <mingo@kernel.org> wrote: > > * Namhyung Kim <namhyung@kernel.org> wrote: > >> Currently 'perf top --call-graph' option is same as 'perf record'. But >> 'perf top' also need to receive display options in 'perf report'. To do >> that, change parse_callchain_report_opt() to allow record options too. >> >> Now perf top can receive display options like below: >> >> $ perf top --call-graph >> Error: option `call-graph' requires a value >> >> Usage: perf top [<options>] >> >> --call-graph >> <mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]> >> setup and enables call-graph (stack chain/backtrace) >> recording: fp dwarf lbr, output_type (graph, flat, >> fractal, or none), min percent threshold, optional >> print limit, callchain order, key (function or >> address), add branches > > Yeah, so this fix is nice, and I think we should also do another patch to fix the > help text output to be the following: > > --call-graph > <record_mode[,record_size],print_style,limit[,print_limit],call_order[,sort_key]> > > Set up and enable call graph (call chain, stack backtrace) recording: > > record_mode: call graph recording mode (fp|dwarf|lbr) > record_size: if rec_mode == dwarf, maximum depth of stack recording (bytes), > default: 8192 bytes. > print_style: call graph printing style (graph|flat|fractal|none) > limit: minimum call graph inclusion threshold (percent) > print_limit: printing threshold (percent) > call_order: call graph order (caller|callee) > sort_key: sorting key (function|address|branch) > > Default: fp,graph,0.5,0.0,caller,function > > Note that this text evolved a bit over what I sent in my previous mail. OK. I'll cook a patch to improve help message like this as well as man page. > > Also note that I think we should sync up the perf config options to be the same as > the option name shortcuts used in this help text. Ah, good idea. > > Side note: to improve perf config usability, we should probably also recognize > underscores in perf config entries, i.e. the following variants should both work: > > print_percent = 1 > print-percent = 1 > > Right now only the second one will match. Taeung, could you consider fixing this in your config patchset? Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Taeung Song <treeze.taeung@gmail.com> |
|---|---|
| Date | 2015-10-22 16:00 +0200 |
| Message-ID | <qmozo-4eU-11@gated-at.bofh.it> |
| In reply to | #1253758 |
Hi, Namhyung and Ingo > On Oct 22, 2015, at 9:20 PM, Namhyung Kim <namhyung@kernel.org> wrote: > > On Thu, Oct 22, 2015 at 5:23 PM, Ingo Molnar <mingo@kernel.org> wrote: >> >> * Namhyung Kim <namhyung@kernel.org> wrote: >> >>> Currently 'perf top --call-graph' option is same as 'perf record'. But >>> 'perf top' also need to receive display options in 'perf report'. To do >>> that, change parse_callchain_report_opt() to allow record options too. >>> >>> Now perf top can receive display options like below: >>> >>> $ perf top --call-graph >>> Error: option `call-graph' requires a value >>> >>> Usage: perf top [<options>] >>> >>> --call-graph >>> <mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]> >>> setup and enables call-graph (stack chain/backtrace) >>> recording: fp dwarf lbr, output_type (graph, flat, >>> fractal, or none), min percent threshold, optional >>> print limit, callchain order, key (function or >>> address), add branches >> >> Yeah, so this fix is nice, and I think we should also do another patch to fix the >> help text output to be the following: >> >> --call-graph >> <record_mode[,record_size],print_style,limit[,print_limit],call_order[,sort_key]> >> >> Set up and enable call graph (call chain, stack backtrace) recording: >> >> record_mode: call graph recording mode (fp|dwarf|lbr) >> record_size: if rec_mode == dwarf, maximum depth of stack recording (bytes), >> default: 8192 bytes. >> print_style: call graph printing style (graph|flat|fractal|none) >> limit: minimum call graph inclusion threshold (percent) >> print_limit: printing threshold (percent) >> call_order: call graph order (caller|callee) >> sort_key: sorting key (function|address|branch) >> >> Default: fp,graph,0.5,0.0,caller,function >> >> Note that this text evolved a bit over what I sent in my previous mail. > > OK. I'll cook a patch to improve help message like this as well as man page. > > >> >> Also note that I think we should sync up the perf config options to be the same as >> the option name shortcuts used in this help text. > > Ah, good idea. > >> >> Side note: to improve perf config usability, we should probably also recognize >> underscores in perf config entries, i.e. the following variants should both work: >> >> print_percent = 1 >> print-percent = 1 >> >> Right now only the second one will match. > > Taeung, could you consider fixing this in your config patchiest? > Sure, no problem. I thought as below. Even if one use a print_percent variable, it will be handled like print-percent. Also if a user change print_percent variable by perf-config command, print-percent variable will remain in perfconfig file. (Because perf-config command will rewrite perfconfig file.) Is anything wrong ? Thanks, Taeung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Date | 2015-10-22 16:40 +0200 |
| Message-ID | <qmpc6-5kr-19@gated-at.bofh.it> |
| In reply to | #1253834 |
On Thu, Oct 22, 2015 at 10:57 PM, Taeung Song <treeze.taeung@gmail.com> wrote: > Hi, Namhyung and Ingo > >> On Oct 22, 2015, at 9:20 PM, Namhyung Kim <namhyung@kernel.org> wrote: >> >> On Thu, Oct 22, 2015 at 5:23 PM, Ingo Molnar <mingo@kernel.org> wrote: >>> >>> * Namhyung Kim <namhyung@kernel.org> wrote: >>> >>>> Currently 'perf top --call-graph' option is same as 'perf record'. But >>>> 'perf top' also need to receive display options in 'perf report'. To do >>>> that, change parse_callchain_report_opt() to allow record options too. >>>> >>>> Now perf top can receive display options like below: >>>> >>>> $ perf top --call-graph >>>> Error: option `call-graph' requires a value >>>> >>>> Usage: perf top [<options>] >>>> >>>> --call-graph >>>> <mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]> >>>> setup and enables call-graph (stack chain/backtrace) >>>> recording: fp dwarf lbr, output_type (graph, flat, >>>> fractal, or none), min percent threshold, optional >>>> print limit, callchain order, key (function or >>>> address), add branches >>> >>> Yeah, so this fix is nice, and I think we should also do another patch to fix the >>> help text output to be the following: >>> >>> --call-graph >>> <record_mode[,record_size],print_style,limit[,print_limit],call_order[,sort_key]> >>> >>> Set up and enable call graph (call chain, stack backtrace) recording: >>> >>> record_mode: call graph recording mode (fp|dwarf|lbr) >>> record_size: if rec_mode == dwarf, maximum depth of stack recording (bytes), >>> default: 8192 bytes. >>> print_style: call graph printing style (graph|flat|fractal|none) >>> limit: minimum call graph inclusion threshold (percent) >>> print_limit: printing threshold (percent) >>> call_order: call graph order (caller|callee) >>> sort_key: sorting key (function|address|branch) >>> >>> Default: fp,graph,0.5,0.0,caller,function >>> >>> Note that this text evolved a bit over what I sent in my previous mail. >> >> OK. I'll cook a patch to improve help message like this as well as man page. >> >> >>> >>> Also note that I think we should sync up the perf config options to be the same as >>> the option name shortcuts used in this help text. >> >> Ah, good idea. >> >>> >>> Side note: to improve perf config usability, we should probably also recognize >>> underscores in perf config entries, i.e. the following variants should both work: >>> >>> print_percent = 1 >>> print-percent = 1 >>> >>> Right now only the second one will match. >> >> Taeung, could you consider fixing this in your config patchiest? >> > > Sure, no problem. > > I thought as below. > Even if one use a print_percent variable, it will be handled like print-percent. > > Also if a user change print_percent variable by perf-config command, > print-percent variable will remain in perfconfig file. > (Because perf-config command will rewrite perfconfig file.) > > Is anything wrong ? Nop, looks good to me! Thanks, Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-10-22 20:40 +0200 |
| Message-ID | <qmsWm-2kA-15@gated-at.bofh.it> |
| In reply to | #1253501 |
Em Thu, Oct 22, 2015 at 03:28:49PM +0900, Namhyung Kim escreveu: > Currently 'perf top --call-graph' option is same as 'perf record'. But > 'perf top' also need to receive display options in 'perf report'. To do > that, change parse_callchain_report_opt() to allow record options too. > > Now perf top can receive display options like below: Applied. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Namhyung Kim <tipbot@zytor.com> |
|---|---|
| Date | 2015-10-23 10:40 +0200 |
| Subject | [tip:perf/core] perf top: Support call-graph display options also |
| Message-ID | <qmG3h-4qs-37@gated-at.bofh.it> |
| In reply to | #1253501 |
Commit-ID: a2c10d39af49b00514f7cc7b750757fcc2174f0c
Gitweb: http://git.kernel.org/tip/a2c10d39af49b00514f7cc7b750757fcc2174f0c
Author: Namhyung Kim <namhyung@kernel.org>
AuthorDate: Thu, 22 Oct 2015 15:28:49 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 22 Oct 2015 15:40:02 -0300
perf top: Support call-graph display options also
Currently 'perf top --call-graph' option is same as 'perf record'. But
'perf top' also need to receive display options in 'perf report'. To do
that, change parse_callchain_report_opt() to allow record options too.
Now perf top can receive display options like below:
$ perf top --call-graph
Error: option `call-graph' requires a value
Usage: perf top [<options>]
--call-graph
<mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]>
setup and enables call-graph (stack chain/backtrace)
recording: fp dwarf lbr, output_type (graph, flat,
fractal, or none), min percent threshold, optional
print limit, callchain order, key (function or
address), add branches
$ perf top --call-graph callee,graph,fp
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Chandler Carruth <chandlerc@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1445495330-25416-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-top.txt | 5 +++--
tools/perf/builtin-top.c | 26 ++++++++++++++++++-----
tools/perf/util/callchain.c | 40 ++++++++++++++++++++++++++++++++---
tools/perf/util/callchain.h | 1 +
4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index f6a23eb..556cec0 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -160,9 +160,10 @@ Default is to monitor all CPUS.
-g::
Enables call-graph (stack chain/backtrace) recording.
---call-graph::
+--call-graph [mode,type,min[,limit],order[,key][,branch]]::
Setup and enable call-graph (stack chain/backtrace) recording,
- implies -g.
+ implies -g. See `--call-graph` section in perf-record and
+ perf-report man pages for details.
--children::
Accumulate callchain of children to parent entry so that then can
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6f641fd..1de381d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1053,8 +1053,22 @@ callchain_opt(const struct option *opt, const char *arg, int unset)
static int
parse_callchain_opt(const struct option *opt, const char *arg, int unset)
{
- symbol_conf.use_callchain = true;
- return record_parse_callchain_opt(opt, arg, unset);
+ struct record_opts *record = (struct record_opts *)opt->value;
+
+ record->callgraph_set = true;
+ callchain_param.enabled = !unset;
+ callchain_param.record_mode = CALLCHAIN_FP;
+
+ /*
+ * --no-call-graph
+ */
+ if (unset) {
+ symbol_conf.use_callchain = false;
+ callchain_param.record_mode = CALLCHAIN_NONE;
+ return 0;
+ }
+
+ return parse_callchain_top_opt(arg);
}
static int perf_top_config(const char *var, const char *value, void *cb)
@@ -1079,6 +1093,8 @@ parse_percent_limit(const struct option *opt, const char *arg,
return 0;
}
+const char top_callchain_help[] = CALLCHAIN_RECORD_HELP ", " CALLCHAIN_REPORT_HELP;
+
int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
{
char errbuf[BUFSIZ];
@@ -1154,11 +1170,11 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
- NULL, "enables call-graph recording",
+ NULL, "enables call-graph recording and display",
&callchain_opt),
OPT_CALLBACK(0, "call-graph", &top.record_opts,
- "mode[,dump_size]", record_callchain_help,
- &parse_callchain_opt),
+ "mode[,dump_size],output_type,min_percent[,print_limit],call_order[,branch]",
+ top_callchain_help, &parse_callchain_opt),
OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
"Accumulate callchains of children and show total overhead as well"),
OPT_INTEGER(0, "max-stack", &top.max_stack,
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 773fe13..842be32 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -77,12 +77,14 @@ static int parse_callchain_sort_key(const char *value)
return -1;
}
-int
-parse_callchain_report_opt(const char *arg)
+static int
+__parse_callchain_report_opt(const char *arg, bool allow_record_opt)
{
char *tok;
char *endptr;
bool minpcnt_set = false;
+ bool record_opt_set = false;
+ bool try_stack_size = false;
symbol_conf.use_callchain = true;
@@ -100,6 +102,28 @@ parse_callchain_report_opt(const char *arg)
!parse_callchain_order(tok) ||
!parse_callchain_sort_key(tok)) {
/* parsing ok - move on to the next */
+ try_stack_size = false;
+ goto next;
+ } else if (allow_record_opt && !record_opt_set) {
+ if (parse_callchain_record(tok, &callchain_param))
+ goto try_numbers;
+
+ /* assume that number followed by 'dwarf' is stack size */
+ if (callchain_param.record_mode == CALLCHAIN_DWARF)
+ try_stack_size = true;
+
+ record_opt_set = true;
+ goto next;
+ }
+
+try_numbers:
+ if (try_stack_size) {
+ unsigned long size = 0;
+
+ if (get_stack_size(tok, &size) < 0)
+ return -1;
+ callchain_param.dump_size = size;
+ try_stack_size = false;
} else if (!minpcnt_set) {
/* try to get the min percent */
callchain_param.min_percent = strtod(tok, &endptr);
@@ -112,7 +136,7 @@ parse_callchain_report_opt(const char *arg)
if (tok == endptr)
return -1;
}
-
+next:
arg = NULL;
}
@@ -123,6 +147,16 @@ parse_callchain_report_opt(const char *arg)
return 0;
}
+int parse_callchain_report_opt(const char *arg)
+{
+ return __parse_callchain_report_opt(arg, false);
+}
+
+int parse_callchain_top_opt(const char *arg)
+{
+ return __parse_callchain_report_opt(arg, true);
+}
+
int perf_callchain_config(const char *var, const char *value)
{
char *endptr;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index c9e3a2e..836d59a 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -192,6 +192,7 @@ extern const char record_callchain_help[];
extern int parse_callchain_record(const char *arg, struct callchain_param *param);
int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
int parse_callchain_report_opt(const char *arg);
+int parse_callchain_top_opt(const char *arg);
int perf_callchain_config(const char *var, const char *value);
static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web