* [PATCHv2 0/3] perf tools: Fix -g option handling
@ 2013-11-01 15:23 Jiri Olsa
2013-11-01 15:23 ` [PATCH 1/3] perf tools: Add call-graph option support into .perfconfig Jiri Olsa
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-11-01 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: Corey Ashford, David Ahern, Ingo Molnar, Namhyung Kim,
Paul Mackerras, Peter Zijlstra, Arnaldo Carvalho de Melo,
Andi Kleen, Adrian Hunter
hi,
changing the '-g/-G' options for record/top commands
to take NO argument and enable unwind method based
on .perfconfig setup (using FP by default).
The current -g option parsing moves into the
'--call-graph' option.
Examples:
$ cat ~/.perfconfig:
[top]
call-graph = fp
[record]
call-graph = dwarf,8192
$ perf record -g ls
- enables dwarf unwind with user stack size dump 8192 bytes
$ perf top -G
- enables frame pointer unwind
$ perf record --call-graph=fp ls
- enables frame pointer unwind
$ perf top --call-graph=dwarf,4096 ls
- enables dwarf unwind with user stack size dump 4096 bytes
v2 changes:
- added -L as short option for call-graph for record/top commands
- updated documentation
- based on latest acme's perf/urgent
thanks,
jirka
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
Jiri Olsa (3):
perf tools: Add call-graph option support into .perfconfig
perf tools: Add readable output for callchain debug
perf tools: Add -L as short option for call-graph for record/top commands
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/Documentation/perf-top.txt | 9 +++++++++
tools/perf/builtin-record.c | 22 ++++++++++++++++++++--
tools/perf/builtin-top.c | 14 +++++++++++++-
tools/perf/perf.h | 4 +++-
tools/perf/util/evsel.c | 2 +-
6 files changed, 52 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] perf tools: Add call-graph option support into .perfconfig
2013-11-01 15:23 [PATCHv2 0/3] perf tools: Fix -g option handling Jiri Olsa
@ 2013-11-01 15:23 ` Jiri Olsa
2013-11-01 15:23 ` [PATCH 2/3] perf tools: Add readable output for callchain debug Jiri Olsa
2013-11-01 15:23 ` [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands Jiri Olsa
2 siblings, 0 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-11-01 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Corey Ashford, David Ahern, Ingo Molnar, Namhyung Kim,
Paul Mackerras, Peter Zijlstra, Arnaldo Carvalho de Melo,
Andi Kleen, Adrian Hunter
Adding call-graph option support into .perfconfig file,
so it's now possible use call-graph option like:
[top]
call-graph = fp
[record]
call-graph = dwarf,8192
Above options ONLY setup the unwind method. To enable
perf record/top to actually use it the command line
option -g/-G must be specified.
The --call-graph option overloads .perfconfig setup.
Assuming above configuration:
$ perf record -g ls
- enables dwarf unwind with user stack size dump 8192 bytes
$ perf top -G
- enables frame pointer unwind
$ perf record --call-graph=fp ls
- enables frame pointer unwind
$ perf top --call-graph=dwarf,4096 ls
- enables dwarf unwind with user stack size dump 4096 bytes
v2 changes:
- Documentation updated
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/Documentation/perf-record.txt | 5 +++++
tools/perf/Documentation/perf-top.txt | 8 ++++++++
tools/perf/builtin-record.c | 16 ++++++++++++++++
tools/perf/builtin-top.c | 12 ++++++++++++
tools/perf/perf.h | 1 +
tools/perf/util/evsel.c | 2 +-
6 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index ca0d3d9..22ccd63 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -105,6 +105,11 @@ OPTIONS
call graphs, using "dwarf", if available (perf tools linked to
the libunwind library) should be used instead.
+ It's possible to use 'call-grap' option as .perfconfig
+ entry, like:
+ [record]
+ call-graph = dwarf,8192
+
-q::
--quiet::
Don't print any message, useful for scripting.
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 6a118e7..456fd65 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -147,6 +147,14 @@ Default is to monitor all CPUS.
Setup and enable call-graph (stack chain/backtrace) recording,
implies -G.
+ Please check other 'call-graph' option DWARF details in
+ perf-record man page.
+
+ It's possible to use 'call-grap' option as .perfconfig
+ entry, like:
+ [top]
+ call-graph = dwarf,8192
+
--ignore-callees=<regex>::
Ignore callees of the function(s) matching the given regex.
This has the effect of collecting the callers of each such
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d046514..2d00a19 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -784,6 +784,8 @@ int record_parse_callchain_opt(const struct option *opt,
struct perf_record_opts *opts = opt->value;
int ret;
+ opts->call_graph_enabled = !unset;
+
/* --no-call-graph */
if (unset) {
opts->call_graph = CALLCHAIN_NONE;
@@ -804,6 +806,8 @@ int record_callchain_opt(const struct option *opt,
{
struct perf_record_opts *opts = opt->value;
+ opts->call_graph_enabled = !unset;
+
if (opts->call_graph == CALLCHAIN_NONE)
opts->call_graph = CALLCHAIN_FP;
@@ -811,6 +815,16 @@ int record_callchain_opt(const struct option *opt,
return 0;
}
+static int perf_record_config(const char *var, const char *value, void *cb)
+{
+ struct perf_record *rec = cb;
+
+ if (!strcmp(var, "record.call-graph"))
+ return record_parse_callchain(value, &rec->opts);
+
+ return perf_default_config(var, value, cb);
+}
+
static const char * const record_usage[] = {
"perf record [<options>] [<command>]",
"perf record [<options>] -- <command> [<options>]",
@@ -936,6 +950,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
rec->evlist = evsel_list;
+ perf_config(perf_record_config, rec);
+
argc = parse_options(argc, argv, record_options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && perf_target__none(&rec->opts.target))
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5a11f13..e1671b1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1031,6 +1031,16 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
return record_parse_callchain_opt(opt, arg, unset);
}
+static int perf_top_config(const char *var, const char *value, void *cb)
+{
+ struct perf_top *top = cb;
+
+ if (!strcmp(var, "top.call-graph"))
+ return record_parse_callchain(value, &top->record_opts);
+
+ return perf_default_config(var, value, cb);
+}
+
static int
parse_percent_limit(const struct option *opt, const char *arg,
int unset __maybe_unused)
@@ -1147,6 +1157,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
if (top.evlist == NULL)
return -ENOMEM;
+ perf_config(perf_top_config, &top);
+
argc = parse_options(argc, argv, options, top_usage, 0);
if (argc)
usage_with_options(top_usage, options);
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index cf20187..27223fb 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -213,6 +213,7 @@ enum perf_call_graph_mode {
struct perf_record_opts {
struct perf_target target;
int call_graph;
+ bool call_graph_enabled;
bool group;
bool inherit_stat;
bool no_delay;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 9f1ef9b..349de75 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -633,7 +633,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
attr->mmap_data = track;
}
- if (opts->call_graph) {
+ if (opts->call_graph_enabled) {
perf_evsel__set_sample_bit(evsel, CALLCHAIN);
if (opts->call_graph == CALLCHAIN_DWARF) {
--
1.7.11.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] perf tools: Add readable output for callchain debug
2013-11-01 15:23 [PATCHv2 0/3] perf tools: Fix -g option handling Jiri Olsa
2013-11-01 15:23 ` [PATCH 1/3] perf tools: Add call-graph option support into .perfconfig Jiri Olsa
@ 2013-11-01 15:23 ` Jiri Olsa
2013-11-01 15:23 ` [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands Jiri Olsa
2 siblings, 0 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-11-01 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Corey Ashford, David Ahern, Ingo Molnar, Namhyung Kim,
Paul Mackerras, Peter Zijlstra, Arnaldo Carvalho de Melo,
Andi Kleen, Adrian Hunter
Adding people readable output for callchain debug,
to get following '-v' output:
$ perf record -v -g ls
callchain: type DWARF
callchain: stack dump size 4096
...
Tested-Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/builtin-record.c | 4 +++-
tools/perf/perf.h | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 2d00a19..04c5cf9 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -770,7 +770,9 @@ int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
static void callchain_debug(struct perf_record_opts *opts)
{
- pr_debug("callchain: type %d\n", opts->call_graph);
+ static const char *str[CALLCHAIN_MAX] = { "NONE", "FP", "DWARF" };
+
+ pr_debug("callchain: type %s\n", str[opts->call_graph]);
if (opts->call_graph == CALLCHAIN_DWARF)
pr_debug("callchain: stack dump size %d\n",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 27223fb..313a5df 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -207,7 +207,8 @@ void pthread__unblock_sigwinch(void);
enum perf_call_graph_mode {
CALLCHAIN_NONE,
CALLCHAIN_FP,
- CALLCHAIN_DWARF
+ CALLCHAIN_DWARF,
+ CALLCHAIN_MAX
};
struct perf_record_opts {
--
1.7.11.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands
2013-11-01 15:23 [PATCHv2 0/3] perf tools: Fix -g option handling Jiri Olsa
2013-11-01 15:23 ` [PATCH 1/3] perf tools: Add call-graph option support into .perfconfig Jiri Olsa
2013-11-01 15:23 ` [PATCH 2/3] perf tools: Add readable output for callchain debug Jiri Olsa
@ 2013-11-01 15:23 ` Jiri Olsa
2013-11-01 15:53 ` Andi Kleen
2 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2013-11-01 15:23 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Corey Ashford, David Ahern, Ingo Molnar, Namhyung Kim,
Paul Mackerras, Peter Zijlstra, Arnaldo Carvalho de Melo,
Andi Kleen, Adrian Hunter
Adding -L as short option for call-graph for record/top
commands. Plus documentation update.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/Documentation/perf-record.txt | 1 +
tools/perf/Documentation/perf-top.txt | 1 +
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-top.c | 2 +-
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 22ccd63..fb4956e 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -92,6 +92,7 @@ OPTIONS
-g::
Enables call-graph (stack chain/backtrace) recording.
+-L::
--call-graph::
Setup and enable call-graph (stack chain/backtrace) recording,
implies -g.
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 456fd65..f92d477 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -143,6 +143,7 @@ Default is to monitor all CPUS.
-G::
Enables call-graph (stack chain/backtrace) recording.
+-L::
--call-graph::
Setup and enable call-graph (stack chain/backtrace) recording,
implies -G.
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 04c5cf9..a20098d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -903,7 +903,7 @@ const struct option record_options[] = {
OPT_CALLBACK_NOOPT('g', NULL, &record.opts,
NULL, "enables call-graph recording" ,
&record_callchain_opt),
- OPT_CALLBACK(0, "call-graph", &record.opts,
+ OPT_CALLBACK('L', "call-graph", &record.opts,
"mode[,dump_size]", record_callchain_help,
&record_parse_callchain_opt),
OPT_INCR('v', "verbose", &verbose,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e1671b1..938e025 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1121,7 +1121,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts,
NULL, "enables call-graph recording",
&callchain_opt),
- OPT_CALLBACK(0, "call-graph", &top.record_opts,
+ OPT_CALLBACK('L', "call-graph", &top.record_opts,
"mode[,dump_size]", record_callchain_help,
&parse_callchain_opt),
OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
--
1.7.11.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands
2013-11-01 15:23 ` [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands Jiri Olsa
@ 2013-11-01 15:53 ` Andi Kleen
2013-11-04 17:18 ` Jiri Olsa
0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2013-11-01 15:53 UTC (permalink / raw)
To: Jiri Olsa
Cc: linux-kernel, Corey Ashford, David Ahern, Ingo Molnar,
Namhyung Kim, Paul Mackerras, Peter Zijlstra,
Arnaldo Carvalho de Melo, Andi Kleen, Adrian Hunter
On Fri, Nov 01, 2013 at 04:23:14PM +0100, Jiri Olsa wrote:
> Adding -L as short option for call-graph for record/top
> commands. Plus documentation update.
Seems overkill. I guess the long option is enough, and in perf
short options already need to be considered a precious resource,
as they may soon run out.
-Andi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands
2013-11-01 15:53 ` Andi Kleen
@ 2013-11-04 17:18 ` Jiri Olsa
0 siblings, 0 replies; 6+ messages in thread
From: Jiri Olsa @ 2013-11-04 17:18 UTC (permalink / raw)
To: Andi Kleen
Cc: linux-kernel, Corey Ashford, David Ahern, Ingo Molnar,
Namhyung Kim, Paul Mackerras, Peter Zijlstra,
Arnaldo Carvalho de Melo, Adrian Hunter
On Fri, Nov 01, 2013 at 04:53:59PM +0100, Andi Kleen wrote:
> On Fri, Nov 01, 2013 at 04:23:14PM +0100, Jiri Olsa wrote:
> > Adding -L as short option for call-graph for record/top
> > commands. Plus documentation update.
>
> Seems overkill. I guess the long option is enough, and in perf
> short options already need to be considered a precious resource,
> as they may soon run out.
I guess you're right here.. Ingo? I think you wanted this one
jirka
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-04 17:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01 15:23 [PATCHv2 0/3] perf tools: Fix -g option handling Jiri Olsa
2013-11-01 15:23 ` [PATCH 1/3] perf tools: Add call-graph option support into .perfconfig Jiri Olsa
2013-11-01 15:23 ` [PATCH 2/3] perf tools: Add readable output for callchain debug Jiri Olsa
2013-11-01 15:23 ` [PATCH 3/3] perf tools: Add -L as short option for call-graph for record/top commands Jiri Olsa
2013-11-01 15:53 ` Andi Kleen
2013-11-04 17:18 ` Jiri Olsa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).