1. 23 Aug, 2016 32 commits
  2. 18 Aug, 2016 8 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo-20160818' of... · de737f33
      Ingo Molnar authored
      Merge tag 'perf-urgent-for-mingo-20160818' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
      - Do not access outside hw cache name arrays (Arnaldo Carvalho de Melo)
      
      - Use addr_location::addr instead of ip for entries when unwinding using
        DWARF CFI, fixing the "srcline" information for userspace application
        callchains (Milian Wolff)
      
      - Reinstate strlcpy() header guard with __UCLIBC__, fixing the build
        with uclibc, detected when building for the ARC architecture (Vineet Gupta)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      de737f33
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Do not access outside hw cache name arrays · c53412ee
      Arnaldo Carvalho de Melo authored
      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: default avatarBrian Sweeney <bsweeney@lgsinnovations.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=153351Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c53412ee
    • Vineet Gupta's avatar
      tools lib: Reinstate strlcpy() header guard with __UCLIBC__ · 0215d59b
      Vineet Gupta authored
      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: default avatarVineet 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0215d59b
    • Jiri Olsa's avatar
      perf/x86: Fix PEBS threshold initialization · b6a32f02
      Jiri Olsa authored
      Latest PEBS rework change could skip initialization
      of the ds->pebs_interrupt_threshold for single event
      PEBS threshold events.
      
      Make sure the PEBS threshold gets always initialized.
      Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 09e61b4f ("perf/x86/intel: Rework the large PEBS setup code")
      Link: http://lkml.kernel.org/r/1471511392-29875-1-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b6a32f02
    • David Carrillo-Cisneros's avatar
      perf/x86: Use PMUEF_READ_CPU_PKG in uncore events · e64cd6f7
      David Carrillo-Cisneros authored
      Add flag to Intel's uncore and RAPL.
      Signed-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1471467307-61171-5-git-send-email-davidcc@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e64cd6f7
    • David Carrillo-Cisneros's avatar
      perf/core: Introduce PMU_EV_CAP_READ_ACTIVE_PKG · d6a2f903
      David Carrillo-Cisneros authored
      Introduce the flag PMU_EV_CAP_READ_ACTIVE_PKG, useful for uncore events,
      that allows a PMU to signal the generic perf code that an event is readable
      in the current CPU if the event is active in a CPU in the same package as
      the current CPU.
      
      This is an optimization that avoids a unnecessary IPI for the common case
      where uncore events are run and read in the same package but in
      different CPUs.
      
      As an example, the IPI removal speeds up perf_read() in my Haswell system
      as follows:
      
        - For event UNC_C_LLC_LOOKUP: From 260 us to 31 us.
        - For event RAPL's power/energy-cores/: From to 255 us to 27 us.
      
      For the optimization to work, all events in the group must have it
      (similarly to PERF_EV_CAP_SOFTWARE).
      Signed-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1471467307-61171-4-git-send-email-davidcc@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d6a2f903
    • David Carrillo-Cisneros's avatar
      perf/core: Generalize event->group_flags · 4ff6a8de
      David Carrillo-Cisneros authored
      Currently, PERF_GROUP_SOFTWARE is used in the group_flags field of a
      group's leader to indicate that is_software_event(event) is true for all
      events in a group. This is the only usage of event->group_flags.
      
      This pattern of setting a group level flags when all events in the group
      share a property is useful for the flag introduced in the next patch and
      for future CQM/CMT flags. So this patches generalizes group_flags to work
      as an aggregate of event level flags.
      
      PERF_GROUP_SOFTWARE denotes an inmutable event's property. All other flags
      that I intend to add are also determinable at event initialization.
      To better convey the above, this patch renames event's group_flags to
      group_caps and PERF_GROUP_SOFTWARE to PERF_EV_CAP_SOFTWARE.
      
      Individual event flags are stored in the new event->event_caps. Since the
      cap flags do not change after event initialization, there is no need to
      serialize event_caps. This new field is used when events are added to a
      context, similarly to how PERF_GROUP_SOFTWARE and is_software_event()
      worked.
      
      Lastly, for consistency, updates is_software_event() to rely in event_cap
      instead of the context index.
      Signed-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1471467307-61171-3-git-send-email-davidcc@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4ff6a8de
    • Madhavan Srinivasan's avatar
      bitmap.h, perf/core: Fix the mask in perf_output_sample_regs() · 29dd3288
      Madhavan Srinivasan authored
      When decoding the perf_regs mask in perf_output_sample_regs(),
      we loop through the mask using find_first_bit and find_next_bit functions.
      
      While the exisiting code works fine in most of the case, the logic
      is broken for big-endian 32-bit kernels.
      
      When reading a u64 mask using (u32 *)(&val)[0], find_*_bit() assumes
      that it gets the lower 32 bits of u64, but instead it gets the upper
      32 bits - which is wrong.
      
      The fix is to swap the words of the u64 to handle this case.
      This is _not_ a regular endianness swap.
      Suggested-by: default avatarYury Norov <ynorov@caviumnetworks.com>
      Signed-off-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarYury Norov <ynorov@caviumnetworks.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lkml.kernel.org/r/1471426568-31051-2-git-send-email-maddy@linux.vnet.ibm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      29dd3288