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

perf machine: Add a mechanism to inject stack frames

Add a mechanism for platforms to inject stack frames for the leaf
frame caller if there is enough information to determine a frame
is missing from dwarf or other post processing mechanisms.
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-3-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 7248e308
......@@ -2710,6 +2710,12 @@ static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread,
return err;
}
static u64 get_leaf_frame_caller(struct perf_sample *sample __maybe_unused,
struct thread *thread __maybe_unused, int usr_idx __maybe_unused)
{
return 0;
}
static int thread__resolve_callchain_sample(struct thread *thread,
struct callchain_cursor *cursor,
struct evsel *evsel,
......@@ -2723,9 +2729,10 @@ static int thread__resolve_callchain_sample(struct thread *thread,
struct ip_callchain *chain = sample->callchain;
int chain_nr = 0;
u8 cpumode = PERF_RECORD_MISC_USER;
int i, j, err, nr_entries;
int i, j, err, nr_entries, usr_idx;
int skip_idx = -1;
int first_call = 0;
u64 leaf_frame_caller;
if (chain)
chain_nr = chain->nr;
......@@ -2850,6 +2857,34 @@ static int thread__resolve_callchain_sample(struct thread *thread,
continue;
}
/*
* PERF_CONTEXT_USER allows us to locate where the user stack ends.
* Depending on callchain_param.order and the position of PERF_CONTEXT_USER,
* the index will be different in order to add the missing frame
* at the right place.
*/
usr_idx = callchain_param.order == ORDER_CALLEE ? j-2 : j-1;
if (usr_idx >= 0 && chain->ips[usr_idx] == PERF_CONTEXT_USER) {
leaf_frame_caller = get_leaf_frame_caller(sample, thread, usr_idx);
/*
* check if leaf_frame_Caller != ip to not add the same
* value twice.
*/
if (leaf_frame_caller && leaf_frame_caller != ip) {
err = add_callchain_ip(thread, cursor, parent,
root_al, &cpumode, leaf_frame_caller,
false, NULL, NULL, 0);
if (err)
return (err < 0) ? err : 0;
}
}
err = add_callchain_ip(thread, cursor, parent,
root_al, &cpumode, ip,
false, NULL, NULL, 0);
......
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