1. 24 8月, 2016 21 次提交
  2. 19 8月, 2016 2 次提交
    • A
      perf evsel: Do not access outside hw cache name arrays · c53412ee
      Arnaldo Carvalho de Melo 提交于
      We have to check if the values are >= *_MAX, not just >, fix it.
      
      From the bugzilla report:
      
      ''In file /tools/perf/util/evsel.c  function __perf_evsel__hw_cache_name
      it appears that there is a bug that reads beyond the end of the buffer.
      The statement "if (type > PERF_COUNT_HW_CACHE_MAX)" allows type to be
      equal to the maximum value. Later, when statement "if
      (!perf_evsel__is_cache_op_valid(type, op))" is executed, the function
      can access array perf_evsel__hw_cache_stat[type] beyond the end of the
      buffer.
      
      It appears to me that the statement "if (type > PERF_COUNT_HW_CACHE_MAX)"
      should be "if (type >= PERF_COUNT_HW_CACHE_MAX)"
      
      Bug found with Coverity and manual code review. No attempts were made to
      execute the code with a maximum type value.''
      
      Committer note:
      
      Testing it:
      
        $ perf record -e $(echo $(perf list cache | cut -d \[ -f1) | sed 's/ /,/g') usleep 1
        [ perf record: Woken up 16 times to write data ]
        [ perf record: Captured and wrote 0.023 MB perf.data (34 samples) ]
        $ perf evlist
        L1-dcache-load-misses
        L1-dcache-loads
        L1-dcache-stores
        L1-icache-load-misses
        LLC-load-misses
        LLC-loads
        LLC-store-misses
        LLC-stores
        branch-load-misses
        branch-loads
        dTLB-load-misses
        dTLB-loads
        dTLB-store-misses
        dTLB-stores
        iTLB-load-misses
        iTLB-loads
        node-load-misses
        node-loads
        node-store-misses
        node-stores
        $ perf list cache
      
        List of pre-defined events (to be used in -e):
      
          L1-dcache-load-misses        [Hardware cache event]
          L1-dcache-loads              [Hardware cache event]
          L1-dcache-stores             [Hardware cache event]
          L1-icache-load-misses        [Hardware cache event]
          LLC-load-misses              [Hardware cache event]
          LLC-loads                    [Hardware cache event]
          LLC-store-misses             [Hardware cache event]
          LLC-stores                   [Hardware cache event]
          branch-load-misses           [Hardware cache event]
          branch-loads                 [Hardware cache event]
          dTLB-load-misses             [Hardware cache event]
          dTLB-loads                   [Hardware cache event]
          dTLB-store-misses            [Hardware cache event]
          dTLB-stores                  [Hardware cache event]
          iTLB-load-misses             [Hardware cache event]
          iTLB-loads                   [Hardware cache event]
          node-load-misses             [Hardware cache event]
          node-loads                   [Hardware cache event]
          node-store-misses            [Hardware cache event]
          node-stores                  [Hardware cache event]
        $
      Reported-by: NBrian Sweeney <bsweeney@lgsinnovations.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=153351Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c53412ee
    • V
      tools lib: Reinstate strlcpy() header guard with __UCLIBC__ · 0215d59b
      Vineet Gupta 提交于
      perf tools build in recent kernels spews splat when cross compiling with uClibc:
      
      |   CC       util/alias.o
      | In file included from tools/perf/util/../ui/../util/cache.h:8:0,
      |                 from tools/perf/util/../ui/helpline.h:7,
      |                 from tools/perf/util/debug.h:8,
      |                 from arch/../util/cpumap.h:9,
      |                 from arch/../util/env.h:5,
      |                 from arch/common.h:4,
      |                 from arch/common.c:3:
      | tools/include/linux/string.h:12:15: warning: redundant redeclaration of ‘strlcpy’ [-Wredundant-decls]
      |  extern size_t strlcpy(char *dest, const char *src, size_t size);
                     ^
      This is after commit 61a6445e ("tools lib: Guard the strlcpy() header with
      __GLIBC__").
      
      The problem is uClibc also defines __GLIBC__ for exported headers for
      applications. So add that specific check to not trip for uClibc.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petri Gynther <pgynther@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: linux-snps-arc@lists.infradead.org
      Link: http://lkml.kernel.org/r/1471537703-16439-1-git-send-email-vgupta@synopsys.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0215d59b
  3. 17 8月, 2016 1 次提交
    • M
      perf unwind: Use addr_location::addr instead of ip for entries · 67540759
      Milian Wolff 提交于
      This fixes the srcline translation for call chains of user space
      applications.
      
      Before we got:
      
          perf report --stdio --no-children -s sym,srcline -g address
           8.92%  [.] main                                 mandelbrot.h:41
                  |
                  |--3.70%--main +8390240
                  |          __libc_start_main +139950056726769
                  |          _start +8388650
                  |
                  |--2.74%--main +8390189
                  |
                   --2.08%--main +8390296
                             __libc_start_main +139950056726769
                             _start +8388650
      
           7.59%  [.] main                                 complex:1326
                  |
                  |--4.79%--main +8390203
                  |          __libc_start_main +139950056726769
                  |          _start +8388650
                  |
                   --2.80%--main +8390219
      
           7.12%  [.] __muldc3                             libgcc2.c:1945
                  |
                  |--3.76%--__muldc3 +139950060519490
                  |          main +8390224
                  |          __libc_start_main +139950056726769
                  |          _start +8388650
                  |
                   --3.32%--__muldc3 +139950060519512
                             main +8390224
      
      With this patch applied, we instead get:
      
          perf report --stdio --no-children -s sym,srcline -g address
           8.92%  [.] main                                 mandelbrot.h:41
                  |
                  |--3.70%--main mandelbrot.h:41
                  |          __libc_start_main +241
                  |          _start +4194346
                  |
                  |--2.74%--main mandelbrot.h:41
                  |
                   --2.08%--main mandelbrot.h:41
                             __libc_start_main +241
                             _start +4194346
      
           7.59%  [.] main                                 complex:1326
                  |
                  |--4.79%--main complex:1326
                  |          __libc_start_main +241
                  |          _start +4194346
                  |
                   --2.80%--main complex:1326
      
           7.12%  [.] __muldc3                             libgcc2.c:1945
                  |
                  |--3.76%--__muldc3 libgcc2.c:1945
                  |          main mandelbrot.h:39
                  |          __libc_start_main +241
                  |          _start +4194346
                  |
                   --3.32%--__muldc3 libgcc2.c:1945
                             main mandelbrot.h:39
      Suggested-and-Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NMilian Wolff <milian.wolff@kdab.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      LPU-Reference: 20160816153926.11288-1-milian.wolff@kdab.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      67540759
  4. 16 8月, 2016 8 次提交
  5. 13 8月, 2016 3 次提交
  6. 11 8月, 2016 1 次提交
    • D
      tools/testing/nvdimm: fix SIGTERM vs hotplug crash · d8d378fa
      Dan Williams 提交于
      The unit tests crash when hotplug races the previous probe. This race
      requires that the loading of the nfit_test module be terminated with
      SIGTERM, and the module to be unloaded while the ars scan is still
      running.
      
      In contrast to the normal nfit driver, the unit test calls
      acpi_nfit_init() twice to simulate hotplug, whereas the nominal case
      goes through the acpi_nfit_notify() event handler.  The
      acpi_nfit_notify() path is careful to flush the previous region
      registration before servicing the hotplug event. The unit test was
      missing this guarantee.
      
       BUG: unable to handle kernel NULL pointer dereference at           (null)
       IP: [<ffffffff810cdce7>] pwq_activate_delayed_work+0x47/0x170
       [..]
       Call Trace:
        [<ffffffff810ce186>] pwq_dec_nr_in_flight+0x66/0xa0
        [<ffffffff810ce490>] process_one_work+0x2d0/0x680
        [<ffffffff810ce331>] ? process_one_work+0x171/0x680
        [<ffffffff810ce88e>] worker_thread+0x4e/0x480
        [<ffffffff810ce840>] ? process_one_work+0x680/0x680
        [<ffffffff810ce840>] ? process_one_work+0x680/0x680
        [<ffffffff810d5343>] kthread+0xf3/0x110
        [<ffffffff8199846f>] ret_from_fork+0x1f/0x40
        [<ffffffff810d5250>] ? kthread_create_on_node+0x230/0x230
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      d8d378fa
  7. 10 8月, 2016 1 次提交
  8. 09 8月, 2016 3 次提交
    • R
      perf probe ppc64le: Fix probe location when using DWARF · 99e608b5
      Ravi Bangoria 提交于
      Powerpc has Global Entry Point and Local Entry Point for functions.  LEP
      catches call from both the GEP and the LEP. Symbol table of ELF contains
      GEP and Offset from which we can calculate LEP, but debuginfo does not
      have LEP info.
      
      Currently, perf prioritize symbol table over dwarf to probe on LEP for
      ppc64le. But when user tries to probe with function parameter, we fall
      back to using dwarf(i.e. GEP) and when function called via LEP, probe
      will never hit.
      
      For example:
      
        $ objdump -d vmlinux
          ...
          do_sys_open():
          c0000000002eb4a0:       e8 00 4c 3c     addis   r2,r12,232
          c0000000002eb4a4:       60 00 42 38     addi    r2,r2,96
          c0000000002eb4a8:       a6 02 08 7c     mflr    r0
          c0000000002eb4ac:       d0 ff 41 fb     std     r26,-48(r1)
      
        $ sudo ./perf probe do_sys_open
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
          p:probe/do_sys_open _text+3060904
      
        $ sudo ./perf probe 'do_sys_open filename:string'
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
          p:probe/do_sys_open _text+3060896 filename_string=+0(%gpr4):string
      
      For second case, perf probed on GEP. So when function will be called via
      LEP, probe won't hit.
      
        $ sudo ./perf record -a -e probe:do_sys_open ls
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.195 MB perf.data ]
      
      To resolve this issue, let's not prioritize symbol table, let perf
      decide what it wants to use. Perf is already converting GEP to LEP when
      it uses symbol table. When perf uses debuginfo, let it find LEP offset
      form symbol table. This way we fall back to probe on LEP for all cases.
      
      After patch:
      
        $ sudo ./perf probe 'do_sys_open filename:string'
        $ sudo cat /sys/kernel/debug/tracing/kprobe_events
          p:probe/do_sys_open _text+3060904 filename_string=+0(%gpr4):string
      
        $ sudo ./perf record -a -e probe:do_sys_open ls
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.197 MB perf.data (11 samples) ]
      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: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Balbir Singh <bsingharora@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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/1470723805-5081-2-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      99e608b5
    • R
      perf probe: Add function to post process kernel trace events · d820456d
      Ravi Bangoria 提交于
      Instead of inline code, introduce function to post process kernel
      probe trace events.
      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: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Balbir Singh <bsingharora@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      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/1470723805-5081-1-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d820456d
    • A
      tools: Sync cpufeatures headers with the kernel · 840b49ba
      Arnaldo Carvalho de Melo 提交于
      Due to:
      
        1e61f78b ("x86/cpufeature: Make sure DISABLED/REQUIRED macros are updated")
      
      No changes to tools using those headers (tools/arch/x86/lib/mem{set,cpu}_64.S)
      seems necessary.
      
      Detected by the tools build header drift checker:
      
        $ make -C tools/perf O=/tmp/build/perf
        make: Entering directory '/home/acme/git/linux/tools/perf'
          BUILD:   Doing 'make -j4' parallel build
          GEN      /tmp/build/perf/common-cmds.h
        Warning: tools/arch/x86/include/asm/disabled-features.h differs from kernel
        Warning: tools/arch/x86/include/asm/required-features.h differs from kernel
        Warning: tools/arch/x86/include/asm/cpufeatures.h differs from kernel
          CC       /tmp/build/perf/util/probe-finder.o
          CC       /tmp/build/perf/builtin-help.o
        <SNIP>
        ^C$
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.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/n/tip-ja75m7zk8j0jkzmrv16i5ehw@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      840b49ba