Skip to content

Commit a913ef6

Browse files
captain5050acmel
authored andcommitted
perf callchain: Always populate the addr_location map when adding IP
Dropping symbols also meant the callchain maps wasn't populated, but the callchain map is needed to find the DSO. Plumb the symbols option better, falling back to thread__find_map() rather than thread__find_symbol() when symbols are disabled. Fixes: 02b2705 ("perf callchain: Allow symbols to be optional when resolving a callchain") Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.ibm.com> Cc: Ben Gainey <ben.gainey@arm.com> Cc: Chaitanya S Prakash <chaitanyas.prakash@arm.com> Cc: Charlie Jenkins <charlie@rivosinc.com> Cc: Chun-Tse Shao <ctshao@google.com> Cc: Colin Ian King <colin.i.king@gmail.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Dr. David Alan Gilbert <linux@treblig.org> Cc: Graham Woodward <graham.woodward@arm.com> Cc: Howard Chu <howardchu95@gmail.com> Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Levi Yun <yeoreum.yun@arm.com> Cc: Li Huafei <lihuafei1@huawei.com> Cc: linux-arm-kernel@lists.infradead.org Cc: Mark Rutland <mark.rutland@arm.com> Cc: Martin Liška <martin.liska@hey.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Matt Fleming <matt@readmodwrite.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Song Liu <song@kernel.org> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Stephen Brennan <stephen.s.brennan@oracle.com> Cc: Steve Clevenger <scclevenger@os.amperecomputing.com> Cc: Thomas Falcon <thomas.falcon@intel.com> Cc: Veronika Molnarova <vmolnaro@redhat.com> Cc: Weilin Wang <weilin.wang@intel.com> Cc: Will Deacon <will@kernel.org> Cc: Yicong Yang <yangyicong@hisilicon.com> Cc: Yujie Liu <yujie.liu@intel.com> Cc: Zhongqiu Han <quic_zhonhan@quicinc.com> Cc: Zixian Cai <fzczx123@gmail.com> Link: https://lore.kernel.org/r/20250529044000.759937-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0df14c1 commit a913ef6

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

tools/perf/util/machine.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ static void ip__resolve_ams(struct thread *thread,
20112011
* Thus, we have to try consecutively until we find a match
20122012
* or else, the symbol is unknown
20132013
*/
2014-
thread__find_cpumode_addr_location(thread, ip, &al);
2014+
thread__find_cpumode_addr_location(thread, ip, /*symbols=*/true, &al);
20152015

20162016
ams->addr = ip;
20172017
ams->al_addr = al.addr;
@@ -2113,7 +2113,7 @@ static int add_callchain_ip(struct thread *thread,
21132113
al.sym = NULL;
21142114
al.srcline = NULL;
21152115
if (!cpumode) {
2116-
thread__find_cpumode_addr_location(thread, ip, &al);
2116+
thread__find_cpumode_addr_location(thread, ip, symbols, &al);
21172117
} else {
21182118
if (ip >= PERF_CONTEXT_MAX) {
21192119
switch (ip) {
@@ -2141,6 +2141,8 @@ static int add_callchain_ip(struct thread *thread,
21412141
}
21422142
if (symbols)
21432143
thread__find_symbol(thread, *cpumode, ip, &al);
2144+
else
2145+
thread__find_map(thread, *cpumode, ip, &al);
21442146
}
21452147

21462148
if (al.sym != NULL) {

tools/perf/util/thread.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bo
410410
}
411411

412412
void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
413-
struct addr_location *al)
413+
bool symbols, struct addr_location *al)
414414
{
415415
size_t i;
416416
const u8 cpumodes[] = {
@@ -421,7 +421,11 @@ void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
421421
};
422422

423423
for (i = 0; i < ARRAY_SIZE(cpumodes); i++) {
424-
thread__find_symbol(thread, cpumodes[i], addr, al);
424+
if (symbols)
425+
thread__find_symbol(thread, cpumodes[i], addr, al);
426+
else
427+
thread__find_map(thread, cpumodes[i], addr, al);
428+
425429
if (al->map)
426430
break;
427431
}

tools/perf/util/thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct symbol *thread__find_symbol_fb(struct thread *thread, u8 cpumode,
126126
u64 addr, struct addr_location *al);
127127

128128
void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
129-
struct addr_location *al);
129+
bool symbols, struct addr_location *al);
130130

131131
int thread__memcpy(struct thread *thread, struct machine *machine,
132132
void *buf, u64 ip, int len, bool *is64bit);

0 commit comments

Comments
 (0)