Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf symbol: Pass is_kallsyms to symbols__fixup_end()

The symbol fixup is necessary for symbols in kallsyms since they don't
have size info. So we use the next symbol's address to calculate the
size. Now it's also used for user binaries because sometimes they miss
size for hand-written asm functions.

There's a arch-specific function to handle kallsyms differently but
currently it cannot distinguish kallsyms from others. Pass this
information explicitly to handle it properly. Note that those arch
functions will be moved to the generic function so I didn't added it to
the arch-functions.

Fixes: 3cf6a32f3f2a4594 ("perf symbols: Fix symbol size calculation condition")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-s390@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20220416004048.1514900-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
838425f2 3b9a8c8b

+6 -5
+1 -1
tools/perf/util/symbol-elf.c
··· 1290 1290 * For misannotated, zeroed, ASM function sizes. 1291 1291 */ 1292 1292 if (nr > 0) { 1293 - symbols__fixup_end(&dso->symbols); 1293 + symbols__fixup_end(&dso->symbols, false); 1294 1294 symbols__fixup_duplicate(&dso->symbols); 1295 1295 if (kmap) { 1296 1296 /*
+4 -3
tools/perf/util/symbol.c
··· 217 217 } 218 218 } 219 219 220 - void symbols__fixup_end(struct rb_root_cached *symbols) 220 + void symbols__fixup_end(struct rb_root_cached *symbols, 221 + bool is_kallsyms __maybe_unused) 221 222 { 222 223 struct rb_node *nd, *prevnd = rb_first_cached(symbols); 223 224 struct symbol *curr, *prev; ··· 1468 1467 if (kallsyms__delta(kmap, filename, &delta)) 1469 1468 return -1; 1470 1469 1471 - symbols__fixup_end(&dso->symbols); 1470 + symbols__fixup_end(&dso->symbols, true); 1472 1471 symbols__fixup_duplicate(&dso->symbols); 1473 1472 1474 1473 if (dso->kernel == DSO_SPACE__KERNEL_GUEST) ··· 1660 1659 #undef bfd_asymbol_section 1661 1660 #endif 1662 1661 1663 - symbols__fixup_end(&dso->symbols); 1662 + symbols__fixup_end(&dso->symbols, false); 1664 1663 symbols__fixup_duplicate(&dso->symbols); 1665 1664 dso->adjust_symbols = 1; 1666 1665
+1 -1
tools/perf/util/symbol.h
··· 203 203 bool kernel); 204 204 void symbols__insert(struct rb_root_cached *symbols, struct symbol *sym); 205 205 void symbols__fixup_duplicate(struct rb_root_cached *symbols); 206 - void symbols__fixup_end(struct rb_root_cached *symbols); 206 + void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms); 207 207 void maps__fixup_end(struct maps *maps); 208 208 209 209 typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);