]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.54/perf-record-fix-s390-missing-module-symbol-and-warni.patch
Linux 4.19.54
[thirdparty/kernel/stable-queue.git] / releases / 4.19.54 / perf-record-fix-s390-missing-module-symbol-and-warni.patch
CommitLineData
a15a8890
SL
1From 6927a3d41c74f37e4350743d9b255a9b6d711a1b Mon Sep 17 00:00:00 2001
2From: Thomas Richter <tmricht@linux.ibm.com>
3Date: Wed, 22 May 2019 16:46:01 +0200
4Subject: perf record: Fix s390 missing module symbol and warning for non-root
5 users
6
7[ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ]
8
9Command 'perf record' and 'perf report' on a system without kernel
10debuginfo packages uses /proc/kallsyms and /proc/modules to find
11addresses for kernel and module symbols. On x86 this works for root and
12non-root users.
13
14On s390, when invoked as non-root user, many of the following warnings
15are shown and module symbols are missing:
16
17 proc/{kallsyms,modules} inconsistency while looking for
18 "[sha1_s390]" module!
19
20Command 'perf record' creates a list of module start addresses by
21parsing the output of /proc/modules and creates a PERF_RECORD_MMAP
22record for the kernel and each module. The following function call
23sequence is executed:
24
25 machine__create_kernel_maps
26 machine__create_module
27 modules__parse
28 machine__create_module --> for each line in /proc/modules
29 arch__fix_module_text_start
30
31Function arch__fix_module_text_start() is s390 specific. It opens
32file /sys/module/<name>/sections/.text to extract the module's .text
33section start address. On s390 the module loader prepends a header
34before the first section, whereas on x86 the module's text section
35address is identical the the module's load address.
36
37However module section files are root readable only. For non-root the
38read operation fails and machine__create_module() returns an error.
39Command perf record does not generate any PERF_RECORD_MMAP record
40for loaded modules. Later command perf report complains about missing
41module maps.
42
43To fix this function arch__fix_module_text_start() always returns
44success. For root users there is no change, for non-root users
45the module's load address is used as module's text start address
46(the prepended header then counts as part of the text section).
47
48This enable non-root users to use module symbols and avoid the
49warning when perf report is executed.
50
51Output before:
52
53 [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
54 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
55
56Output after:
57
58 [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
59 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
60 0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz
61 0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz
62 0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz
63
64Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
65Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
66Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
67Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.com
68Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
69Signed-off-by: Sasha Levin <sashal@kernel.org>
70---
71 tools/perf/arch/s390/util/machine.c | 9 ++++++---
72 1 file changed, 6 insertions(+), 3 deletions(-)
73
74diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
75index 0b2054007314..a19690a17291 100644
76--- a/tools/perf/arch/s390/util/machine.c
77+++ b/tools/perf/arch/s390/util/machine.c
78@@ -5,16 +5,19 @@
79 #include "util.h"
80 #include "machine.h"
81 #include "api/fs/fs.h"
82+#include "debug.h"
83
84 int arch__fix_module_text_start(u64 *start, const char *name)
85 {
86+ u64 m_start = *start;
87 char path[PATH_MAX];
88
89 snprintf(path, PATH_MAX, "module/%.*s/sections/.text",
90 (int)strlen(name) - 2, name + 1);
91-
92- if (sysfs__read_ull(path, (unsigned long long *)start) < 0)
93- return -1;
94+ if (sysfs__read_ull(path, (unsigned long long *)start) < 0) {
95+ pr_debug2("Using module %s start:%#lx\n", path, m_start);
96+ *start = m_start;
97+ }
98
99 return 0;
100 }
101--
1022.20.1
103