Skip to content

Commit eb853e8

Browse files
Jiri Olsaacmel
authored andcommitted
perf tools: Add call-graph option support into .perfconfig
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>
1 parent bc52908 commit eb853e8

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎tools/perf/builtin-record.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ int record_parse_callchain_opt(const struct option *opt,
749749
struct record_opts *opts = opt->value;
750750
int ret;
751751

752+
opts->call_graph_enabled = !unset;
753+
752754
/* --no-call-graph */
753755
if (unset) {
754756
opts->call_graph = CALLCHAIN_NONE;
@@ -769,13 +771,25 @@ int record_callchain_opt(const struct option *opt,
769771
{
770772
struct record_opts *opts = opt->value;
771773

774+
opts->call_graph_enabled = !unset;
775+
772776
if (opts->call_graph == CALLCHAIN_NONE)
773777
opts->call_graph = CALLCHAIN_FP;
774778

775779
callchain_debug(opts);
776780
return 0;
777781
}
778782

783+
static int perf_record_config(const char *var, const char *value, void *cb)
784+
{
785+
struct record *rec = cb;
786+
787+
if (!strcmp(var, "record.call-graph"))
788+
return record_parse_callchain(value, &rec->opts);
789+
790+
return perf_default_config(var, value, cb);
791+
}
792+
779793
static const char * const record_usage[] = {
780794
"perf record [<options>] [<command>]",
781795
"perf record [<options>] -- <command> [<options>]",
@@ -907,6 +921,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
907921
if (rec->evlist == NULL)
908922
return -ENOMEM;
909923

924+
perf_config(perf_record_config, rec);
925+
910926
argc = parse_options(argc, argv, record_options, record_usage,
911927
PARSE_OPT_STOP_AT_NON_OPTION);
912928
if (!argc && target__none(&rec->opts.target))

‎tools/perf/builtin-top.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,16 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
991991
return record_parse_callchain_opt(opt, arg, unset);
992992
}
993993

994+
static int perf_top_config(const char *var, const char *value, void *cb)
995+
{
996+
struct perf_top *top = cb;
997+
998+
if (!strcmp(var, "top.call-graph"))
999+
return record_parse_callchain(value, &top->record_opts);
1000+
1001+
return perf_default_config(var, value, cb);
1002+
}
1003+
9941004
static int
9951005
parse_percent_limit(const struct option *opt, const char *arg,
9961006
int unset __maybe_unused)
@@ -1115,6 +1125,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
11151125
if (top.evlist == NULL)
11161126
return -ENOMEM;
11171127

1128+
perf_config(perf_top_config, &top);
1129+
11181130
argc = parse_options(argc, argv, options, top_usage, 0);
11191131
if (argc)
11201132
usage_with_options(top_usage, options);

‎tools/perf/perf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ enum perf_call_graph_mode {
257257
struct record_opts {
258258
struct target target;
259259
int call_graph;
260+
bool call_graph_enabled;
260261
bool group;
261262
bool inherit_stat;
262263
bool no_buffering;

‎tools/perf/util/evsel.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
595595
attr->mmap_data = track;
596596
}
597597

598-
if (opts->call_graph) {
598+
if (opts->call_graph_enabled) {
599599
perf_evsel__set_sample_bit(evsel, CALLCHAIN);
600600

601601
if (opts->call_graph == CALLCHAIN_DWARF) {

0 commit comments

Comments
 (0)