1. 23 8月, 2019 8 次提交
  2. 22 8月, 2019 3 次提交
  3. 20 8月, 2019 4 次提交
    • L
      perf cs-etm: Support sample flags 'insn' and 'insnlen' · a4973d8f
      Leo Yan 提交于
      The synthetic branch and instruction samples are missed to set
      instruction related info, thus the perf tool fails to display samples
      with flags '-F,+insn,+insnlen'.
      
      The CoreSight trace decoder provides sufficient information to decide
      the instruction size based on the ISA type: A64/A32 instructions are
      32-bit size, but one exception is the T32 instruction size, which might
      be 32-bit or 16-bit.
      
      This patch handles these cases and it reads the instruction values from
      DSO file; thus can support the flags '-F,+insn,+insnlen'.
      
      Before:
      
        # perf script -F,insn,insnlen,ip,sym
                      0 [unknown] ilen: 0
           ffff97174044 _start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
           ffff97174938 _dl_start ilen: 0
      
        [...]
      
      After:
      
        # perf script -F,insn,insnlen,ip,sym
                      0 [unknown] ilen: 0
           ffff97174044 _start ilen: 4 insn: 2f 02 00 94
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
           ffff97174938 _dl_start ilen: 4 insn: c1 ff ff 54
      
        [...]
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Tested-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Walker <robert.walker@arm.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190815082854.18191-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a4973d8f
    • A
      perf report: Dump LBR callstack data by -D jointly with thread stack · d2720c3d
      Alexey Budankov 提交于
      Make perf report -D command print captured LBR callstack chain when it is
      collected together with raw thread stack data:
      
        2752673087247083 0x5d10 [0x548]: PERF_RECORD_SAMPLE(IP, 0x4002): 5841/5841: 0x40121f period: 1543862 addr: 0
        ... FP chain: nr:0
        ... branch callstack: nr:3
        .....  0: 00000000004011d0
        .....  1: 00007f393c388411
        .....  2: 0000000000401098
        ... user regs: mask 0xff0fff ABI 64-bit
        .... AX    0x34e7
        .... BX    0x7fff5f6dd3c0
        .... CX    0xffffffff
        .... DX    0x34e6
        .... SI    0x7f393c5268d0
        .... DI    0x0
        .... BP    0x401260
        .... SP    0x7fff5f6dd3c0
        .... IP    0x40121f
        .... FLAGS 0x29f
        .... CS    0x33
        .... SS    0x2b
        .... R8    0x7f393c526800
        .... R9    0x7f393c525da0
        .... R10   0xfffffffffffff70a
        .... R11   0x246
        .... R12   0x401070
        .... R13   0x7fff5f6ddcb0
        .... R14   0x0
        .... R15   0x0
        ... ustack: size 1024, offset 0x130
         . data_src: 0x5080021
         ... thread: stack_test:5841
         ...... dso: /root/abudanko/stacks/stack_test
      
      Committer testing:
      
        # perf record -g --call-graph dwarf,1024 -j stack,u ls > /dev/null
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.042 MB perf.data (10 samples) ]
        #
      
      Before:
      
        # perf report -D |& grep PERF_RECORD_SAMPLE -A28 | tail -29
        67538909824483 0xa7a0 [0x560]: PERF_RECORD_SAMPLE(IP, 0x4002): 9721/9721: 0x7f441b2b1e20 period: 1376095 addr: 0
        ... FP chain: nr:0
        ... user regs: mask 0xff0fff ABI 64-bit
        .... AX    0x7f441b2b1000
        .... BX    0x7f441b55b970
        .... CX    0x7fff6e2db218
        .... DX    0x7fff6e2db218
        .... SI    0x7fff6e2db208
        .... DI    0x1
        .... BP    0x1
        .... SP    0x7fff6e2db178
        .... IP    0x7f441b2b1e20
        .... FLAGS 0x20a
        .... CS    0x33
        .... SS    0x2b
        .... R8    0x1
        .... R9    0x7f441b371c18
        .... R10   0x7f441b5a5f10
        .... R11   0x202
        .... R12   0x7fff6e2db208
        .... R13   0x7fff6e2db218
        .... R14   0x7f441b5a7150
        .... R15   0x0
        ... ustack: size 1024, offset 0x148
         . data_src: 0x5080021
         ... thread: ls:9721
         ...... dso: /usr/lib64/libpthread-2.29.so
      
        0xad00 [0x60]: event: 10
        #
      
      After:
      
        # perf report -D |& grep PERF_RECORD_SAMPLE -A31 | tail -32
        67538909824483 0xa7a0 [0x560]: PERF_RECORD_SAMPLE(IP, 0x4002): 9721/9721: 0x7f441b2b1e20 period: 1376095 addr: 0
        ... FP chain: nr:0
        ... branch callstack: nr:4
        .....  0: 00007f441b2b1e20
        .....  1: 00007f441b58af1a
        .....  2: 00007f441b58b0e1
        .....  3: 00007f441b57c145
        ... user regs: mask 0xff0fff ABI 64-bit
        .... AX    0x7f441b2b1000
        .... BX    0x7f441b55b970
        .... CX    0x7fff6e2db218
        .... DX    0x7fff6e2db218
        .... SI    0x7fff6e2db208
        .... DI    0x1
        .... BP    0x1
        .... SP    0x7fff6e2db178
        .... IP    0x7f441b2b1e20
        .... FLAGS 0x20a
        .... CS    0x33
        .... SS    0x2b
        .... R8    0x1
        .... R9    0x7f441b371c18
        .... R10   0x7f441b5a5f10
        .... R11   0x202
        .... R12   0x7fff6e2db208
        .... R13   0x7fff6e2db218
        .... R14   0x7f441b5a7150
        .... R15   0x0
        ... ustack: size 1024, offset 0x148
         . data_src: 0x5080021
         ... thread: ls:9721
         ...... dso: /usr/lib64/libpthread-2.29.so
        #
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/aa82e5dd-def2-0ca8-a064-db9e2e8ad076@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d2720c3d
    • A
      perf record: Enable LBR callstack capture jointly with thread stack · 25663496
      Alexey Budankov 提交于
      Enable '-j stack' applicability together with '--call-graph dwarf'
      option so thread stack data and LBR call stack could be captured
      jointly:
      
        $ perf record -g --call-graph dwarf,1024 -j stack,u -- stack_test
      
      Collected LBR call stack can be used to augment DWARF call stack
      calculated from the raw thread stack data and to provide more
      comprehensive call stack information for cases when collected SIZE is
      not enough to cover complete thread stack.
      
      Such cases are typical for workloads that allocate large arrays of data
      on its threads stacks or the possible SIZE to collect can't be large
      enough due to workload nature or system configuration and this is where
      hardware captured LBR call stacks can provide missing stack frames.
      Possible DWARF plus LBR call stacks consolidation algorithm description
      follows.
      
      With this patch set perf report command UI currently ignores collected
      LBR call stack data and still provides DWARF based call stacks
      information.
      
        ===========================================================================
      
        Overview:
      
         Legend:
      
         THS - thread stack
         CTX - thread register context
         SWS - software stack
         SSF - skipped stack frames
         PSS - Perf sample stack
      
         ip,sp,bp - HW registers values
         d        - allocated stack regions
         kip      - ip address in the kernel space
         K        - captured thread stack size
      
              THS
      
             -----
             |   |<-stack bottom
              ...
             |---|
             |ip4|
             |---|         PSS = SWS(THS(K))
             |   |
         --> |   |
         |   |d3 |                  user/
         |   |---|         user PSS kernel PSS
         |   |ip3|         ------   ------
         |   |---|         |SSF |   |SSF |
         |   |   |          ....     ....
         |   |   |         ------   ------
         |   |d2 |         | -1 |   | -1 |
             |---|   user  ------   ------
         K   |ip2|   CTX   |ip3 |   |ip3 |
             |---|         |----|   |----|
         |   |d1 |   ...   |ip2 | , |ip2 |
         |   |---|  |---|  |----|   |----|
         |   |ip1|  |bp0|  |ip1 |   |ip1 |
         |   |---|  |---|  |----|   |----|
         |   |   |  |ip0|->|ip0 |   |ip0 |<-user stack top
         |   |   |  |---|  ------   ------
         |   |   |<-|sp0|<-stack    |kip0|<-kernel stack bottom
         --> -----  -----   top     |----|
                                    |kip1|
                                    |----|
      		              |kip2|
      		              |----|
                                     ....
      			      |    |<-kernel stack top
                                    ------
      
        Algorithm details:
      
         Legend:
      
         HWS - hardware stack
         K-SWS - kernel software stack
      
      			 BRANCH
      			 TABLE
      
      		 HWS      ip   ip
      			  from to
      		 ------  -----------
      		 |ip7`|  |ip7`|    |
      		 |----|  |----|----|
      		 |ip6`|  |ip6`|    |
      	user PSS |----|  |----|----|
      		 |ip5`|  |ip5`|    |
      	------   |----|  |----|----|
      	| -1 |   |ip4`|  |ip4`|    |
      	------   |----|  |----|----|
      	|ip3 |~~~|ip3`|  |ip3`|    |
      	|----|   |----|  |----|----|
      	|ip2 |~~~|ip2`|  |ip2`|    |
      	|----| 	 |----|  |----|----|
      	|ip1 |~~~|ip1`|  |ip1`|ip0`|
      	|----| 	 |----|  -----------
      	|ip0 |~~~|ip0`|<---------'
      	------   ------
      
      	1. if (sym(ipj) == sym(ipj`)), j=0-3 ===> user PSS
      	2. ipj`                      , j=4-7 ===> user PSS
      
        Augmented PSS = A_SWS(SWS(THS(K)), HWS):
      
      	         user/
             user PSS  kernel PSS
      
      	------   ------
      	|ip7`|   |ip7`|<-user PSS bottom
      	|----|   |----|
      	|ip6`|   |ip6`|
      	|----|   |----|
          HWS	|ip5`|   |ip5`|
      	|----|   |----|
      	|ip4`|   |ip4`|
      	------   ------
      	|ip3 |   |ip3 |
      	|----|   |----|
          SWS |ip2 |   |ip2 |
      	|----|   |----|
      	|ip1 |   |ip1 |
      	|----|   |----|
      	|ip0 |   |ip0 |<-user PSS top
      	------   ------
      		 |kip0|<-kernel PSS bottom
      		 |----|
      		 |kip1|
      	   K-SWS |----|
      		 |kip2|
      		 |----|
      		 |kip3|<-kernel PSS top
      		 ------
      
                        APSS
      
      Committer testing:
      
      Before:
      
        # perf record -g --call-graph dwarf,1024 -j stack,u ls > /dev/null
        unknown branch filter stack, check man page
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -j, --branch-filter <branch filter mask>
                                  branch stack filter modes
        # perf record -g --call-graph dwarf,1024 -j u ls > /dev/null
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.054 MB perf.data (12 samples) ]
        # perf evlist -v
        cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|PERIOD|BRANCH_STACK|REGS_USER|STACK_USER|DATA_SRC, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, mmap_data: 1, sample_id_all: 1, exclude_guest: 1, exclude_callchain_user: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY, sample_regs_user: 0xff0fff, sample_stack_user: 1024
         #
      
      After:
      
        # perf record -g --call-graph dwarf,1024 -j stack,u ls > /dev/null
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.044 MB perf.data (11 samples) ]
        [root@quaco ~]# perf evlist -v
        cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|PERIOD|BRANCH_STACK|REGS_USER|STACK_USER|DATA_SRC, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, mmap_data: 1, sample_id_all: 1, exclude_guest: 1, exclude_callchain_user: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: USER|CALL_STACK, sample_regs_user: 0xff0fff, sample_stack_user: 1024
        #
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/e9e00090-66fb-d2a4-c90f-1d12344f7788@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      25663496
    • A
      perf evsel: Add comment for 'idx' member in 'struct perf_sample_id · 3c84e65a
      Adrian Hunter 提交于
      The 'idx' member was added as preparation for AUX area sampling. Add a
      comment to describe why.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/83ff264f-84c3-5372-8976-dd9293d20c6f@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c84e65a
  4. 16 8月, 2019 4 次提交
    • J
      perf unwind: Remove unnecessary test · e2736219
      John Keeping 提交于
      If dwarf_callchain_users is false, then unwind__prepare_access() will
      not set unwind_libunwind_ops so the remaining test here is sufficient.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: john keeping <john@metanate.com>
      Link: http://lkml.kernel.org/r/20190815100146.28842-3-john@metanate.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e2736219
    • J
      perf unwind: Fix libunwind when tid != pid · e8ba2906
      John Keeping 提交于
      Commit e5adfc3e ("perf map: Synthesize maps only for thread group
      leader") changed the recording side so that we no longer get mmap events
      for threads other than the thread group leader (when synthesising these
      events for threads which exist before perf is started).
      
      When a file recorded after this change is loaded, the lack of mmap
      records mean that unwinding is not set up for any other threads.
      
      This can be seen in a simple record/report scenario:
      
      	perf record --call-graph=dwarf -t $TID
      	perf report
      
      If $TID is a process ID then the report will show call graphs, but if
      $TID is a secondary thread the output is as if --call-graph=none was
      specified.
      
      Following the rationale in that commit, move the libunwind fields into
      struct map_groups and update the libunwind functions to take this
      instead of the struct thread.  This is only required for
      unwind__finish_access which must now be called from map_groups__delete
      and the others are changed for symmetry.
      
      Note that unwind__get_entries keeps the thread argument since it is
      required for symbol lookup and the libdw unwind provider uses the thread
      ID.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: e5adfc3e ("perf map: Synthesize maps only for thread group leader")
      Link: http://lkml.kernel.org/r/20190815100146.28842-2-john@metanate.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e8ba2906
    • J
      perf map: Use zalloc for map_groups · ab6cd0e5
      John Keeping 提交于
      In the next commit we will add new fields to map_groups and we need
      these to be null if no value is assigned.  The simplest way to achieve
      this is to request zeroed memory from the allocator.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: john keeping <john@metanate.com>
      Link: http://lkml.kernel.org/r/20190815100146.28842-1-john@metanate.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ab6cd0e5
    • A
      perf top: Add --switch-on/--switch-off events · 2f53ae34
      Arnaldo Carvalho de Melo 提交于
      Just like 'perf trace' and 'perf script', should be useful for instance
      to only consider samples after the initialization phase of some
      workload.
      
      The man page has some examples and considerations about its current
      interface, that still doesn't handle the on/off events in a special way,
      behaving just like when multiple events are specified, i.e.:
      
      - In non-group mode (when the event list is not enclosed in {}) show a
        a menu to allow choosing which event the user wants to see in the
        histograms browser
      
      - In group mode, be it using {} or asking for --group, show one column
        per event.
      
      Try for instance:
      
        # perf top -e '{cycles,instructions,probe:icmp_rcv}' --switch-on=probe:icmp_rcv
      
      Replace probe:icmp_rcv, that I put in place using:
      
        # perf probe icmp_rcv:59
      
      To hit when broadcast packets arrive, with a probe installed after an
      initialization phase is over or after some other point of interest, some
      garbage collection, etc, and also use --switch-off, for instance, on a
      probe installed after said garbage collection is over.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: William Cohen <wcohen@redhat.com>
      Link: https://lkml.kernel.org/n/tip-c7q7qjeqtyvc9mkeipxza6ne@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2f53ae34
  5. 15 8月, 2019 7 次提交
  6. 14 8月, 2019 9 次提交
  7. 13 8月, 2019 3 次提交
  8. 09 8月, 2019 2 次提交
    • T
      perf annotate: Fix s390 gap between kernel end and module start · b9c0a649
      Thomas Richter 提交于
      During execution of command 'perf top' the error message:
      
         Not enough memory for annotating '__irf_end' symbol!)
      
      is emitted from this call sequence:
        __cmd_top
          perf_top__mmap_read
            perf_top__mmap_read_idx
              perf_event__process_sample
                hist_entry_iter__add
                  hist_iter__top_callback
                    perf_top__record_precise_ip
                      hist_entry__inc_addr_samples
                        symbol__inc_addr_samples
                          symbol__get_annotation
                            symbol__alloc_hist
      
      In this function the size of symbol __irf_end is calculated. The size of
      a symbol is the difference between its start and end address.
      
      When the symbol was read the first time, its start and end was set to:
      
         symbol__new: __irf_end 0xe954d0-0xe954d0
      
      which is correct and maps with /proc/kallsyms:
      
         root@s8360046:~/linux-4.15.0/tools/perf# fgrep _irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         root@s8360046:~/linux-4.15.0/tools/perf#
      
      In function symbol__alloc_hist() the end of symbol __irf_end is
      
        symbol__alloc_hist sym:__irf_end start:0xe954d0 end:0x3ff80045a8
      
      which is identical with the first module entry in /proc/kallsyms
      
      This results in a symbol size of __irf_req for histogram analyses of
      70334140059072 bytes and a malloc() for this requested size fails.
      
      The root cause of this is function
        __dso__load_kallsyms()
        +-> symbols__fixup_end()
      
      Function symbols__fixup_end() enlarges the last symbol in the kallsyms
      map:
      
         # fgrep __irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         #
      
      to the start address of the first module:
         # cat /proc/kallsyms | sort  | egrep ' [tT] '
         ....
         0000000000e952d0 T __security_initcall_end
         0000000000e954d0 T __initramfs_size
         0000000000e954d0 t __irf_end
         000003ff800045a8 T fc_get_event_number       [scsi_transport_fc]
         000003ff800045d0 t store_fc_vport_disable    [scsi_transport_fc]
         000003ff800046a8 T scsi_is_fc_rport  [scsi_transport_fc]
         000003ff800046d0 t fc_target_setup   [scsi_transport_fc]
      
      On s390 the kernel is located around memory address 0x200, 0x10000 or
      0x100000, depending on linux version. Modules however start some- where
      around 0x3ff xxxx xxxx.
      
      This is different than x86 and produces a large gap for which histogram
      allocation fails.
      
      Fix this by detecting the kernel's last symbol and do no adjustment for
      it. Introduce a weak function and handle s390 specifics.
      Reported-by: NKlaus Theurich <klaus.theurich@de.ibm.com>
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190724122703.3996-2-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b9c0a649
    • T
      perf record: Fix module size on s390 · 12a6d294
      Thomas Richter 提交于
      On s390 the modules loaded in memory have the text segment located after
      the GOT and Relocation table. This can be seen with this output:
      
        [root@m35lp76 perf]# fgrep qeth /proc/modules
        qeth 151552 1 qeth_l2, Live 0x000003ff800b2000
        ...
        [root@m35lp76 perf]# cat /sys/module/qeth/sections/.text
        0x000003ff800b3990
        [root@m35lp76 perf]#
      
      There is an offset of 0x1990 bytes. The size of the qeth module is
      151552 bytes (0x25000 in hex).
      
      The location of the GOT/relocation table at the beginning of a module is
      unique to s390.
      
      commit 203d8a4a ("perf s390: Fix 'start' address of module's map")
      adjusts the start address of a module in the map structures, but does
      not adjust the size of the modules. This leads to overlapping of module
      maps as this example shows:
      
      [root@m35lp76 perf] # ./perf report -D
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x25000)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x8000)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      
      The module qeth.ko has an adjusted start address modified to b3990, but
      its size is unchanged and the module ends at 0x3ff800d8990.  This end
      address overlaps with the next modules start address of 0x3ff800d85a0.
      
      When the size of the leading GOT/Relocation table stored in the
      beginning of the text segment (0x1990 bytes) is subtracted from module
      qeth end address, there are no overlaps anymore:
      
         0x3ff800d8990 - 0x1990 = 0x0x3ff800d7000
      
      which is the same as
      
         0x3ff800b2000 + 0x25000 = 0x0x3ff800d7000.
      
      To fix this issue, also adjust the modules size in function
      arch__fix_module_text_start(). Add another function parameter named size
      and reduce the size of the module when the text segment start address is
      changed.
      
      Output after:
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x23670)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x7a60)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      Reported-by: NStefan Liebler <stli@linux.ibm.com>
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Fixes: 203d8a4a ("perf s390: Fix 'start' address of module's map")
      Link: http://lkml.kernel.org/r/20190724122703.3996-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      12a6d294