linux-stable/tools/perf
Krister Johansen 50e36c2897 perf symbols: Symbol lookup with kcore can fail if multiple segments match stext
commit 1c24956542 upstream.

This problem was encountered on an arm64 system with a lot of memory.
Without kernel debug symbols installed, and with both kcore and kallsyms
available, perf managed to get confused and returned "unknown" for all
of the kernel symbols that it tried to look up.

On this system, stext fell within the vmalloc segment.  The kcore symbol
matching code tries to find the first segment that contains stext and
uses that to replace the segment generated from just the kallsyms
information.  In this case, however, there were two: a very large
vmalloc segment, and the text segment.  This caused perf to get confused
because multiple overlapping segments were inserted into the RB tree
that holds the discovered segments.  However, that alone wasn't
sufficient to cause the problem. Even when we could find the segment,
the offsets were adjusted in such a way that the newly generated symbols
didn't line up with the instruction addresses in the trace.  The most
obvious solution would be to consult which segment type is text from
kcore, but this information is not exposed to users.

Instead, select the smallest matching segment that contains stext
instead of the first matching segment.  This allows us to match the text
segment instead of vmalloc, if one is contained within the other.

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Reaver <me@davidreaver.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20230125183418.GD1963@templeofstupid.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-05 18:27:37 +01:00
..
arch tools headers UAPI: Sync powerpc syscall tables with the kernel sources 2022-10-25 17:40:48 -03:00
bench parisc: Align parisc MADV_XXX constants with all other architectures 2023-01-14 10:33:40 +01:00
dlfilters
Documentation perf intel-pt: Do not try to queue auxtrace data on pipe 2023-03-10 09:33:26 +01:00
examples/bpf
include
jvmti
pmu-events perf vendor events power9: Remove UTF-8 characters from JSON files 2023-05-17 11:53:39 +02:00
python
scripts perf scripts intel-pt-events.py: Fix IPC output for Python 2 2023-05-17 11:53:39 +02:00
tests perf tests record_offcpu.sh: Fix redirection of stderr to stdin 2023-05-17 11:53:39 +02:00
trace tools headers uapi: Sync linux/stat.h with the kernel sources 2022-10-25 17:40:48 -03:00
ui perf tools: Fix "kernel lock contention analysis" test by not printing warnings in quiet mode 2022-12-31 13:32:44 +01:00
util perf symbols: Symbol lookup with kcore can fail if multiple segments match stext 2023-07-05 18:27:37 +01:00
.gitignore perf tools: Add the include/perf/ directory to .gitignore 2022-11-08 18:54:41 -03:00
Build
builtin-annotate.c perf tools: Make quiet mode consistent between tools 2022-12-31 13:33:07 +01:00
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf mem/c2c: Set PERF_SAMPLE_WEIGHT for LOAD_STORE events 2022-10-06 16:29:32 -03:00
builtin-config.c
builtin-daemon.c
builtin-data.c
builtin-diff.c perf tools: Make quiet mode consistent between tools 2022-12-31 13:33:07 +01:00
builtin-evlist.c
builtin-ftrace.c perf ftrace latency: Remove unnecessary "--" from --use-nsec option 2023-06-09 10:34:02 +02:00
builtin-help.c
builtin-inject.c perf inject: Fix --buildid-all not to eat up MMAP2 2023-03-17 08:50:14 +01:00
builtin-kallsyms.c
builtin-kmem.c perf kmem: Support field "node" in evsel__process_alloc_event() coping with recent tracepoint restructuring 2023-01-18 11:58:31 +01:00
builtin-kvm.c
builtin-kwork.c
builtin-list.c perf list: Fix metricgroups title message 2022-10-14 12:21:42 -03:00
builtin-lock.c perf lock contention: Fix core dump related to not finding the "__sched_text_end" symbol on s/390 2023-01-12 12:02:30 +01:00
builtin-mem.c perf mem: Fix -C option behavior for perf mem record 2022-10-14 12:21:34 -03:00
builtin-probe.c perf probe: Check -v and -q options in the right place 2022-12-31 13:33:08 +01:00
builtin-record.c perf record: Fix "read LOST count failed" msg with sample read 2023-05-17 11:53:39 +02:00
builtin-report.c perf tools: Make quiet mode consistent between tools 2022-12-31 13:33:07 +01:00
builtin-sched.c perf sched: Factor out destroy_tasks() 2022-10-04 08:55:21 -03:00
builtin-script.c perf script: Add missing fields in usage hint 2022-10-06 16:32:20 -03:00
builtin-stat.c perf stat: Separate bperf from bpf_profiler 2023-05-17 11:53:41 +02:00
builtin-timechart.c perf timechart: Add p_state_end helper 2022-10-04 08:55:21 -03:00
builtin-top.c perf top: Fix error code in cmd_top() 2022-10-04 08:55:22 -03:00
builtin-trace.c perf build: Properly guard libbpf includes 2023-01-18 11:58:31 +01:00
builtin-version.c
builtin.h
check-headers.sh tools headers: Update the copy of x86's memcpy_64.S used in 'perf bench' 2022-10-25 17:40:48 -03:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config perf bpf: Fix build with libbpf 0.7.0 by checking if bpf_program__set_insns() is available 2022-10-25 17:40:48 -03:00
Makefile.perf perf test: Add arm64 asm pureloop test shell script 2022-10-06 14:50:49 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-03-10 09:33:27 +01:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c
perf.h