1. 23 5月, 2018 7 次提交
  2. 22 5月, 2018 7 次提交
  3. 19 5月, 2018 7 次提交
    • I
      Merge tag 'perf-core-for-mingo-4.18-20180519' of... · 2996123e
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-4.18-20180519' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      - Record min/max LBR cycles (>= Skylake) and add 'perf annotate' TUI
        hotkey to show it (c) (Jin Yao)
      
      - Fix machine->kernel_start for PTI on x86 (Adrian Hunter)
      
      - Make machine->env->arch always available, e.g. in 'perf top', not
        just when reading that info from perf.data files (Adrian Hunter)
      
      - Reduce the number of files read at 'perf' start, leaving information such as
        cacheline size, tracefs mount point determination, max_stack, etc, to be
        lazily read as tools needs then (Arnaldo Carvalho de Melo)
      
      - Fix up BPF include and examples install messages (Arnaldo Carvalho de Melo)
      
      - Fix up callchain addresses and symbol offsets in 'perf script', to help
        correlating with objdump output (Sandipan Das)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2996123e
    • A
      perf tools: Fix kernel_start for PTI on x86 · 19422a9f
      Adrian Hunter 提交于
      Opickn x86_64, PTI entry trampolines are less than the start of kernel text,
      but still above 2^63. So leave kernel_start = 1ULL << 63 for x86_64.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86@kernel.org
      Link: http://lkml.kernel.org/r/1526548928-20790-7-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      19422a9f
    • A
      perf machine: Add machine__is() to identify machine arch · dbbd34a6
      Adrian Hunter 提交于
      Add a function to identify the machine architecture.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86@kernel.org
      Link: http://lkml.kernel.org/r/1526548928-20790-6-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dbbd34a6
    • A
      perf bpf: Fixup include and examples install messages · cfc4033b
      Arnaldo Carvalho de Melo 提交于
      Before:
      
        INSTALL  lib
      install include/bpf/*.h '/home/acme/lib/include/perf/bpf'
        INSTALL  lib
      install examples/bpf/*.c '/home/acme/lib/examples/perf/bpf'
      
      After:
      
        INSTALL  lib
        INSTALL  include/bpf
        INSTALL  lib
        INSTALL  examples/bpf
      Reported-by: NIngo Molnar <mingo@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>
      Fixes: dd8e4ead ("perf bpf: Add bpf.h to be used in eBPF proggies")
      Fixes: 8f12a2ff ("perf bpf: Add 'examples' directories")
      Link: https://lkml.kernel.org/n/tip-icljqe87e8pak8mu6mkki9d4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cfc4033b
    • J
      perf annotate: Create hotkey 'c' to show min/max cycles · 3e71fc03
      Jin Yao 提交于
      In the 'perf annotate' view, a new hotkey 'c' is created for showing the
      min/max cycles.
      
      For example, when press 'c', the annotate view is:
      
        Percent│ IPC     Cycle(min/max)
               │
               │
               │                             Disassembly of section .text:
               │
               │                             000000000003aab0 <random@@GLIBC_2.2.5>:
          8.22 │3.92                           sub    $0x18,%rsp
               │3.92                           mov    $0x1,%esi
               │3.92                           xor    %eax,%eax
               │3.92                           cmpl   $0x0,argp_program_version_hook@@G
               │3.92             1(2/1)      ↓ je     20
               │                               lock   cmpxchg %esi,__abort_msg@@GLIBC_P
               │                             ↓ jne    29
               │                             ↓ jmp    43
               │1.10                     20:   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+
          8.93 │1.10             1(5/1)      ↓ je     43
      
      When press 'c' again, the annotate view is switched back:
      
        Percent│ IPC Cycle
               │
               │
               │                Disassembly of section .text:
               │
               │                000000000003aab0 <random@@GLIBC_2.2.5>:
          8.22 │3.92              sub    $0x18,%rsp
               │3.92              mov    $0x1,%esi
               │3.92              xor    %eax,%eax
               │3.92              cmpl   $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x
               │3.92     1      ↓ je     20
               │                  lock   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
               │                ↓ jne    29
               │                ↓ jmp    43
               │1.10        20:   cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0
          8.93 │1.10     1      ↓ je     43
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1526569118-14217-3-git-send-email-yao.jin@linux.intel.com
      [ Rename all maxmin to minmax ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e71fc03
    • J
      perf annotate: Record the min/max cycles · 48659ebf
      Jin Yao 提交于
      Currently perf has a feature to account cycles for LBRs
      
      For example, on skylake:
      
        perf record -b ...
        perf report or perf annotate
      
      And then browsing the annotate browser gives average cycle counts for
      program blocks.
      
      For some analysis it would be useful if we could know not only the
      average cycles but also the min and max cycles.
      
      This patch records the min and max cycles.
      Signed-off-by: NJin Yao <yao.jin@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: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1526569118-14217-2-git-send-email-yao.jin@linux.intel.com
      [ Switch from max/min to min/max ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      48659ebf
    • S
      perf script: Show symbol offsets by default · 7903a708
      Sandipan Das 提交于
      Since the ip shown for a symbol is now always a virtual address, it
      becomes difficult to correlate this with objdump output and determine
      the exact instruction address. So, we always show the offset from the
      start of the symbol.
      
      This can be verified on a powerpc64le system running Fedora 27 as
      follows:
      
        # perf probe -a sys_write
        # perf record -e probe:sys_write -g ~/test
      
      Before applying this patch:
      
        # perf script
      
        test  9710 [013] 95614.332431: probe:sys_write: (c0000000004025b0)
                c0000000004025b0 sys_write (/lib/modules/4.17.0-rc4+/build/vmlinux)
                c00000000000b9e0 system_call (/lib/modules/4.17.0-rc4+/build/vmlinux)
                    7fffb70d8234 __GI___libc_write (/usr/lib64/libc-2.26.so)
                    7fffb7052c74 _IO_file_write@@GLIBC_2.17 (/usr/lib64/libc-2.26.so)
                        5afc1818 [unknown] ([unknown])
                    7fffb7051a60 new_do_write (/usr/lib64/libc-2.26.so)
                    7fffb7054638 _IO_do_write@@GLIBC_2.17 (/usr/lib64/libc-2.26.so)
                    7fffb7054bbc _IO_file_overflow@@GLIBC_2.17 (/usr/lib64/libc-2.26.so)
                    7fffb7055a24 __overflow (/usr/lib64/libc-2.26.so)
                    7fffb7044548 _IO_puts (/usr/lib64/libc-2.26.so)
                        10000440 main (/home/sandipan/test)
                    7fffb6fe36a0 generic_start_main.isra.0 (/usr/lib64/libc-2.26.so)
                    7fffb6fe3898 __libc_start_main (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
        ...
      
      After applying this patch:
      
        # perf script
      
        test  9710 [013] 95614.332431: probe:sys_write: (c0000000004025b0)
                c0000000004025b0 sys_write+0x10 (/lib/modules/4.17.0-rc4+/build/vmlinux)
                c00000000000b9e0 system_call+0x58 (/lib/modules/4.17.0-rc4+/build/vmlinux)
                    7fffb70d8234 __GI___libc_write+0x24 (/usr/lib64/libc-2.26.so)
                    7fffb7052c74 _IO_file_write@@GLIBC_2.17+0x44 (/usr/lib64/libc-2.26.so)
                        5afc1818 [unknown] ([unknown])
                    7fffb7051a60 new_do_write+0x90 (/usr/lib64/libc-2.26.so)
                    7fffb7054638 _IO_do_write@@GLIBC_2.17+0x38 (/usr/lib64/libc-2.26.so)
                    7fffb7054bbc _IO_file_overflow@@GLIBC_2.17+0x14c (/usr/lib64/libc-2.26.so)
                    7fffb7055a24 __overflow+0x64 (/usr/lib64/libc-2.26.so)
                    7fffb7044548 _IO_puts+0x218 (/usr/lib64/libc-2.26.so)
                        10000440 main+0x20 (/home/sandipan/test)
                    7fffb6fe36a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fffb6fe3898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
        ...
      Signed-off-by: NSandipan Das <sandipan@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20180517063326.6319-2-sandipan@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7903a708
  4. 18 5月, 2018 8 次提交
  5. 17 5月, 2018 4 次提交
  6. 16 5月, 2018 7 次提交
    • I
      Merge tag 'perf-core-for-mingo-4.18-20180516' of... · 5aafae8d
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-4.18-20180516' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      - Add '-e intel_pt//u' test to the 'parse-events' 'perf test' entry,
        to help avoiding regressions in the events parser such as one
        that caused a revert in v4.17-rc (Arnaldo Carvalho de Melo)
      
      - Fix NULL return handling in bpf__prepare_load() (YueHaibing)
      
      - Warn about 'perf buildid-cache --purge-all' failures (Ravi Bangoria)
      
      - Add infrastructure to help in writing eBPF C programs to be used
        with '-e name.c' type events in tools such as 'record' and 'trace',
        with headers for common constructs and an examples directory that
        will get populated as we add more such helpers and the 'perf bpf'
        branch that Jiri Olsa has been working on (Arnaldo Carvalho de Melo)
      
      - Handle uncore event aliases in small groups properly (Kan Liang)
      
      - Use the "_stest" symbol to identify the kernel map when loading kcore (Adrian Hunter)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5aafae8d
    • Y
      perf bpf: Fix NULL return handling in bpf__prepare_load() · 7a36a287
      YueHaibing 提交于
      bpf_object__open()/bpf_object__open_buffer can return error pointer or
      NULL, check the return values with IS_ERR_OR_NULL() in bpf__prepare_load
      and bpf__prepare_load_buffer
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: netdev@vger.kernel.org
      Link: https://lkml.kernel.org/n/tip-psf4xwc09n62al2cb9s33v9h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a36a287
    • K
      perf parse-events: Handle uncore event aliases in small groups properly · 3cdc5c2c
      Kan Liang 提交于
      Perf stat doesn't count the uncore event aliases from the same uncore
      block in a group, for example:
      
        perf stat -e '{unc_m_cas_count.all,unc_m_clockticks}' -a -I 1000
        #           time             counts unit events
             1.000447342      <not counted>      unc_m_cas_count.all
             1.000447342      <not counted>      unc_m_clockticks
             2.000740654      <not counted>      unc_m_cas_count.all
             2.000740654      <not counted>      unc_m_clockticks
      
      The output is very misleading. It gives a wrong impression that the
      uncore event doesn't work.
      
      An uncore block could be composed by several PMUs. An uncore event alias
      is a joint name which means the same event runs on all PMUs of a block.
      Perf doesn't support mixed events from different PMUs in the same group.
      It is wrong to put uncore event aliases in a big group.
      
      The right way is to split the big group into multiple small groups which
      only include the events from the same PMU.
      
      Only uncore event aliases from the same uncore block should be specially
      handled here. It doesn't make sense to mix the uncore events with other
      uncore events from different blocks or even core events in a group.
      
      With the patch:
        #           time             counts unit events
           1.001557653            140,833      unc_m_cas_count.all
           1.001557653      1,330,231,332      unc_m_clockticks
           2.002709483             85,007      unc_m_cas_count.all
           2.002709483      1,429,494,563      unc_m_clockticks
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: http://lkml.kernel.org/r/1525727623-19768-1-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3cdc5c2c
    • A
      perf tools: Use the "_stest" symbol to identify the kernel map when loading kcore · 56549978
      Adrian Hunter 提交于
      The first symbol is not necessarily in the kernel text.  Instead of
      using the first symbol, use the _stest symbol to identify the kernel map
      when loading kcore.
      
      This allows for the introduction of symbols to identify the x86_64 PTI
      entry trampolines.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86@kernel.org
      Link: http://lkml.kernel.org/r/1525866228-30321-6-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      56549978
    • A
      perf bpf: Add probe() helper to reduce kprobes boilerplate · d8fc764d
      Arnaldo Carvalho de Melo 提交于
      So that kprobe definitions become:
      
        int probe(function, variables)(void *ctx, int err, var1, var2, ...)
      
      The existing 5sec.c, got converted and goes from:
      
        SEC("func=hrtimer_nanosleep rqtp->tv_sec")
        int func(void *ctx, int err, long sec)
        {
        }
      
      To:
      
        int probe(hrtimer_nanosleep, rqtp->tv_sec)(void *ctx, int err, long sec)
        {
        }
      
      If we decide to add tv_nsec as well, then it becomes:
      
        $ cat tools/perf/examples/bpf/5sec.c
        #include <bpf.h>
      
        int probe(hrtimer_nanosleep, rqtp->tv_sec rqtp->tv_nsec)(void *ctx, int err, long sec, long nsec)
        {
      	  return sec == 5;
        }
      
        license(GPL);
        $
      
      And if we run it, system wide as before and run some 'sleep' with values
      for the tv_nsec field, we get:
      
        # perf trace --no-syscalls -e tools/perf/examples/bpf/5sec.c
           0.000 perf_bpf_probe:hrtimer_nanosleep:(ffffffff9811b5f0) tv_sec=5 tv_nsec=100000000
        9641.650 perf_bpf_probe:hrtimer_nanosleep:(ffffffff9811b5f0) tv_sec=5 tv_nsec=123450001
        ^C#
      
      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: https://lkml.kernel.org/n/tip-1v9r8f6ds5av0w9pcwpeknyl@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d8fc764d
    • A
      perf bpf: Add license(NAME) helper · 1f477305
      Arnaldo Carvalho de Melo 提交于
      To further reduce boilerplate.
      
      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: https://lkml.kernel.org/n/tip-vst6hj335s0ebxzqltes3nsc@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f477305
    • A
      perf bpf: Add kprobe example to catch 5s naps · 7542b767
      Arnaldo Carvalho de Melo 提交于
      Description:
      
      . Disable strace like syscall tracing (--no-syscalls), or try tracing
        just some (-e *sleep).
      
      . Attach a filter function to a kernel function, returning when it should
        be considered, i.e. appear on the output:
      
        $ cat tools/perf/examples/bpf/5sec.c
        #include <bpf.h>
      
        SEC("func=hrtimer_nanosleep rqtp->tv_sec")
        int func(void *ctx, int err, long sec)
        {
      	  return sec == 5;
        }
      
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        $
      
      . Run it system wide, so that any sleep of >= 5 seconds and < than 6
        seconds gets caught.
      
      . Ask for callgraphs using DWARF info, so that userspace can be unwound
      
      . While this is running, run something like "sleep 5s".
      
        # perf trace --no-syscalls -e tools/perf/examples/bpf/5sec.c/call-graph=dwarf/
           0.000 perf_bpf_probe:func:(ffffffff9811b5f0) tv_sec=5
                                             hrtimer_nanosleep ([kernel.kallsyms])
                                             __x64_sys_nanosleep ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64 ([kernel.kallsyms])
                                             __GI___nanosleep (/usr/lib64/libc-2.26.so)
                                             rpl_nanosleep (/usr/bin/sleep)
                                             xnanosleep (/usr/bin/sleep)
                                             main (/usr/bin/sleep)
                                             __libc_start_main (/usr/lib64/libc-2.26.so)
                                             _start (/usr/bin/sleep)
        ^C#
      
      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: https://lkml.kernel.org/n/tip-2nmxth2l2h09f9gy85lyexcq@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7542b767