Skip to content

Commit

Permalink
perf tools: Add call-graph option support into .perfconfig
Browse files Browse the repository at this point in the history
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

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
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>
Link: http://lkml.kernel.org/r/1391427883-13443-2-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Feb 18, 2014
1 parent bc52908 commit eb853e8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ int record_parse_callchain_opt(const struct option *opt,
struct record_opts *opts = opt->value;
int ret;

opts->call_graph_enabled = !unset;

/* --no-call-graph */
if (unset) {
opts->call_graph = CALLCHAIN_NONE;
Expand All @@ -769,13 +771,25 @@ int record_callchain_opt(const struct option *opt,
{
struct record_opts *opts = opt->value;

opts->call_graph_enabled = !unset;

if (opts->call_graph == CALLCHAIN_NONE)
opts->call_graph = CALLCHAIN_FP;

callchain_debug(opts);
return 0;
}

static int perf_record_config(const char *var, const char *value, void *cb)
{
struct 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>]",
Expand Down Expand Up @@ -907,6 +921,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
if (rec->evlist == NULL)
return -ENOMEM;

perf_config(perf_record_config, rec);

argc = parse_options(argc, argv, record_options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target__none(&rec->opts.target))
Expand Down
12 changes: 12 additions & 0 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,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)
Expand Down Expand Up @@ -1115,6 +1125,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);
Expand Down
1 change: 1 addition & 0 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ enum perf_call_graph_mode {
struct record_opts {
struct target target;
int call_graph;
bool call_graph_enabled;
bool group;
bool inherit_stat;
bool no_buffering;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
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) {
Expand Down

0 comments on commit eb853e8

Please sign in to comment.