Skip to content

Commit 8799ebc

Browse files
namhyungacmel
authored andcommitted
perf symbol: Update symbols__fixup_end()
Now arch-specific functions all do the same thing. When it fixes the symbol address it needs to check the boundary between the kernel image and modules. For the last symbol in the previous region, it cannot know the exact size as it's discarded already. Thus it just uses a small page size (4096) and rounds it up like the last symbol. Fixes: 3cf6a32 ("perf symbols: Fix symbol size calculation condition") Signed-off-by: Namhyung Kim <[email protected]> Acked-by: Ian Rogers <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 838425f commit 8799ebc

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tools/perf/util/symbol.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ void symbols__fixup_duplicate(struct rb_root_cached *symbols)
217217
}
218218
}
219219

220-
void symbols__fixup_end(struct rb_root_cached *symbols,
221-
bool is_kallsyms __maybe_unused)
220+
/* Update zero-sized symbols using the address of the next symbol */
221+
void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms)
222222
{
223223
struct rb_node *nd, *prevnd = rb_first_cached(symbols);
224224
struct symbol *curr, *prev;
@@ -232,8 +232,29 @@ void symbols__fixup_end(struct rb_root_cached *symbols,
232232
prev = curr;
233233
curr = rb_entry(nd, struct symbol, rb_node);
234234

235-
if (prev->end == prev->start || prev->end != curr->start)
236-
arch__symbols__fixup_end(prev, curr);
235+
/*
236+
* On some architecture kernel text segment start is located at
237+
* some low memory address, while modules are located at high
238+
* memory addresses (or vice versa). The gap between end of
239+
* kernel text segment and beginning of first module's text
240+
* segment is very big. Therefore do not fill this gap and do
241+
* not assign it to the kernel dso map (kallsyms).
242+
*
243+
* In kallsyms, it determines module symbols using '[' character
244+
* like in:
245+
* ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi]
246+
*/
247+
if (prev->end == prev->start) {
248+
/* Last kernel/module symbol mapped to end of page */
249+
if (is_kallsyms && (!strchr(prev->name, '[') !=
250+
!strchr(curr->name, '[')))
251+
prev->end = roundup(prev->end + 4096, 4096);
252+
else
253+
prev->end = curr->start;
254+
255+
pr_debug4("%s sym:%s end:%#" PRIx64 "\n",
256+
__func__, prev->name, prev->end);
257+
}
237258
}
238259

239260
/* Last entry */

0 commit comments

Comments
 (0)