Skip to content

Commit 72a128a

Browse files
namhyungacmel
authored andcommitted
perf tools: Move callchain config from record_opts to callchain_param
So that all callchain config parameters can be read/written to a single place. It's a preparation to consolidate handling of all callchain options. Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Milian Wolff <mail@milianw.de> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1411434104-5307-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 72f72ed commit 72a128a

5 files changed

Lines changed: 30 additions & 38 deletions

File tree

‎tools/perf/builtin-record.c‎

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static int get_stack_size(char *str, unsigned long *_size)
652652
}
653653
#endif /* HAVE_DWARF_UNWIND_SUPPORT */
654654

655-
int record_parse_callchain(const char *arg, struct record_opts *opts)
655+
int record_parse_callchain(const char *arg)
656656
{
657657
char *tok, *name, *saveptr = NULL;
658658
char *buf;
@@ -672,7 +672,7 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
672672
/* Framepointer style */
673673
if (!strncmp(name, "fp", sizeof("fp"))) {
674674
if (!strtok_r(NULL, ",", &saveptr)) {
675-
opts->call_graph = CALLCHAIN_FP;
675+
callchain_param.record_mode = CALLCHAIN_FP;
676676
ret = 0;
677677
} else
678678
pr_err("callchain: No more arguments "
@@ -685,15 +685,15 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
685685
const unsigned long default_stack_dump_size = 8192;
686686

687687
ret = 0;
688-
opts->call_graph = CALLCHAIN_DWARF;
689-
opts->stack_dump_size = default_stack_dump_size;
688+
callchain_param.record_mode = CALLCHAIN_DWARF;
689+
callchain_param.dump_size = default_stack_dump_size;
690690

691691
tok = strtok_r(NULL, ",", &saveptr);
692692
if (tok) {
693693
unsigned long size = 0;
694694

695695
ret = get_stack_size(tok, &size);
696-
opts->stack_dump_size = size;
696+
callchain_param.dump_size = size;
697697
}
698698
#endif /* HAVE_DWARF_UNWIND_SUPPORT */
699699
} else {
@@ -708,61 +708,56 @@ int record_parse_callchain(const char *arg, struct record_opts *opts)
708708
return ret;
709709
}
710710

711-
static void callchain_debug(struct record_opts *opts)
711+
static void callchain_debug(void)
712712
{
713713
static const char *str[CALLCHAIN_MAX] = { "NONE", "FP", "DWARF" };
714714

715-
pr_debug("callchain: type %s\n", str[opts->call_graph]);
715+
pr_debug("callchain: type %s\n", str[callchain_param.record_mode]);
716716

717-
if (opts->call_graph == CALLCHAIN_DWARF)
717+
if (callchain_param.record_mode == CALLCHAIN_DWARF)
718718
pr_debug("callchain: stack dump size %d\n",
719-
opts->stack_dump_size);
719+
callchain_param.dump_size);
720720
}
721721

722-
int record_parse_callchain_opt(const struct option *opt,
722+
int record_parse_callchain_opt(const struct option *opt __maybe_unused,
723723
const char *arg,
724724
int unset)
725725
{
726-
struct record_opts *opts = opt->value;
727726
int ret;
728727

729-
opts->call_graph_enabled = !unset;
728+
callchain_param.enabled = !unset;
730729

731730
/* --no-call-graph */
732731
if (unset) {
733-
opts->call_graph = CALLCHAIN_NONE;
732+
callchain_param.record_mode = CALLCHAIN_NONE;
734733
pr_debug("callchain: disabled\n");
735734
return 0;
736735
}
737736

738-
ret = record_parse_callchain(arg, opts);
737+
ret = record_parse_callchain(arg);
739738
if (!ret)
740-
callchain_debug(opts);
739+
callchain_debug();
741740

742741
return ret;
743742
}
744743

745-
int record_callchain_opt(const struct option *opt,
744+
int record_callchain_opt(const struct option *opt __maybe_unused,
746745
const char *arg __maybe_unused,
747746
int unset __maybe_unused)
748747
{
749-
struct record_opts *opts = opt->value;
748+
callchain_param.enabled = true;
750749

751-
opts->call_graph_enabled = !unset;
750+
if (callchain_param.record_mode == CALLCHAIN_NONE)
751+
callchain_param.record_mode = CALLCHAIN_FP;
752752

753-
if (opts->call_graph == CALLCHAIN_NONE)
754-
opts->call_graph = CALLCHAIN_FP;
755-
756-
callchain_debug(opts);
753+
callchain_debug();
757754
return 0;
758755
}
759756

760757
static int perf_record_config(const char *var, const char *value, void *cb)
761758
{
762-
struct record *rec = cb;
763-
764759
if (!strcmp(var, "record.call-graph"))
765-
return record_parse_callchain(value, &rec->opts);
760+
return record_parse_callchain(value);
766761

767762
return perf_default_config(var, value, cb);
768763
}

‎tools/perf/builtin-top.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,8 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
10201020

10211021
static int perf_top_config(const char *var, const char *value, void *cb)
10221022
{
1023-
struct perf_top *top = cb;
1024-
10251023
if (!strcmp(var, "top.call-graph"))
1026-
return record_parse_callchain(value, &top->record_opts);
1024+
return record_parse_callchain(value);
10271025
if (!strcmp(var, "top.children")) {
10281026
symbol_conf.cumulate_callchain = perf_config_bool(var, value);
10291027
return 0;

‎tools/perf/perf.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ void pthread__unblock_sigwinch(void);
4141

4242
struct record_opts {
4343
struct target target;
44-
int call_graph;
45-
bool call_graph_enabled;
4644
bool group;
4745
bool inherit_stat;
4846
bool no_buffering;
@@ -60,7 +58,6 @@ struct record_opts {
6058
u64 branch_stack;
6159
u64 default_interval;
6260
u64 user_interval;
63-
u16 stack_dump_size;
6461
bool sample_transaction;
6562
unsigned initial_delay;
6663
};

‎tools/perf/util/callchain.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ enum chain_key {
5454
};
5555

5656
struct callchain_param {
57+
bool enabled;
58+
enum perf_call_graph_mode record_mode;
59+
u32 dump_size;
5760
enum chain_mode mode;
5861
u32 print_limit;
5962
double min_percent;
@@ -154,7 +157,7 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
154157
struct option;
155158
struct hist_entry;
156159

157-
int record_parse_callchain(const char *arg, struct record_opts *opts);
160+
int record_parse_callchain(const char *arg);
158161
int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset);
159162
int record_callchain_opt(const struct option *opt, const char *arg, int unset);
160163

‎tools/perf/util/evsel.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,20 +503,19 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
503503
}
504504

505505
static void
506-
perf_evsel__config_callgraph(struct perf_evsel *evsel,
507-
struct record_opts *opts)
506+
perf_evsel__config_callgraph(struct perf_evsel *evsel)
508507
{
509508
bool function = perf_evsel__is_function_event(evsel);
510509
struct perf_event_attr *attr = &evsel->attr;
511510

512511
perf_evsel__set_sample_bit(evsel, CALLCHAIN);
513512

514-
if (opts->call_graph == CALLCHAIN_DWARF) {
513+
if (callchain_param.record_mode == CALLCHAIN_DWARF) {
515514
if (!function) {
516515
perf_evsel__set_sample_bit(evsel, REGS_USER);
517516
perf_evsel__set_sample_bit(evsel, STACK_USER);
518517
attr->sample_regs_user = PERF_REGS_MASK;
519-
attr->sample_stack_user = opts->stack_dump_size;
518+
attr->sample_stack_user = callchain_param.dump_size;
520519
attr->exclude_callchain_user = 1;
521520
} else {
522521
pr_info("Cannot use DWARF unwind for function trace event,"
@@ -625,8 +624,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
625624
attr->mmap_data = track;
626625
}
627626

628-
if (opts->call_graph_enabled && !evsel->no_aux_samples)
629-
perf_evsel__config_callgraph(evsel, opts);
627+
if (callchain_param.enabled && !evsel->no_aux_samples)
628+
perf_evsel__config_callgraph(evsel);
630629

631630
if (target__has_cpu(&opts->target))
632631
perf_evsel__set_sample_bit(evsel, CPU);

0 commit comments

Comments
 (0)