1. 14 9月, 2016 11 次提交
  2. 12 9月, 2016 2 次提交
    • N
      perf hists browser: Fix event group display · d9ea48bc
      Namhyung Kim 提交于
      Milian reported that the event group on TUI shows duplicated overhead.
      This was due to a bug on calculating hpp->buf position.  The
      hpp_advance() was called from __hpp__slsmg_color_printf() on TUI but
      it's already called from the hpp__call_print_fn macro in __hpp__fmt().
      The end result is that the print function returns number of bytes it
      printed but the buffer advanced twice of the length.
      
      This is generally not a problem since it doesn't need to access the
      buffer again.  But with event group, overhead needs to be printed
      multiple times and hist_entry__snprintf_alignment() tries to fill the
      space with buffer after it printed.  So it (brokenly) showed the last
      overhead again.
      
      The bug was there from the beginning, but I think it's only revealed
      when the alignment function was added.
      Reported-by: NMilian Wolff <milian.wolff@kdab.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Fixes: 89fee709 ("perf hists: Do column alignment on the format iterator")
      Link: http://lkml.kernel.org/r/20160912061958.16656-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d9ea48bc
    • A
      perf probe: Fix dwarf regs table for x86_64 · 7a023fd2
      Arnaldo Carvalho de Melo 提交于
      In 293d5b43 ("perf probe: Support probing on offline cross-arch binary")
      DWARF register tables were introduced for many architectures, with the one for
      the "dx" register being broken for x86_64, which got noticed by the 'perf test
      bpf' testcase, that has this difference from a successful run to one that
      fails, with the aforementioned patch:
      
        -Writing event: p:perf_bpf_probe/func _text+5197232 f_mode=+68(%di):x32 offset=%si:s64 orig=dx:s32
        -Failed to write event: Invalid argument
        -bpf_probe: failed to apply perf probe eventsFailed to add events selected by BPF
        +Writing event: p:perf_bpf_probe/func _text+5197232 f_mode=+68(%di):x32 offset=%si:s64 orig=%dx:s32
      
      Add the missing '%' to '%dx' to fix this.
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 293d5b43 ("perf probe: Support probing on offline cross-arch binary")
      Link: https://lkml.kernel.org/r/20160909145955.GC32585@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a023fd2
  3. 09 9月, 2016 4 次提交
    • R
      perf powerpc: Fix build-test failure · 25b8592e
      Ravi Bangoria 提交于
      'make -C tools/perf build-test' is failing with below log for poewrpc.
      
        In file included from /tmp/tmp.3eEwmGlYaF/perf-4.8.0-rc4/tools/perf/perf.h:15:0,
                         from util/cpumap.h:8,
                         from util/env.c:1:
        /tmp/tmp.3eEwmGlYaF/perf-4.8.0-rc4/tools/perf/perf-sys.h:23:56:
        fatal error: ../../arch/powerpc/include/uapi/asm/unistd.h: No such file or directory
        compilation terminated.
      
      I bisected it and found it's failing from commit ad430729 ("Remove:
      kernel unistd*h files from perf's MANIFEST, not used").
      
      Header file '../../arch/powerpc/include/uapi/asm/unistd.h' is included
      only for powerpc in tools/perf/perf-sys.h.
      
      By looking closly at commit history, I found little weird thing:
      
      Commit f2d9cae9 ("perf powerpc: Use uapi/unistd.h to fix build
      error") replaced 'asm/unistd.h' with 'uapi/asm/unistd.h'
      
      Commit d2709c7c ("perf: Make perf build for x86 with UAPI
      disintegration applied") removes all arch specific 'uapi/asm/unistd.h'
      for all archs and adds generic <asm/unistd.h>.
      
      Commit f0b9abfb ("Merge branch 'linus' into perf/core") again
      includes 'uapi/asm/unistd.h' for powerpc. Don't know how exactly this
      happened as this change is not part of commit also.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1472630591-5089-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com
      Fixes: ad430729 ("Remove: kernel unistd*h files from perf's MANIFEST, not used")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      25b8592e
    • M
      perf pmu: Support alternative sysfs cpumask · 7e3fcffe
      Mark Rutland 提交于
      The perf tools can read a cpumask file for a PMU, describing a subset of
      CPUs which that PMU covers. So far this has only been used to cater for
      uncore PMUs, which in practice happen to only have a single CPU
      described in the mask.
      
      Until recently, the perf tools only correctly handled cpumask containing
      a single CPU, and only when monitoring in system-wide mode. For example,
      prior to commit 00e727bb ("perf stat: Balance opening and
      reading events"), a mask with more than a single CPU could cause perf
      stat to hang. When a CPU PMU covers a subset of CPUs, but lacks a
      cpumask, perf record will fail to open events (on the cores the PMU does
      not support), and gives up.
      
      For systems with heterogeneous CPUs such as ARM big.LITTLE systems, this
      presents a problem. We have a PMU for each microarchitecture (e.g. a big
      PMU and a little PMU), and would like to expose a cpumask for each (so
      as to allow perf record and other tools to do the right thing). However,
      doing so kernel-side will cause old perf binaries to not function (e.g.
      hitting the issue solved by 00e727bb), and thus commits the
      cardinal sin of breaking (existing) userspace.
      
      To address this chicken-and-egg problem, this patch adds support got a
      new file, cpus, which is largely identical to the existing cpumask file.
      A kernel can expose this file, knowing that new perf binaries will
      correctly support it, while old perf binaries will not look for it (and
      thus will not be broken).
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: http://lkml.kernel.org/r/1473330112-28528-8-git-send-email-mark.rutland@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7e3fcffe
    • M
      perf evlist: Only open events on CPUs an evsel permits · 9f21b815
      Mark Rutland 提交于
      In systems with heterogeneous CPU PMUs, it's possible for each evsel to
      cover a distinct set of CPUs, and hence the cpu_map associated with each
      evsel may have a distinct idx<->id mapping. Any of these may be distinct
      from the evlist's cpu map.
      
      Events can be tied to the same fd so long as they use the same per-cpu
      ringbuffer (i.e. so long as they are on the same CPU). To acquire the
      correct FDs, we must compare the Linux logical IDs rather than the evsel
      or evlist indices.
      
      This path adds logic to perf_evlist__mmap_per_evsel to handle this,
      translating IDs as required. As PMUs may cover a subset of CPUs from the
      evlist, we skip the CPUs a PMU cannot handle.
      
      Without this patch, perf record may try to mmap erroneous FDs on
      heterogeneous systems, and will bail out early rather than running the
      workload.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: http://lkml.kernel.org/r/1473330112-28528-7-git-send-email-mark.rutland@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9f21b815
    • P
      perf annotate: Add branch stack / basic block · 70fbe057
      Peter Zijlstra 提交于
      I wanted to know the hottest path through a function and figured the
      branch-stack (LBR) information should be able to help out with that.
      
      The below uses the branch-stack to create basic blocks and generate
      statistics from them.
      
              from    to              branch_i
              * ----> *
                      |
                      | block
                      v
                      * ----> *
                      from    to      branch_i+1
      
      The blocks are broken down into non-overlapping ranges, while tracking
      if the start of each range is an entry point and/or the end of a range
      is a branch.
      
      Each block iterates all ranges it covers (while splitting where required
      to exactly match the block) and increments the 'coverage' count.
      
      For the range including the branch we increment the taken counter, as
      well as the pred counter if flags.predicted.
      
      Using these number we can find if an instruction:
      
       - had coverage; given by:
      
              br->coverage / br->sym->max_coverage
      
         This metric ensures each symbol has a 100% spot, which reflects the
         observation that each symbol must have a most covered/hottest
         block.
      
       - is a branch target: br->is_target && br->start == add
      
       - for targets, how much of a branch's coverages comes from it:
      
      	target->entry / branch->coverage
      
       - is a branch: br->is_branch && br->end == addr
      
       - for branches, how often it was taken:
      
              br->taken / br->coverage
      
         after all, all execution that didn't take the branch would have
         incremented the coverage and continued onward to a later branch.
      
       - for branches, how often it was predicted:
      
              br->pred / br->taken
      
      The coverage percentage is used to color the address and asm sections;
      for low (<1%) coverage we use NORMAL (uncolored), indicating that these
      instructions are not 'important'. For high coverage (>75%) we color the
      address RED.
      
      For each branch, we add an asm comment after the instruction with
      information on how often it was taken and predicted.
      
      Output looks like (sans color, which does loose a lot of the
      information :/)
      
      $ perf record --branch-filter u,any -e cycles:p ./branches 27
      $ perf annotate branches
      
       Percent |	Source code & Disassembly of branches for cycles:pu (217 samples)
      ---------------------------------------------------------------------------------
               :	branches():
          0.00 :	  40057a:       push   %rbp
          0.00 :	  40057b:       mov    %rsp,%rbp
          0.00 :	  40057e:       sub    $0x20,%rsp
          0.00 :	  400582:       mov    %rdi,-0x18(%rbp)
          0.00 :	  400586:       mov    %rsi,-0x20(%rbp)
          0.00 :	  40058a:       mov    -0x18(%rbp),%rax
          0.00 :	  40058e:       mov    %rax,-0x10(%rbp)
          0.00 :	  400592:       movq   $0x0,-0x8(%rbp)
          0.00 :	  40059a:       jmpq   400656 <branches+0xdc>
          1.84 :	  40059f:       mov    -0x10(%rbp),%rax	# +100.00%
          3.23 :	  4005a3:       and    $0x1,%eax
          1.84 :	  4005a6:       test   %rax,%rax
          0.00 :	  4005a9:       je     4005bf <branches+0x45>	# -54.50% (p:42.00%)
          0.46 :	  4005ab:       mov    0x200bbe(%rip),%rax        # 601170 <acc>
         12.90 :	  4005b2:       add    $0x1,%rax
          2.30 :	  4005b6:       mov    %rax,0x200bb3(%rip)        # 601170 <acc>
          0.46 :	  4005bd:       jmp    4005d1 <branches+0x57>	# -100.00% (p:100.00%)
          0.92 :	  4005bf:       mov    0x200baa(%rip),%rax        # 601170 <acc>	# +49.54%
         13.82 :	  4005c6:       sub    $0x1,%rax
          0.46 :	  4005ca:       mov    %rax,0x200b9f(%rip)        # 601170 <acc>
          2.30 :	  4005d1:       mov    -0x10(%rbp),%rax	# +50.46%
          0.46 :	  4005d5:       mov    %rax,%rdi
          0.46 :	  4005d8:       callq  400526 <lfsr>	# -100.00% (p:100.00%)
          0.00 :	  4005dd:       mov    %rax,-0x10(%rbp)	# +100.00%
          0.92 :	  4005e1:       mov    -0x18(%rbp),%rax
          0.00 :	  4005e5:       and    $0x1,%eax
          0.00 :	  4005e8:       test   %rax,%rax
          0.00 :	  4005eb:       je     4005ff <branches+0x85>	# -100.00% (p:100.00%)
          0.00 :	  4005ed:       mov    0x200b7c(%rip),%rax        # 601170 <acc>
          0.00 :	  4005f4:       shr    $0x2,%rax
          0.00 :	  4005f8:       mov    %rax,0x200b71(%rip)        # 601170 <acc>
          0.00 :	  4005ff:       mov    -0x10(%rbp),%rax	# +100.00%
          7.37 :	  400603:       and    $0x1,%eax
          3.69 :	  400606:       test   %rax,%rax
          0.00 :	  400609:       jne    400612 <branches+0x98>	# -59.25% (p:42.99%)
          1.84 :	  40060b:       mov    $0x1,%eax
         14.29 :	  400610:       jmp    400617 <branches+0x9d>	# -100.00% (p:100.00%)
          1.38 :	  400612:       mov    $0x0,%eax	# +57.65%
         10.14 :	  400617:       test   %al,%al	# +42.35%
          0.00 :	  400619:       je     40062f <branches+0xb5>	# -57.65% (p:100.00%)
          0.46 :	  40061b:       mov    0x200b4e(%rip),%rax        # 601170 <acc>
          2.76 :	  400622:       sub    $0x1,%rax
          0.00 :	  400626:       mov    %rax,0x200b43(%rip)        # 601170 <acc>
          0.46 :	  40062d:       jmp    400641 <branches+0xc7>	# -100.00% (p:100.00%)
          0.92 :	  40062f:       mov    0x200b3a(%rip),%rax        # 601170 <acc>	# +56.13%
          2.30 :	  400636:       add    $0x1,%rax
          0.92 :	  40063a:       mov    %rax,0x200b2f(%rip)        # 601170 <acc>
          0.92 :	  400641:       mov    -0x10(%rbp),%rax	# +43.87%
          2.30 :	  400645:       mov    %rax,%rdi
          0.00 :	  400648:       callq  400526 <lfsr>	# -100.00% (p:100.00%)
          0.00 :	  40064d:       mov    %rax,-0x10(%rbp)	# +100.00%
          1.84 :	  400651:       addq   $0x1,-0x8(%rbp)
          0.92 :	  400656:       mov    -0x8(%rbp),%rax
          5.07 :	  40065a:       cmp    -0x20(%rbp),%rax
          0.00 :	  40065e:       jb     40059f <branches+0x25>	# -100.00% (p:100.00%)
          0.00 :	  400664:       nop
          0.00 :	  400665:       leaveq
          0.00 :	  400666:       retq
      
      (Note: the --branch-filter u,any was used to avoid spurious target and
      branch points due to interrupts/faults, they show up as very small -/+
      annotations on 'weird' locations)
      
      Committer note:
      
      Please take a look at:
      
        http://vger.kernel.org/~acme/perf/annotate_basic_blocks.png
      
      To see the colors.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      [ Moved sym->max_coverage to 'struct annotate', aka symbol__annotate(sym) ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70fbe057
  4. 08 9月, 2016 3 次提交
  5. 05 9月, 2016 5 次提交
  6. 01 9月, 2016 15 次提交
    • R
      perf probe: Move dwarf specific functions to dwarf-aux.c · 6243b9dc
      Ravi Bangoria 提交于
      Move generic dwarf related functions from util/probe-finder.c to
      util/dwarf-aux.c. Functions name and their prototype are also changed
      accordingly. No functionality changes.
      Suggested-and-Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1472546377-25612-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6243b9dc
    • R
      perf uprobe: Skip prologue if program compiled without optimization · e47392bf
      Ravi Bangoria 提交于
      The function prologue prepares stack and registers before executing
      function logic.
      
      When target program is compiled without optimization, function parameter
      information is only valid after the prologue.
      
      When we probe entrypc of the function, and try to record a function
      parameter, it contains a garbage value.
      
      For example:
      
        $ vim test.c
          #include <stdio.h>
      
          void foo(int i)
          {
             printf("i: %d\n", i);
          }
      
          int main()
          {
            foo(42);
            return 0;
          }
      
        $ gcc -g test.c -o test
        $ objdump -dl test | less
          foo():
          /home/ravi/test.c:4
            400536:       55                      push   %rbp
            400537:       48 89 e5                mov    %rsp,%rbp
            40053a:       48 83 ec 10             sub    -bashx10,%rsp
            40053e:       89 7d fc                mov    %edi,-0x4(%rbp)
          /home/ravi/test.c:5
            400541:       8b 45 fc                mov    -0x4(%rbp),%eax
          ...
          ...
          main():
          /home/ravi/test.c:9
            400558:       55                      push   %rbp
            400559:       48 89 e5                mov    %rsp,%rbp
          /home/ravi/test.c:10
            40055c:       bf 2a 00 00 00          mov    -bashx2a,%edi
            400561:       e8 d0 ff ff ff          callq  400536 <foo>
      
        $ perf probe -x ./test 'foo i'
        $ cat /sys/kernel/debug/tracing/uprobe_events
           p:probe_test/foo /home/ravi/test:0x0000000000000536 i=-12(%sp):s32
      
        $ perf record -e probe_test:foo ./test
        $ perf script
           test  5778 [001]  4918.562027: probe_test:foo: (400536) i=0
      
      Here variable 'i' is passed via stack which is pushed on stack at
      0x40053e. But we are probing at 0x400536.
      
      To resolve this issues, we need to probe on next instruction after
      prologue.  gdb and systemtap also does same thing. I've implemented this
      patch based on approach systemtap has used.
      
      After applying patch:
      
        $ perf probe -x ./test 'foo i'
        $ cat /sys/kernel/debug/tracing/uprobe_events
          p:probe_test/foo /home/ravi/test:0x0000000000000541 i=-4(%bp):s32
      
        $ perf record -e probe_test:foo ./test
        $ perf script
          test  6300 [001]  5877.879327: probe_test:foo: (400541) i=42
      
      No need to skip prologue for optimized case since debug info is correct
      for each instructions for -O2 -g. For more details please visit:
      
              https://bugzilla.redhat.com/show_bug.cgi?id=612253#c6
      
      Changes in v2:
      
      - Skipping prologue only when any ARG is either C variable, $params or
        $vars.
      
      - Probe on line(:1) may not be always possible. Recommend only address
        to force probe on function entry.
      
      Committer notes:
      
      Testing it with 'perf trace':
      
        # perf probe -x ./test foo i
        Added new event:
          probe_test:foo       (on foo in /home/acme/c/test with i)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_test:foo -aR sleep 1
      
        # cat /sys/kernel/debug/tracing/uprobe_events
        p:probe_test/foo /home/acme/c/test:0x0000000000000526 i=-12(%sp):s32
        # trace --no-sys --event probe_*:* ./test
        i: 42
           0.000 probe_test:foo:(400526) i=0)
        #
      
      After the patch:
      
        # perf probe -d *:*
        Removed event: probe_test:foo
        # perf probe -x ./test foo i
        Target program is compiled without optimization. Skipping prologue.
        Probe on address 0x400526 to force probing at the function entry.
      
        Added new event:
          probe_test:foo       (on foo in /home/acme/c/test with i)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe_test:foo -aR sleep 1
      
        # cat /sys/kernel/debug/tracing/uprobe_events
        p:probe_test/foo /home/acme/c/test:0x0000000000000531 i=-4(%bp):s32
        # trace --no-sys --event probe_*:* ./test
        i: 42
           0.000 probe_test:foo:(400531) i=42)
        #
      Reported-by: NMichael Petlan <mpetlan@redhat.com>
      Report-Link: https://www.mail-archive.com/linux-perf-users@vger.kernel.org/msg02348.htmlSigned-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
      Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1299021
      Link: http://lkml.kernel.org/r/1470214725-5023-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com
      [ Rename 'die' to 'cu_die' to avoid shadowing a die() definition on at least centos 5, Debian 7 and ubuntu:12.04.5]
      [ Use PRIx64 instead of lx to format a Dwarf_Addr, aka long long unsigned int, fixing the build on 32-bit systems ]
      [ dwarf_getsrclines() expects a size_t * argument ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e47392bf
    • R
      perf probe: Add helper function to check if probe with variable · b3f33f93
      Ravi Bangoria 提交于
      Introduce helper function instead of inline code and replace hardcoded
      strings "$vars" and "$params" with their corresponding macros.
      
      perf_probe_with_var() is not declared as static since it will be called
      from different file in subsequent patch.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1470214725-5023-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b3f33f93
    • A
      perf symbols: Fixup symbol sizes before picking best ones · 432746f8
      Arnaldo Carvalho de Melo 提交于
      When we call symbol__fixup_duplicate() we use algorithms to pick the
      "best" symbols for cases where there are various functions/aliases to an
      address, and those check zero size symbols, which, before calling
      symbol__fixup_end() are _all_ symbols in a just parsed kallsyms file.
      
      So first fixup the end, then fixup the duplicates.
      
      Found while trying to figure out why 'perf test vmlinux' failed, see the
      output of 'perf test -v vmlinux' to see cases where the symbols picked
      as best for vmlinux don't match the ones picked for kallsyms.
      
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 694bf407 ("perf symbols: Add some heuristics for choosing the best duplicate symbol")
      Link: http://lkml.kernel.org/n/tip-rxqvdgr0mqjdxee0kf8i2ufn@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      432746f8
    • A
      perf symbols: Check symbol_conf.allow_aliases for kallsyms loading too · c97b40e4
      Arnaldo Carvalho de Melo 提交于
      We can allow aliases to be kept, but we were checking this just when
      loading vmlinux files, be consistent, do it for any symbol table loading
      code that calls symbol__fixup_duplicate() by making this function check
      .allow_aliases instead.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 680d926a ("perf symbols: Allow symbol alias when loading map for symbol name")
      Link: http://lkml.kernel.org/n/tip-z0avp0s6cfjckc4xj3pdfjdz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c97b40e4
    • A
      perf test vmlinux: Tolerate symbol aliases · 7e1b6595
      Arnaldo Carvalho de Melo 提交于
      The algorithms used to prune aliases in symbols__fixup_duplicate() uses
      information available on ELF symtabs that are not present on
      /proc/kallsyms, so it picks different aliases as "best" for vmlinux and
      kallsyms.
      
      We could probably improve a bit this by having a list of aliases for the
      "best" symbols picked, instead of throwing this info, but that is left
      for when we find a real need.
      
      With this, 'perf test vmlinux' passes:
      
        # perf test -F 1
         1: vmlinux symtab matches kallsyms: Ok
        #
      
      When we ask for verbose mode, we can see those warning:
      
        # perf test -F -v 1
         1: vmlinux symtab matches kallsyms:
        --- start ---
        Looking at the vmlinux_path (8 entries long)
        Using /lib/modules/4.8.0-rc4+/build/vmlinux for symbols
        WARN: 0xffffffffb7001000: diff name v: xen_hypercall_set_trap_table k: hypercall_page
        WARN: 0xffffffffb7077970: diff end addr for aesni_gcm_dec v: 0xffffffffb707a2f2 k: 0xffffffffb7077a02
        WARN: 0xffffffffb707a300: diff end addr for aesni_gcm_enc v: 0xffffffffb707cc03 k: 0xffffffffb707a392
        WARN: 0xffffffffb707f950: diff end addr for aesni_gcm_enc_avx_gen2 v: 0xffffffffb7084ef6 k: 0xffffffffb707f9c3
        WARN: 0xffffffffb7084f00: diff end addr for aesni_gcm_dec_avx_gen2 v: 0xffffffffb708a691 k: 0xffffffffb7084f73
        WARN: 0xffffffffb708aa10: diff end addr for aesni_gcm_enc_avx_gen4 v: 0xffffffffb708f844 k: 0xffffffffb708aa83
        WARN: 0xffffffffb708f850: diff end addr for aesni_gcm_dec_avx_gen4 v: 0xffffffffb709486f k: 0xffffffffb708f8c3
        WARN: 0xffffffffb71a6e50: diff name v: perf_pmu_commit_txn.part.98 k: perf_pmu_cancel_txn.part.97
        WARN: 0xffffffffb752e480: diff name v: wakeup_expire_count_show.part.5 k: wakeup_active_count_show.part.7
        WARN: 0xffffffffb76e8d00: diff name v: phys_switch_id_show.part.11 k: phys_port_name_show.part.12
        WARN: Maps only in vmlinux:
         ffffffffb7d7d000-ffffffffb7eeaac8 117d000 [kernel].init.text
         ffffffffb7eeaac8-ffffffffc03ad000 12eaac8 [kernel].exit.text
        ---- end ----
        vmlinux symtab matches kallsyms: Ok
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-6v5w1k8rpx4ggczlkw730vt0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7e1b6595
    • A
      perf test vmlinux: Avoid printing headers for empty lists · 54da0769
      Arnaldo Carvalho de Melo 提交于
      Before:
      
        # perf test -F -v 1
         1: vmlinux symtab matches kallsyms:
        --- start ---
      <SNIP>
        WARN: Maps only in vmlinux:
         ffffffffb7d7d000-ffffffffb7eeaac8 117d000 [kernel].init.text
         ffffffffb7eeaac8-ffffffffc03ad000 12eaac8 [kernel].exit.text
        WARN: Maps in vmlinux with a different name in kallsyms:
        WARN: Maps only in kallsyms:
        ---- end ----
        vmlinux symtab matches kallsyms: Ok
        #
      
      The two last WARN lines are now suppressed, since there are no such
      cases detected.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-9ww8uvzl682ykaw8ht1tozlr@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      54da0769
    • A
      perf test vmlinux: Clarify which -v lines are errors or warning · e267769e
      Arnaldo Carvalho de Melo 提交于
      When the 'perf test -v vmlinux' test fails, it is not clear which of the
      lines are errors or warnings, clarify that adding ERR/WARN prefixes:
      
        # perf test -F -v 1
         1: vmlinux symtab matches kallsyms                          :
        --- start ---
        Looking at the vmlinux_path (8 entries long)
        Using /lib/modules/4.8.0-rc4+/build/vmlinux for symbols
        ERR : 0xffffffffb7001000: diff name v: xen_hypercall_set_trap_table k: hypercall_page
        WARN: 0xffffffffb7077970: diff end addr for aesni_gcm_dec v: 0xffffffffb707a2f2 k: 0xffffffffb7077a02
        WARN: 0xffffffffb707a300: diff end addr for aesni_gcm_enc v: 0xffffffffb707cc03 k: 0xffffffffb707a392
        WARN: 0xffffffffb707f950: diff end addr for aesni_gcm_enc_avx_gen2 v: 0xffffffffb7084ef6 k: 0xffffffffb707f9c3
        WARN: 0xffffffffb7084f00: diff end addr for aesni_gcm_dec_avx_gen2 v: 0xffffffffb708a691 k: 0xffffffffb7084f73
        WARN: 0xffffffffb708aa10: diff end addr for aesni_gcm_enc_avx_gen4 v: 0xffffffffb708f844 k: 0xffffffffb708aa83
        WARN: 0xffffffffb708f850: diff end addr for aesni_gcm_dec_avx_gen4 v: 0xffffffffb709486f k: 0xffffffffb708f8c3
        ERR : 0xffffffffb71a6e50: diff name v: perf_pmu_commit_txn.part.98 k: perf_pmu_cancel_txn.part.97
        ERR : 0xffffffffb752e480: diff name v: wakeup_expire_count_show.part.5 k: wakeup_active_count_show.part.7
        ERR : 0xffffffffb76e8d00: diff name v: phys_switch_id_show.part.11 k: phys_port_name_show.part.12
        WARN: Maps only in vmlinux:
         ffffffffb7d7d000-ffffffffb7eeaac8 117d000 [kernel].init.text
         ffffffffb7eeaac8-ffffffffc03ad000 12eaac8 [kernel].exit.text
        WARN: Maps in vmlinux with a different name in kallsyms:
        WARN: Maps only in kallsyms:
        ---- end ----
        vmlinux symtab matches kallsyms: FAILED!
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-n5ml8m7y9x8kzvxt09ipku88@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e267769e
    • M
      perf probe: Ignore vmlinux Build-id when offline vmlinux given · e50243bb
      Masami Hiramatsu 提交于
      Ignore vmlinux build-id when user gives offline vmlinux if the command
      does not affect running kernel.
      
      perf-probe has several actions some of them does not change the running
      kernel, like --lines, --vars, and --funcs.
      
      e.g.
        -----
        $ ./perf probe -k ./vmlinux-arm -V do_sys_open:14
        Available variables at do_sys_open:14
                @<do_sys_open+202>
                        char*   filename
                        int     dfd
                        int     fd
                        int     flags
                        struct filename*        tmp
                        struct open_flags       op
                        umode_t mode
        -----
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/147222347320.5088.2582658035296667520.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e50243bb
    • M
      perf probe: Support probing on offline cross-arch binary · 293d5b43
      Masami Hiramatsu 提交于
      Support probing on offline cross-architecture binary by adding getting
      the target machine arch from ELF and choose correct register string for
      the machine.
      
      Here is an example:
        -----
        $ perf probe --vmlinux=./vmlinux-arm --definition 'do_sys_open $params'
        p:probe/do_sys_open do_sys_open+0 dfd=%r5:s32 filename=%r1:u32 flags=%r6:s32 mode=%r3:u16
        -----
      
      Here, we can get probe/do_sys_open from above and append it to to the target
      machine's tracing/kprobe_events file in the tracefs mountput, usually
      /sys/kernel/debug/tracing/kprobe_events (or /sys/kernel/tracing/kprobe_events).
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/147214229717.23638.6440579792548044658.stgit@devbox
      [ Add definition for EM_AARCH64 to fix the build on at least centos 6, debian 7 & ubuntu 12.04.5 ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      293d5b43
    • M
      perf probe: Ignore vmlinux buildid if offline kernel is given · 428aff82
      Masami Hiramatsu 提交于
      Ignore the buildid of running kernel when both of --definition and
      --vmlinux is given because that kernel should be off-line.
      
      This also skips post-processing of kprobe event for relocating symbol
      and checking blacklist, because it can not be done on off-line kernel.
      
      E.g. without this fix perf shows an error as below
        ----
        $ perf probe --vmlinux=./vmlinux-arm --definition do_sys_open
        ./vmlinux-arm with build id 7a1f76dd56e9c4da707cd3d6333f50748141434b not found, continuing without symbols
        Failed to find symbol do_sys_open in kernel
          Error: Failed to add events.
        ----
      with this fix, we can get the definition
        ----
        $ perf probe --vmlinux=./vmlinux-arm --definition do_sys_open
        p:probe/do_sys_open do_sys_open+0
        ----
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/147214228193.23638.12581984840822162131.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      428aff82
    • M
      perf probe: Show trace event definition · 1c20b1d1
      Masami Hiramatsu 提交于
      Add --definition/-D option for showing the trace-event definition in
      stdout. This can be useful in debugging or combined with a shell script.
      
      e.g.
        ----
        # perf probe --definition 'do_sys_open $params'
        p:probe/do_sys_open _text+2261728 dfd=%di:s32 filename=%si:u64 flags=%dx:s32 mode=%cx:u16
        ----
      Suggested-and-Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/147214226712.23638.2240534040014013658.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1c20b1d1
    • M
      perf config: Show default report configuration in example and docs · 893c5c79
      Milian Wolff 提交于
      Signed-off-by: NMilian Wolff <milian.wolff@kdab.com>
      LPU-Reference: 20160830134106.21240-2-milian.wolff@kdab.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      893c5c79
    • M
      perf symbols: Demangle symbols for synthesized @plt entries. · 2a8d41b4
      Milian Wolff 提交于
      The symbols in the synthesized @plt entries where not demangled before,
      i.e. we could end up with entries such as:
      
          $ perf report
          Samples: 7K of event 'cycles:ppp', Event count (approx.): 6223833141
          Children      Self  Command          Shared Object           Symbol
          -   93.63%    28.89%  lab_mandelbrot   lab_mandelbrot        [.] main
              - 73.81% main
                  - 33.57% hypot
                    27.76% __hypot_finite
                    15.97% __muldc3
                     2.90% __muldc3@plt
                     2.40% _ZNK6QImage6heightEv@plt
                   + 2.14% QColor::rgb
                     1.94% _ZNK6QImage5widthEv@plt
                     1.92% cabs@plt
      
      This patch remedies this issue by also applying demangling to the
      synthesized symbols. The output for the above is now:
      
          $ perf report
          Samples: 7K of event 'cycles:ppp', Event count (approx.): 6223833141
          Children      Self  Command          Shared Object           Symbol
          -   93.63%    28.89%  lab_mandelbrot   lab_mandelbrot        [.] main
              - 73.81% main
                  - 33.57% hypot
                    27.76% __hypot_finite
                    15.97% __muldc3
                     2.90% __muldc3@plt
                     2.40% QImage::height() const@plt
                   + 2.14% QColor::rgb
                     1.94% QImage::width() const@plt
                     1.92% cabs@plt
      Signed-off-by: NMilian Wolff <milian.wolff@kdab.com>
      LPU-Reference: 20160830114102.30863-1-milian.wolff@kdab.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2a8d41b4
    • A
      perf probe: Do not use map_load filters for function · fd227598
      Arnaldo Carvalho de Melo 提交于
      It is simpler to just do the loop, no need for globals and the last user
      of such facility disappears.
      
      Testing:
      
        # perf probe -F [a-z]*recvmsg
        aead_recvmsg
        compat_SyS_recvmsg
        compat_sys_recvmsg
        hash_recvmsg
        inet_recvmsg
        kernel_recvmsg
        netlink_recvmsg
        packet_recvmsg
        ping_recvmsg
        raw_recvmsg
        rawv6_recvmsg
        rng_recvmsg
        security_socket_recvmsg
        selinux_socket_recvmsg
        skcipher_recvmsg
        sock_common_recvmsg
        sock_no_recvmsg
        sock_recvmsg
        sys_recvmsg
        tcp_recvmsg
        udp_recvmsg
        udpv6_recvmsg
        unix_dgram_recvmsg
        unix_seqpacket_recvmsg
        unix_stream_recvmsg
        #
      
      Without filters:
      
        # perf probe -F | tail -5
        zswap_pool_create
        zswap_pool_current
        zswap_update_total_size
        zswap_writeback_entry
        zswap_zpool_param_set
        #
        # perf probe -F | wc -l
        33311
        #
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20160831130427.GA13095@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fd227598