perf maps: Fix display of kernel symbols
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 8 Jan 2025 09:54:20 +0000 (10:54 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 8 Jan 2025 20:20:42 +0000 (17:20 -0300)
commitdae29277fddaaf6670d17dfcbb916a2ca29c912f
tree9e0d301e9b7cd0d4262f762e34fd5b34c4969c32
parentc738a34417b6087e2b27ac1494fef12e37057f93
perf maps: Fix display of kernel symbols

Since commit 659ad3492b913c90 ("perf maps: Switch from rbtree to lazily
sorted array for addresses"), perf doesn't display anymore kernel
symbols on powerpc, allthough it still detects them as kernel addresses.

# Overhead  Command     Shared Object  Symbol
# ........  ..........  ............. ......................................
#
    80.49%  Coeur main  [unknown]      [k] 0xc005f0f8
     3.91%  Coeur main  gau            [.] engine_loop.constprop.0.isra.0
     1.72%  Coeur main  [unknown]      [k] 0xc005f11c
     1.09%  Coeur main  [unknown]      [k] 0xc01f82c8
     0.44%  Coeur main  libc.so.6      [.] epoll_wait
     0.38%  Coeur main  [unknown]      [k] 0xc0011718
     0.36%  Coeur main  [unknown]      [k] 0xc01f45c0

This is because function maps__find_next_entry() now returns current
entry instead of next entry, leading to kernel map end address getting
mis-configured with its own start address instead of the start address
of the following map.

Fix it by really taking the next entry, also make sure that entry
follows current one by making sure entries are sorted.

Fixes: 659ad3492b913c90 ("perf maps: Switch from rbtree to lazily sorted array for addresses")
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/2ea4501209d5363bac71a6757fe91c0747558a42.1736329923.git.christophe.leroy@csgroup.eu
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/maps.c