]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/perf-record-fix-s390-missing-module-symbol-and-warni.patch
Linux 5.1.13
[thirdparty/kernel/stable-queue.git] / queue-4.19 / perf-record-fix-s390-missing-module-symbol-and-warni.patch
1 From 6927a3d41c74f37e4350743d9b255a9b6d711a1b Mon Sep 17 00:00:00 2001
2 From: Thomas Richter <tmricht@linux.ibm.com>
3 Date: Wed, 22 May 2019 16:46:01 +0200
4 Subject: perf record: Fix s390 missing module symbol and warning for non-root
5 users
6
7 [ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ]
8
9 Command 'perf record' and 'perf report' on a system without kernel
10 debuginfo packages uses /proc/kallsyms and /proc/modules to find
11 addresses for kernel and module symbols. On x86 this works for root and
12 non-root users.
13
14 On s390, when invoked as non-root user, many of the following warnings
15 are shown and module symbols are missing:
16
17 proc/{kallsyms,modules} inconsistency while looking for
18 "[sha1_s390]" module!
19
20 Command 'perf record' creates a list of module start addresses by
21 parsing the output of /proc/modules and creates a PERF_RECORD_MMAP
22 record for the kernel and each module. The following function call
23 sequence 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
31 Function arch__fix_module_text_start() is s390 specific. It opens
32 file /sys/module/<name>/sections/.text to extract the module's .text
33 section start address. On s390 the module loader prepends a header
34 before the first section, whereas on x86 the module's text section
35 address is identical the the module's load address.
36
37 However module section files are root readable only. For non-root the
38 read operation fails and machine__create_module() returns an error.
39 Command perf record does not generate any PERF_RECORD_MMAP record
40 for loaded modules. Later command perf report complains about missing
41 module maps.
42
43 To fix this function arch__fix_module_text_start() always returns
44 success. For root users there is no change, for non-root users
45 the 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
48 This enable non-root users to use module symbols and avoid the
49 warning when perf report is executed.
50
51 Output before:
52
53 [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
54 0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
55
56 Output 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
64 Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
65 Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
66 Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
67 Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.com
68 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
69 Signed-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
74 diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c
75 index 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 --
102 2.20.1
103