• Thomas Richter's avatar
    perf record: Fix s390 missing module symbol and warning for non-root users · 60a3e3b9
    Thomas Richter authored
    [ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ]
    
    Command 'perf record' and 'perf report' on a system without kernel
    debuginfo packages uses /proc/kallsyms and /proc/modules to find
    addresses for kernel and module symbols. On x86 this works for root and
    non-root users.
    
    On s390, when invoked as non-root user, many of the following warnings
    are shown and module symbols are missing:
    
        proc/{kallsyms,modules} inconsistency while looking for
            "[sha1_s390]" module!
    
    Command 'perf record' creates a list of module start addresses by
    parsing the output of /proc/modules and creates a PERF_RECORD_MMAP
    record for the kernel and each module. The following function call
    sequence is executed:
    
      machine__create_kernel_maps
        machine__create_module
          modules__parse
            machine__create_module --> for each line in /proc/modules
              arch__fix_module_text_start
    
    Function arch__fix_module_text_start() is s390 specific. It opens
    file /sys/module/<name>/sections/.text to extract the module's .text
    section start address. On s390 the module loader prepends a header
    before the first section, whereas on x86 the module's text section
    address is identical the the module's load address.
    
    However module section files are root readable only. For non-root the
    read operation fails and machine__create_module() returns an error.
    Command perf record does not generate any PERF_RECORD_MMAP record
    for loaded modules. Later command perf report complains about missing
    module maps.
    
    To fix this function arch__fix_module_text_start() always returns
    success. For root users there is no change, for non-root users
    the module's load address is used as module's text start address
    (the prepended header then counts as part of the text section).
    
    This enable non-root users to use module symbols and avoid the
    warning when perf report is executed.
    
    Output before:
    
      [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
      0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
    
    Output after:
    
      [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
      0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
      0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz
      0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz
      0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz
    Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
    Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.ibm.com>
    Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
    Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    60a3e3b9
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
bpf Loading commit data...
build Loading commit data...
cgroup Loading commit data...
firewire Loading commit data...
gpio Loading commit data...
hv Loading commit data...
iio Loading commit data...
include Loading commit data...
kvm/kvm_stat Loading commit data...
laptop Loading commit data...
leds Loading commit data...
lib Loading commit data...
memory-model Loading commit data...
nfsd Loading commit data...
objtool Loading commit data...
pci Loading commit data...
pcmcia Loading commit data...
perf Loading commit data...
power Loading commit data...
scripts Loading commit data...
spi Loading commit data...
testing Loading commit data...
thermal/tmon Loading commit data...
time Loading commit data...
usb Loading commit data...
virtio Loading commit data...
vm Loading commit data...
wmi Loading commit data...
Makefile Loading commit data...