]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf symbol: Update symbols__fixup_end()
authorNamhyung Kim <namhyung@kernel.org>
Sat, 16 Apr 2022 00:40:47 +0000 (17:40 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 Apr 2022 13:51:33 +0000 (10:51 -0300)
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: ef7c0ec0f67ad5c3 ("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-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/symbol.c

index 1b85cc1422a96a24fb72fdbf18ca94398c269659..623094e866fd84af6511eabe45f510db1adeb8a5 100644 (file)
@@ -217,8 +217,8 @@ again:
        }
 }
 
-void symbols__fixup_end(struct rb_root_cached *symbols,
-                       bool is_kallsyms __maybe_unused)
+/* Update zero-sized symbols using the address of the next symbol */
+void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms)
 {
        struct rb_node *nd, *prevnd = rb_first_cached(symbols);
        struct symbol *curr, *prev;
@@ -232,8 +232,29 @@ void symbols__fixup_end(struct rb_root_cached *symbols,
                prev = curr;
                curr = rb_entry(nd, struct symbol, rb_node);
 
-               if (prev->end == prev->start || prev->end != curr->start)
-                       arch__symbols__fixup_end(prev, curr);
+               /*
+                * On some architecture kernel text segment start is located at
+                * some low memory address, while modules are located at high
+                * memory addresses (or vice versa).  The gap between end of
+                * kernel text segment and beginning of first module's text
+                * segment is very big.  Therefore do not fill this gap and do
+                * not assign it to the kernel dso map (kallsyms).
+                *
+                * In kallsyms, it determines module symbols using '[' character
+                * like in:
+                *   ffffffffc1937000 T hdmi_driver_init  [snd_hda_codec_hdmi]
+                */
+               if (prev->end == prev->start) {
+                       /* Last kernel/module symbol mapped to end of page */
+                       if (is_kallsyms && (!strchr(prev->name, '[') !=
+                                           !strchr(curr->name, '[')))
+                               prev->end = roundup(prev->end + 4096, 4096);
+                       else
+                               prev->end = curr->start;
+
+                       pr_debug4("%s sym:%s end:%#" PRIx64 "\n",
+                                 __func__, prev->name, prev->end);
+               }
        }
 
        /* Last entry */