Commit aa8db3e4 authored by Alexandre Truong's avatar Alexandre Truong Committed by Arnaldo Carvalho de Melo

perf callchain: Enable dwarf_callchain_users on arm64

Enable dwarf_callchain_users on arm64 which will be needed to do a
DWARF unwind in order to get the caller of the leaf frame.
Reviewed-by: default avatarJames Clark <james.clark@arm.com>
Signed-off-by: default avatarAlexandre Truong <alexandre.truong@arm.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20211217154521.80603-5-german.gomez@arm.comSigned-off-by: default avatarGerman Gomez <german.gomez@arm.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ab236921
...@@ -410,7 +410,7 @@ static int report__setup_sample_type(struct report *rep) ...@@ -410,7 +410,7 @@ static int report__setup_sample_type(struct report *rep)
} }
} }
callchain_param_setup(sample_type); callchain_param_setup(sample_type, perf_env__arch(&rep->session->header.env));
if (rep->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { if (rep->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) {
ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n"
...@@ -1127,7 +1127,7 @@ static int process_attr(struct perf_tool *tool __maybe_unused, ...@@ -1127,7 +1127,7 @@ static int process_attr(struct perf_tool *tool __maybe_unused,
* on events sample_type. * on events sample_type.
*/ */
sample_type = evlist__combined_sample_type(*pevlist); sample_type = evlist__combined_sample_type(*pevlist);
callchain_param_setup(sample_type); callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env));
return 0; return 0;
} }
......
...@@ -2318,7 +2318,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event, ...@@ -2318,7 +2318,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
* on events sample_type. * on events sample_type.
*/ */
sample_type = evlist__combined_sample_type(evlist); sample_type = evlist__combined_sample_type(evlist);
callchain_param_setup(sample_type); callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env));
/* Enable fields for callchain entries */ /* Enable fields for callchain entries */
if (symbol_conf.use_callchain && if (symbol_conf.use_callchain &&
...@@ -3468,7 +3468,7 @@ static void script__setup_sample_type(struct perf_script *script) ...@@ -3468,7 +3468,7 @@ static void script__setup_sample_type(struct perf_script *script)
struct perf_session *session = script->session; struct perf_session *session = script->session;
u64 sample_type = evlist__combined_sample_type(session->evlist); u64 sample_type = evlist__combined_sample_type(session->evlist);
callchain_param_setup(sample_type); callchain_param_setup(sample_type, perf_env__arch(session->machines.host.env));
if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) {
pr_warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" pr_warning("Can't find LBR callchain. Switch off --stitch-lbr.\n"
......
...@@ -1600,7 +1600,7 @@ void callchain_cursor_reset(struct callchain_cursor *cursor) ...@@ -1600,7 +1600,7 @@ void callchain_cursor_reset(struct callchain_cursor *cursor)
map__zput(node->ms.map); map__zput(node->ms.map);
} }
void callchain_param_setup(u64 sample_type) void callchain_param_setup(u64 sample_type, const char *arch)
{ {
if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) { if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
if ((sample_type & PERF_SAMPLE_REGS_USER) && if ((sample_type & PERF_SAMPLE_REGS_USER) &&
...@@ -1612,6 +1612,18 @@ void callchain_param_setup(u64 sample_type) ...@@ -1612,6 +1612,18 @@ void callchain_param_setup(u64 sample_type)
else else
callchain_param.record_mode = CALLCHAIN_FP; callchain_param.record_mode = CALLCHAIN_FP;
} }
/*
* It's necessary to use libunwind to reliably determine the caller of
* a leaf function on aarch64, as otherwise we cannot know whether to
* start from the LR or FP.
*
* Always starting from the LR can result in duplicate or entirely
* erroneous entries. Always skipping the LR and starting from the FP
* can result in missing entries.
*/
if (callchain_param.record_mode == CALLCHAIN_FP && !strcmp(arch, "arm64"))
dwarf_callchain_users = true;
} }
static bool chain_match(struct callchain_list *base_chain, static bool chain_match(struct callchain_list *base_chain,
......
...@@ -300,7 +300,7 @@ int callchain_branch_counts(struct callchain_root *root, ...@@ -300,7 +300,7 @@ int callchain_branch_counts(struct callchain_root *root,
u64 *branch_count, u64 *predicted_count, u64 *branch_count, u64 *predicted_count,
u64 *abort_count, u64 *cycles_count); u64 *abort_count, u64 *cycles_count);
void callchain_param_setup(u64 sample_type); void callchain_param_setup(u64 sample_type, const char *arch);
bool callchain_cnode_matched(struct callchain_node *base_cnode, bool callchain_cnode_matched(struct callchain_node *base_cnode,
struct callchain_node *pair_cnode); struct callchain_node *pair_cnode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment