1. 08 3月, 2016 23 次提交
    • A
      perf/x86/intel: Fix PEBS data source interpretation on Nehalem/Westmere · e17dc653
      Andi Kleen 提交于
      Jiri reported some time ago that some entries in the PEBS data source table
      in perf do not agree with the SDM. We investigated and the bits
      changed for Sandy Bridge, but the SDM was not updated.
      
      perf already implements the bits correctly for Sandy Bridge
      and later. This patch patches it up for Nehalem and Westmere.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1456871124-15985-1-git-send-email-andi@firstfloor.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e17dc653
    • S
      perf/x86/pebs: Add proper PEBS constraints for Broadwell · b3e62463
      Stephane Eranian 提交于
      This patch adds a Broadwell specific PEBS event constraint table.
      
      Broadwell has a fix for the HT corruption bug erratum HSD29 on
      Haswell. Therefore, there is no need to mark events 0xd0, 0xd1, 0xd2,
      0xd3 has requiring the exclusive mode across both sibling HT threads.
      This holds true for regular counting and sampling (see core.c) and
      PEBS (ds.c) which we fix in this patch.
      
      In doing so, we relax evnt scheduling for these events, they can now
      be programmed on any 4 counters without impacting what is measured on
      the sibling thread.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: acme@redhat.com
      Cc: adrian.hunter@intel.com
      Cc: jolsa@redhat.com
      Cc: kan.liang@intel.com
      Cc: namhyung@kernel.org
      Link: http://lkml.kernel.org/r/1457034642-21837-4-git-send-email-eranian@google.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      b3e62463
    • S
      perf/x86/pebs: Add workaround for broken OVFL status on HSW+ · 8077eca0
      Stephane Eranian 提交于
      This patch fixes an issue with the GLOBAL_OVERFLOW_STATUS bits on
      Haswell, Broadwell and Skylake processors when using PEBS.
      
      The SDM stipulates that when the PEBS iterrupt threshold is crossed,
      an interrupt is posted and the kernel is interrupted. The kernel will
      find GLOBAL_OVF_SATUS bit 62 set indicating there are PEBS records to
      drain. But the bits corresponding to the actual counters should NOT be
      set. The kernel follows the SDM and assumes that all PEBS events are
      processed in the drain_pebs() callback. The kernel then checks for
      remaining overflows on any other (non-PEBS) events and processes these
      in the for_each_bit_set(&status) loop.
      
      As it turns out, under certain conditions on HSW and later processors,
      on PEBS buffer interrupt, bit 62 is set but the counter bits may be
      set as well. In that case, the kernel drains PEBS and generates
      SAMPLES with the EXACT tag, then it processes the counter bits, and
      generates normal (non-EXACT) SAMPLES.
      
      I ran into this problem by trying to understand why on HSW sampling on
      a PEBS event was sometimes returning SAMPLES without the EXACT tag.
      This should not happen on user level code because HSW has the
      eventing_ip which always point to the instruction that caused the
      event.
      
      The workaround in this patch simply ensures that the bits for the
      counters used for PEBS events are cleared after the PEBS buffer has
      been drained. With this fix 100% of the PEBS samples on my user code
      report the EXACT tag.
      
      Before:
        $ perf record -e cpu/event=0xd0,umask=0x81/upp ./multichase
        $ perf report -D | fgrep SAMPLES
        PERF_RECORD_SAMPLE(IP, 0x2): 11775/11775: 0x406de5 period: 73469 addr: 0 exact=Y
                                 \--- EXACT tag is missing
      
      After:
        $ perf record -e cpu/event=0xd0,umask=0x81/upp ./multichase
        $ perf report -D | fgrep SAMPLES
        PERF_RECORD_SAMPLE(IP, 0x4002): 11775/11775: 0x406de5 period: 73469 addr: 0 exact=Y
                                 \--- EXACT tag is set
      
      The problem tends to appear more often when multiple PEBS events are used.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: adrian.hunter@intel.com
      Cc: kan.liang@intel.com
      Cc: namhyung@kernel.org
      Link: http://lkml.kernel.org/r/1457034642-21837-3-git-send-email-eranian@google.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      8077eca0
    • S
      perf/x86/intel: Add definition for PT PMI bit · 5690ae28
      Stephane Eranian 提交于
      This patch adds a definition for GLOBAL_OVFL_STATUS bit 55
      which is used with the Processor Trace (PT) feature.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: adrian.hunter@intel.com
      Cc: kan.liang@intel.com
      Cc: namhyung@kernel.org
      Link: http://lkml.kernel.org/r/1457034642-21837-2-git-send-email-eranian@google.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      5690ae28
    • K
      perf/x86/intel: Fix PEBS warning by only restoring active PMU in pmi · c3d266c8
      Kan Liang 提交于
      This patch tries to fix a PEBS warning found in my stress test. The
      following perf command can easily trigger the pebs warning or spurious
      NMI error on Skylake/Broadwell/Haswell platforms:
      
        sudo perf record -e 'cpu/umask=0x04,event=0xc4/pp,cycles,branches,ref-cycles,cache-misses,cache-references' --call-graph fp -b -c1000 -a
      
      Also the NMI watchdog must be enabled.
      
      For this case, the events number is larger than counter number. So
      perf has to do multiplexing.
      
      In perf_mux_hrtimer_handler, it does perf_pmu_disable(), schedule out
      old events, rotate_ctx, schedule in new events and finally
      perf_pmu_enable().
      
      If the old events include precise event, the MSR_IA32_PEBS_ENABLE
      should be cleared when perf_pmu_disable().  The MSR_IA32_PEBS_ENABLE
      should keep 0 until the perf_pmu_enable() is called and the new event is
      precise event.
      
      However, there is a corner case which could restore PEBS_ENABLE to
      stale value during the above period. In perf_pmu_disable(), GLOBAL_CTRL
      will be set to 0 to stop overflow and followed PMI. But there may be
      pending PMI from an earlier overflow, which cannot be stopped. So even
      GLOBAL_CTRL is cleared, the kernel still be possible to get PMI. At
      the end of the PMI handler, __intel_pmu_enable_all() will be called,
      which will restore the stale values if old events haven't scheduled
      out.
      
      Once the stale pebs value is set, it's impossible to be corrected if
      the new events are non-precise. Because the pebs_enabled will be set
      to 0. x86_pmu.enable_all() will ignore the MSR_IA32_PEBS_ENABLE
      setting. As a result, the following NMI with stale PEBS_ENABLE
      trigger pebs warning.
      
      The pending PMI after enabled=0 will become harmless if the NMI handler
      does not change the state. This patch checks cpuc->enabled in pmi and
      only restore the state when PMU is active.
      
      Here is the dump:
      
        Call Trace:
         <NMI>  [<ffffffff813c3a2e>] dump_stack+0x63/0x85
         [<ffffffff810a46f2>] warn_slowpath_common+0x82/0xc0
         [<ffffffff810a483a>] warn_slowpath_null+0x1a/0x20
         [<ffffffff8100fe2e>] intel_pmu_drain_pebs_nhm+0x2be/0x320
         [<ffffffff8100caa9>] intel_pmu_handle_irq+0x279/0x460
         [<ffffffff810639b6>] ? native_write_msr_safe+0x6/0x40
         [<ffffffff811f290d>] ? vunmap_page_range+0x20d/0x330
         [<ffffffff811f2f11>] ?  unmap_kernel_range_noflush+0x11/0x20
         [<ffffffff8148379f>] ? ghes_copy_tofrom_phys+0x10f/0x2a0
         [<ffffffff814839c8>] ? ghes_read_estatus+0x98/0x170
         [<ffffffff81005a7d>] perf_event_nmi_handler+0x2d/0x50
         [<ffffffff810310b9>] nmi_handle+0x69/0x120
         [<ffffffff810316f6>] default_do_nmi+0xe6/0x100
         [<ffffffff810317f2>] do_nmi+0xe2/0x130
         [<ffffffff817aea71>] end_repeat_nmi+0x1a/0x1e
         [<ffffffff810639b6>] ? native_write_msr_safe+0x6/0x40
         [<ffffffff810639b6>] ? native_write_msr_safe+0x6/0x40
         [<ffffffff810639b6>] ? native_write_msr_safe+0x6/0x40
         <<EOE>>  <IRQ>  [<ffffffff81006df8>] ?  x86_perf_event_set_period+0xd8/0x180
         [<ffffffff81006eec>] x86_pmu_start+0x4c/0x100
         [<ffffffff8100722d>] x86_pmu_enable+0x28d/0x300
         [<ffffffff811994d7>] perf_pmu_enable.part.81+0x7/0x10
         [<ffffffff8119cb70>] perf_mux_hrtimer_handler+0x200/0x280
         [<ffffffff8119c970>] ?  __perf_install_in_context+0xc0/0xc0
         [<ffffffff8110f92d>] __hrtimer_run_queues+0xfd/0x280
         [<ffffffff811100d8>] hrtimer_interrupt+0xa8/0x190
         [<ffffffff81199080>] ?  __perf_read_group_add.part.61+0x1a0/0x1a0
         [<ffffffff81051bd8>] local_apic_timer_interrupt+0x38/0x60
         [<ffffffff817af01d>] smp_apic_timer_interrupt+0x3d/0x50
         [<ffffffff817ad15c>] apic_timer_interrupt+0x8c/0xa0
         <EOI>  [<ffffffff81199080>] ?  __perf_read_group_add.part.61+0x1a0/0x1a0
         [<ffffffff81123de5>] ?  smp_call_function_single+0xd5/0x130
         [<ffffffff81123ddb>] ?  smp_call_function_single+0xcb/0x130
         [<ffffffff81199080>] ?  __perf_read_group_add.part.61+0x1a0/0x1a0
         [<ffffffff8119765a>] event_function_call+0x10a/0x120
         [<ffffffff8119c660>] ? ctx_resched+0x90/0x90
         [<ffffffff811971e0>] ? cpu_clock_event_read+0x30/0x30
         [<ffffffff811976d0>] ? _perf_event_disable+0x60/0x60
         [<ffffffff8119772b>] _perf_event_enable+0x5b/0x70
         [<ffffffff81197388>] perf_event_for_each_child+0x38/0xa0
         [<ffffffff811976d0>] ? _perf_event_disable+0x60/0x60
         [<ffffffff811a0ffd>] perf_ioctl+0x12d/0x3c0
         [<ffffffff8134d855>] ? selinux_file_ioctl+0x95/0x1e0
         [<ffffffff8124a3a1>] do_vfs_ioctl+0xa1/0x5a0
         [<ffffffff81036d29>] ? sched_clock+0x9/0x10
         [<ffffffff8124a919>] SyS_ioctl+0x79/0x90
         [<ffffffff817ac4b2>] entry_SYSCALL_64_fastpath+0x1a/0xa4
        ---[ end trace aef202839fe9a71d ]---
        Uhhuh. NMI received for unknown reason 2d on CPU 2.
        Do you have a strange power saving mode enabled?
      Signed-off-by: NKan Liang <kan.liang@intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      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>
      Link: http://lkml.kernel.org/r/1457046448-6184-1-git-send-email-kan.liang@intel.com
      [ Fixed various typos and other small details. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c3d266c8
    • J
      perf/x86/intel: Use PAGE_SIZE for PEBS buffer size on Core2 · e72daf3f
      Jiri Olsa 提交于
      Using PAGE_SIZE buffers makes the WRMSR to PERF_GLOBAL_CTRL in
      intel_pmu_enable_all() mysteriously hang on Core2. As a workaround, we
      don't do this.
      
      The hard lockup is easily triggered by running 'perf test attr'
      repeatedly. Most of the time it gets stuck on sample session with
      small periods.
      
        # perf test attr -vv
        14: struct perf_event_attr setup                             :
        --- start ---
        ...
          'PERF_TEST_ATTR=/tmp/tmpuEKz3B /usr/bin/perf record -o /tmp/tmpuEKz3B/perf.data -c 123 kill >/dev/null 2>&1' ret 1
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Cc: <stable@vger.kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20160301190352.GA8355@krava.redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e72daf3f
    • A
      perf/core: Fix perf_sched_count derailment · 927a5570
      Alexander Shishkin 提交于
      The error path in perf_event_open() is such that asking for a sampling
      event on a PMU that doesn't generate interrupts will end up in dropping
      the perf_sched_count even though it hasn't been incremented for this
      event yet.
      
      Given a sufficient amount of these calls, we'll end up disabling
      scheduler's jump label even though we'd still have active events in the
      system, thereby facilitating the arrival of the infernal regions upon us.
      
      I'm fixing this by moving account_event() inside perf_event_alloc().
      Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      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: vince@deater.net
      Link: http://lkml.kernel.org/r/1456917854-29427-1-git-send-email-alexander.shishkin@linux.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      927a5570
    • I
      Merge branch 'email/acme' into perf/core · b9461ba8
      Ingo Molnar 提交于
      Merge perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
          User visible changes:
      
       - Allow grouping multiple sort keys per 'perf report/top --hierarchy'
         level (Namhyung Kim)
      
       - Document 'perf stat --detailed' option (Borislav Petkov)
      
      Infrastructure changes:
      
       - jitdump prep work for supporting it with Intel PT (Adrian Hunter)
      
       - Use 64-bit shifts with (TSC) time conversion (Adrian Hunter)
      
      Fixes:
      
       - Explicitly declare inc_group_count as a void function (Colin Ian King)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b9461ba8
    • N
      perf report: Use hierarchy hpp list on gtk · 58ecd33b
      Namhyung Kim 提交于
      Now hpp formats are linked using perf_hpp_list_node when hierarchy is
      enabled.  Like in stdio, use this info to print entries with multiple
      sort keys in a single hierarchy properly.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-8-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      58ecd33b
    • N
      perf hists browser: Use hierarchy hpp list · a61a22f6
      Namhyung Kim 提交于
      Now hpp formats are linked using perf_hpp_list_node when hierarchy is
      enabled.  Like in stdio, use this info to print entries with multiple
      sort keys in a single hierarchy properly.
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-7-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a61a22f6
    • N
      perf report: Use hierarchy hpp list on stdio · f58c95e3
      Namhyung Kim 提交于
      Now hpp formats are linked using perf_hpp_list_node when hierarchy is
      enabled.  Use this info to print entries with multiple sort keys in a
      single hierarchy properly.
      
      For example, the below example shows using 4 sort keys with 2 levels.
      
        $ perf report --hierarchy -s '{prev_pid,prev_comm},{next_pid,next_comm}' \
         --percent-limit 1 -i perf.data.sched
        ...
        #    Overhead  prev_pid+prev_comm / next_pid+next_comm
        # ...........  .......................................
        #
            22.36%     0  swapper/0
                9.48%     17773  transmission-gt
                5.25%     109  kworker/0:1H
                1.53%     6524  Xephyr
            21.39%     17773  transmission-gt
                9.52%     0  swapper/0
                9.04%     0  swapper/2
                1.78%     0  swapper/3
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-6-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f58c95e3
    • N
      perf hists: Fix indent for multiple hierarchy sort key · 2dbbe9f2
      Namhyung Kim 提交于
      When multiple sort keys are used in a single hierarchy, it should indent
      using number of hierarchy levels instead of number of sort keys.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-5-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      2dbbe9f2
    • N
      perf hists: Support multiple sort keys in a hierarchy level · a23f37e8
      Namhyung Kim 提交于
      This implements having multiple sort keys in a single hierarchy level.
      Originally only single sort key is supported for each level, but now
      using the group syntax with '{ }', it can set more than one sort key in
      one level.  Note that now it needs to quote in order to prevent shell
      interpretation.
      
      For example:
      
        $ perf report --hierarchy -s '{comm,dso},sym'
        ...
        #       Overhead  Command / Shared Object / Symbol
        # ..............  ..........................................
        #
            48.67%        swapper          [kernel.vmlinux]
               34.42%        [k] intel_idle
                1.30%        [k] __tick_nohz_idle_enter
                1.03%        [k] cpuidle_reflect
             8.87%        firefox          libpthread-2.22.so
                6.60%        [.] __GI___libc_recvmsg
                1.18%        [.] pthread_cond_signal@@GLIBC_2.3.2
                1.09%        [.] 0x000000000000ff4b
             6.11%        Xorg             libc-2.22.so
                5.27%        [.] __memcpy_sse2_unaligned
      
      In the above example, the command name and the shared object name are
      shown on the same line but the symbol name is on the different line.
      Since the first two are grouped by '{}', they are in the same level.
      
      Suggested-and-Tested=by: Arnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-4-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a23f37e8
    • N
      perf hists: Use own hpp_list for hierarchy mode · 1b2dbbf4
      Namhyung Kim 提交于
      Now each hists has its own hpp lists in hierarchy.  So instead of having
      a pointer to a single perf_hpp_fmt in a hist entry, make it point the
      hpp_list for its level.  This will be used to support multiple sort keys
      in a single hierarchy level.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-3-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1b2dbbf4
    • N
      perf hists: Introduce perf_hpp__setup_hists_formats() · c3bc0c43
      Namhyung Kim 提交于
      The perf_hpp__setup_hists_formats() is to build hists-specific output
      formats (and sort keys).  Currently it's only used in order to build the
      output format in a hierarchy with same sort keys, but it could be used
      with different sort keys in non-hierarchy mode later.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457361308-514-2-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c3bc0c43
    • B
      perf stat: Document --detailed option · f594bae0
      Borislav Petkov 提交于
      I'm surprised this remained undocumented since at least 2011. And it is
      actually a very useful switch, as Steve and I came to realize recently.
      
      Add the text from
      
        2cba3ffb ("perf stat: Add -d -d and -d -d -d options to show more CPU events")
      
      which added the incrementing aspect to -d.
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Davidlohr Bueso <dbueso@suse.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mel Gorman <mgorman@suse.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 2cba3ffb ("perf stat: Add -d -d and -d -d -d options to show more CPU events")
      Link: http://lkml.kernel.org/r/1457347294-32546-1-git-send-email-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f594bae0
    • N
      perf hists: Add level field to struct perf_hpp_fmt · 4b633eba
      Namhyung Kim 提交于
      The level field is to distinguish levels in the hierarchy mode.
      Currently each column (perf_hpp_fmt) has a different level.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457103582-28396-2-git-send-email-namhyung@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      4b633eba
    • A
      perf tools: Use 64-bit shifts with (TSC) time conversion · a23f96ee
      Adrian Hunter 提交于
      Commit b9511cd7 ("perf/x86: Fix time_shift in perf_event_mmap_page")
      altered the time conversion algorithms documented in the perf_event.h
      header file, to use 64-bit shifts.  That was done to make the code more
      future-proof (i.e. some time in the future a 32-bit shift could be
      allowed).  Reflect those changes in perf tools.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1457005856-6143-9-git-send-email-adrian.hunter@intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a23f96ee
    • A
      perf jit: Move clockid validation · 4a018cc4
      Adrian Hunter 提交于
      Move clockid validation into jit_process() so it can later be made
      conditional.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1457005856-6143-6-git-send-email-adrian.hunter@intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      4a018cc4
    • A
      perf jit: Let jit_process() return errors · 570735b3
      Adrian Hunter 提交于
      In preparation for moving clockid validation into jit_process().
      
      Previously a return value of zero meant the processing had been done and
      non-zero meant either the processing was not done (i.e. not the jitdump
      file mmap event) or an error occurred.
      
      Change it so that zero means the processing was not done, one means the
      processing was done and successful, and negative values are an error.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1457005856-6143-5-git-send-email-adrian.hunter@intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      570735b3
    • A
      perf session: Simplify tool stubs · 5fb0ac16
      Adrian Hunter 提交于
      Some of the stubs are identical so just have one function for them.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1457005856-6143-3-git-send-email-adrian.hunter@intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      5fb0ac16
    • A
      perf inject: Hit all DSOs for AUX data in JIT and other cases · 640dad47
      Adrian Hunter 提交于
      Currently, when injecting build ids, if there is AUX data then 'perf
      inject' hits all DSOs because it is not known which DSOs the trace data
      would hit.
      
      That needs to be done for JIT injection also, and in fact there is no
      reason to distinguish what kind of injection is being done.  That is,
      any time there is AUX data and the HEADER_BUID_ID feature flag is set,
      and the AUX data is not being processed, then hit all DSOs.  This patch
      does that.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1457005856-6143-2-git-send-email-adrian.hunter@intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      640dad47
    • C
      perf tools: Explicitly declare inc_group_count as a void function · 07ef7574
      Colin Ian King 提交于
      The return type is not defined, so it defaults to int, however, the
      function is not returning anything, so this is clearly not correct. Make
      it a void function.
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1457008214-14393-1-git-send-email-colin.king@canonical.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      07ef7574
  2. 04 3月, 2016 1 次提交
    • I
      Merge tag 'perf-core-for-mingo-20160303' of... · 00966852
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-20160303' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes:
      
      User visible changes:
      
       - Check existence of frontend/backed stalled cycles in 'perf stat' (Andi Kleen)
      
       - Implement CSV metrics output in 'perf stat' (Andi Kleen)
      
       - Support metrics in 'perf stat' --per-core/socket mode (Andi Kleen)
      
       - Avoid installing .o files from tools/lib/ into the python extension (Jiri Olsa)
      
       - Rename the tracepoint '/format' field that carries the syscall ID from 'nr',
         that is also the name of some syscalls arguments, to "__syscall_nr", to
         avoid having multiple fields with the same name, that was breaking the
         python script skeleton generator from perf.data files (Taeung Song)
      
       - Support converting data from bpf events in 'perf data' (Wang Nan)
      
       - Fix segfault in 'perf test' hists related entries (Arnaldo Carvalho de Melo)
      
       - Fix output of %llu for 64 bit values read on 32 bit machines in libtraceevent (Steven Rostedt)
      
       - Fix time stamp rounding issue in libtraceevent (Chaos.Chen)
      
      Infrastructure changes:
      
       - Fix setlocale() breakage in the pmu parsing code (Jiri Olsa)
      
       - Split libtraceevent's pevent_print_event() (Steven Rostedt)
      
       - Librarize some 'perf record' bits to allow handling multiple perf.data
         files per session (Wang Nan)
      
       - Ensure return non-zero rc when mmap fails in 'perf record' (Wang Nan)
      
       - Fix double free on 'command_line' in a error path in 'perf script' (Colin Ian King)
      
       - Initialize struct sigaction 'sa_flags' field in a 'perf test' entry (Colin Ian King)
      
       - Fix various build warnings in turbostat, detected with gcc6 (Colin Ian King)
      
       - Use .s extension for preprocessed assembler code (Masahiro Yamada)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      00966852
  3. 03 3月, 2016 16 次提交
    • A
      perf stat: Check for frontend stalled for metrics · fb4605ba
      Andi Kleen 提交于
      Add an extra check for frontend stalled in the metrics.  This avoids an
      extra column for the --metric-only case when the CPU does not support
      frontend stalled.
      
      v2: Add separate init function
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/1456858672-21594-8-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fb4605ba
    • C
      tools/power turbostat: fix various build warnings · 1b69317d
      Colin Ian King 提交于
      When building with gcc 6 we're getting various build warnings that just
      require some trivial function declaration and call fixes:
      
        turbostat.c: In function ‘dump_cstate_pstate_config_info’:
        turbostat.c:1973:1: warning: type of ‘family’ defaults to ‘int’
         dump_cstate_pstate_config_info(family, model)
        turbostat.c:1973:1: warning: type of ‘model’ defaults to ‘int’
        turbostat.c: In function ‘get_tdp’:
        turbostat.c:2145:8: warning: type of ‘model’ defaults to ‘int’
         double get_tdp(model)
        turbostat.c: In function ‘perf_limit_reasons_probe’:
        turbostat.c:2259:6: warning: type of ‘family’ defaults to ‘int’
         void perf_limit_reasons_probe(family, model)
        turbostat.c:2259:6: warning: type of ‘model’ defaults to ‘int’
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/n/tip-wbicer8n0s9qe6ql8h9x478e@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1b69317d
    • C
      perf tests: Initialize sa.sa_flags · e17a0e16
      Colin Ian King 提交于
      The sa_flags field is not being initialized, so a garbage value is being
      passed to sigaction.  Initialize it to zero.
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1456923322-29697-1-git-send-email-colin.king@canonical.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e17a0e16
    • A
      perf test: Fix hists related entries · 9b240637
      Arnaldo Carvalho de Melo 提交于
      That got broken by d3a72fd8 ("perf report: Fix indentation of
      dynamic entries in hierarchy"), by using the evlist in setup_sorting()
      without checking if it is NULL, as done in some 'perf test' entries:
      
        $ find tools/ -name "*.c" | xargs grep 'setup_sorting(NULL);'
        tools/perf/tests/hists_output.c:      setup_sorting(NULL);
        tools/perf/tests/hists_output.c:      setup_sorting(NULL);
        tools/perf/tests/hists_output.c:      setup_sorting(NULL);
        tools/perf/tests/hists_output.c:      setup_sorting(NULL);
        tools/perf/tests/hists_output.c:      setup_sorting(NULL);
        tools/perf/tests/hists_cumulate.c:    setup_sorting(NULL);
        tools/perf/tests/hists_cumulate.c:    setup_sorting(NULL);
        tools/perf/tests/hists_cumulate.c:    setup_sorting(NULL);
        tools/perf/tests/hists_cumulate.c:    setup_sorting(NULL);
        $
      
      Fix it.
      
      Before:
      
        [root@jouet ~]# perf test
        <SNIP>
        15: Test matching and linking multiple hists                 : FAILED!
        16: Try 'import perf' in python, checking link problems      : Ok
        17: Test breakpoint overflow signal handler                  : Ok
        18: Test breakpoint overflow sampling                        : Ok
        19: Test number of exit event of a simple workload           : Ok
        20: Test software clock events have valid period values      : Ok
        21: Test object code reading                                 : Ok
        22: Test sample parsing                                      : Ok
        23: Test using a dummy software event to keep tracking       : Ok
        24: Test parsing with no sample_id_all bit set               : Ok
        25: Test filtering hist entries                              : FAILED!
        26: Test mmap thread lookup                                  : Ok
        27: Test thread mg sharing                                   : Ok
        28: Test output sorting of hist entries                      : FAILED!
        29: Test cumulation of child hist entries                    : FAILED!
        <SNIP>
      
      After the patch the above failed tests complete successfully.
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: d3a72fd8 ("perf report: Fix indentation of dynamic entries in hierarchy")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b240637
    • S
      tools lib traceevent: Fix output of %llu for 64 bit values read on 32 bit machines · a66673a0
      Steven Rostedt (Red Hat) 提交于
      When a long value is read on 32 bit machines for 64 bit output, the
      parsing needs to change "%lu" into "%llu", as the value is read
      natively.
      
      Unfortunately, if "%llu" is already there, the code will add another "l"
      to it and fail to parse it properly.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: http://lkml.kernel.org/r/20160209204237.337024613@goodmis.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a66673a0
    • S
      tools lib traceevent: Set int_array fields to NULL if freeing from error · 9ec72eaf
      Steven Rostedt (Red Hat) 提交于
      Had a bug where on error of parsing __print_array() where the fields are
      freed after they were allocated, but since they were not set to NULL,
      the freeing of the arg also tried to free the already freed fields
      causing a double free.
      
      Fix process_hex() while at it.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: http://lkml.kernel.org/r/20160209204237.188327674@goodmis.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9ec72eaf
    • C
      tools lib traceevent: Fix time stamp rounding issue · 21a30100
      Chaos.Chen 提交于
      When rounding to microseconds, if the timestamp subsecond is between
      .999999500 and .999999999, it is rounded to .1000000, when it should
      instead increment the second counter due to the overflow.
      
      For example, if the timestamp is 1234.999999501 instead of seeing:
      
        1235.000000
      
      we see:
      
        1234.1000000
      Signed-off-by: NChaos.Chen <rainboy1215@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: http://lkml.kernel.org/r/20160209204236.824426460@goodmis.org
      [ fixed incrementing "secs" instead of decrementing it ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      21a30100
    • C
      perf script: Fix double free on command_line · 979ac257
      Colin Ian King 提交于
      The 'command_line' variable is free'd twice if db_export__branch_types()
      fails. To avoid this, defer the free'ing of 'command_line' to after this
      call so that the error return path will just free 'command_line' once.
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Javi Merino <javi.merino@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1456875980-25606-1-git-send-email-colin.king@canonical.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      979ac257
    • M
      tools build: Use .s extension for preprocessed assembler code · 67678793
      Masahiro Yamada 提交于
      The "man gcc" says .i extension represents the file is C source code
      that should not be preprocessed.  Here, .s should be used.
      
      For clarification,
        .c  ---(preprocess)--->  .i
        .S  ---(preprocess)--->  .s
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Aaro Koskinen <aaro.koskinen@nokia.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Lukas Wunner <lukas@wunner.de>
      Link: http://lkml.kernel.org/r/1454263140-19670-1-git-send-email-yamada.masahiro@socionext.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      67678793
    • A
      perf stat: Support metrics in --per-core/socket mode · 44d49a60
      Andi Kleen 提交于
      Enable metrics printing in --per-core / --per-socket mode. We need to
      save the shadow metrics in a unique place. Always use the first CPU in
      the aggregation. Then use the same CPU to retrieve the shadow value
      later.
      
      Example output:
      
        % perf stat --per-core -a ./BC1s
      
         Performance counter stats for 'system wide':
      
        S0-C0 2   2966.020381 task-clock (msec) #   2.004 CPUs utilized  (100.00%)
        S0-C0 2            49 context-switches  #   0.017 K/sec          (100.00%)
        S0-C0 2             4 cpu-migrations    #   0.001 K/sec          (100.00%)
        S0-C0 2           467 page-faults       #   0.157 K/sec
        S0-C0 2 4,599,061,773 cycles            #   1.551 GHz            (100.00%)
        S0-C0 2 9,755,886,883 instructions      #   2.12  insn per cycle (100.00%)
        S0-C0 2 1,906,272,125 branches          # 642.704 M/sec          (100.00%)
        S0-C0 2    81,180,867 branch-misses     #   4.26% of all branches
        S0-C1 2   2965.995373 task-clock (msec) #   2.003 CPUs utilized  (100.00%)
        S0-C1 2            62 context-switches  #   0.021 K/sec          (100.00%)
        S0-C1 2             8 cpu-migrations    #   0.003 K/sec          (100.00%)
        S0-C1 2           281 page-faults       #   0.095 K/sec
        S0-C1 2     6,347,290 cycles            #   0.002 GHz            (100.00%)
        S0-C1 2     4,654,156 instructions      #   0.73  insn per cycle (100.00%)
        S0-C1 2       947,121 branches          #   0.319 M/sec          (100.00%)
        S0-C1 2        37,322 branch-misses     #   3.94% of all branches
      
               1.480409747 seconds time elapsed
      
      v2: Rebase to older patches
      v3: Document shadow cpus. Fix aggr_get_id argument. Fix -A shadows (Jiri)
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/1456785386-19481-4-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      44d49a60
    • A
      perf stat: Implement CSV metrics output · 92a61f64
      Andi Kleen 提交于
      Now support CSV output for metrics. With the new output callbacks this
      is relatively straight forward by creating new callbacks.
      
      This allows to easily plot metrics from CSV files.
      
      The new line callback needs to know the number of fields to skip them
      correctly
      
      Example output before:
      
        % perf stat -x, true
        0.200687,,task-clock,200687,100.00
        0,,context-switches,200687,100.00
        0,,cpu-migrations,200687,100.00
        40,,page-faults,200687,100.00
        730871,,cycles,203601,100.00
        551056,,stalled-cycles-frontend,203601,100.00
        <not supported>,,stalled-cycles-backend,0,100.00
        385523,,instructions,203601,100.00
        78028,,branches,203601,100.00
        3946,,branch-misses,203601,100.00
      
      After:
      
        % perf stat -x, true
        .502457,,task-clock,502457,100.00,0.485,CPUs utilized
        0,,context-switches,502457,100.00,0.000,K/sec
        0,,cpu-migrations,502457,100.00,0.000,K/sec
        45,,page-faults,502457,100.00,0.090,M/sec
        644692,,cycles,509102,100.00,1.283,GHz
        423470,,stalled-cycles-frontend,509102,100.00,65.69,frontend cycles idle
        <not supported>,,stalled-cycles-backend,0,100.00,,,,
        492701,,instructions,509102,100.00,0.76,insn per cycle
        ,,,,,0.86,stalled cycles per insn
        97767,,branches,509102,100.00,194.578,M/sec
        4788,,branch-misses,509102,100.00,4.90,of all branches
      
      or easier readable
      
        $ perf stat  -x, -o x.csv true
        $ column -s, -t x.csv
        0.490635        task-clock              490635 100.00 0.489   CPUs utilized
        0               context-switches        490635 100.00 0.000   K/sec
        0               cpu-migrations          490635 100.00 0.000   K/sec
        45              page-faults             490635 100.00 0.092   M/sec
        629080          cycles                  497698 100.00 1.282   GHz
        409498          stalled-cycles-frontend 497698 100.00 65.09   frontend cycles idle
        <not supported> stalled-cycles-backend  0      100.00
        491424          instructions            497698 100.00 0.78    insn per cycle
                                                              0.83    stalled cycles per insn
        97278           branches                497698 100.00 198.270 M/sec
        4569            branch-misses           497698 100.00 4.70    of all branches
      
      Two new fields are added: metric value and metric name.
      
      v2: Split out function argument changes
      v3: Reenable metrics for real.
      v4: Fix wrong hunk from refactoring.
      v5: Remove extra "noise" printing (Jiri), but add it to the not counted case.
      Print empty metrics for not counted.
      v6: Avoid outputting metric on empty format.
      v7: Print metric at the end
      v8: Remove extra run, ena fields
      v9: Avoid extra new line for unsupported counters
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Link: http://lkml.kernel.org/r/1456785386-19481-3-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      92a61f64
    • W
      perf record: Ensure return non-zero rc when mmap fail · 95c36561
      Wang Nan 提交于
      perf_evlist__mmap_ex() can fail without setting errno (for example, fail
      in condition checking. In this case all syscall is success).
      
      If this happen, record__open() incorrectly returns 0. Force setting rc
      is a quick way to avoid this problem, or we have to follow all possible
      code path in perf_evlist__mmap_ex() to make sure there's at least one
      system call before returning an error.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1456479154-136027-30-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      95c36561
    • W
      perf record: Introduce record__finish_output() to finish a perf.data · e1ab48ba
      Wang Nan 提交于
      Move code for finalizing 'perf.data' to record__finish_output(). It will
      be used by following commits to split output to multiple files.
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1456479154-136027-23-git-send-email-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e1ab48ba
    • W
      perf record: Extract synthesize code to record__synthesize() · c45c86eb
      Wang Nan 提交于
      Create record__synthesize(). It can be used to create tracking events
      for each perf.data after perf supporting splitting into multiple
      outputs.
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1456479154-136027-20-git-send-email-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c45c86eb
    • W
      perf record: Use WARN_ONCE to replace 'if' condition · d8871ea7
      Wang Nan 提交于
      Commits in a BPF patchkit will extract kernel and module synthesizing
      code into a separated function and call it multiple times. This patch
      replace 'if (err < 0)' using WARN_ONCE, makes sure the error message
      show one time.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1456479154-136027-19-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d8871ea7
    • W
      perf data: Explicitly set byte order for integer types · f8dd2d5f
      Wang Nan 提交于
      After babeltrace commit 5cec03e402aa ("ir: copy variants and sequences
      when setting a field path"), 'perf data convert' gets incorrect result
      if there's bpf output data. For example:
      
       # perf data convert --to-ctf ./out.ctf
       # babeltrace ./out.ctf
       [10:44:31.186045346] (+?.?????????) evt: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF810E7DD1, perf_tid = 23819, perf_pid = 23819, perf_id = 518, raw_len = 3, raw_data = [ [0] = 0xC028E32F, [1] = 0x815D0100, [2] = 0x1000000 ] }
       [10:44:31.286101003] (+0.100055657) evt: { cpu_id = 0 }, { perf_ip = 0xFFFFFFFF8105B609, perf_tid = 23819, perf_pid = 23819, perf_id = 518, raw_len = 3, raw_data = [ [0] = 0x35D9F1EB, [1] = 0x15D81, [2] = 0x2 ] }
      
      The expected result of the first sample should be:
      
       raw_data = [ [0] = 0x2FE328C0, [1] = 0x15D81, [2] = 0x1 ] }
      
      however, 'perf data convert' output big endian value to resuling CTF
      file.
      
      The reason is a internal change (or a bug?) of babeltrace.
      
      Before this patch, at the first add_bpf_output_values(), byte order of
      all integer type is uncertain (is 0, neither 1234 (le) nor 4321 (be)).
      It would be fixed by:
      
      perf_evlist__deliver_sample
       -> process_sample_event
         -> ctf_stream
            ...
            ->bt_ctf_trace_add_stream_class
              ->bt_ctf_field_type_structure_set_byte_order
                ->bt_ctf_field_type_integer_set_byte_order
      
      during creating the stream.
      
      However, the babeltrace commit mentioned above duplicates types in
      sequence to prevent potential conflict in following call stack and link
      the newly allocated type into the 'raw_data' sequence:
      
      perf_evlist__deliver_sample
       -> process_sample_event
         -> ctf_stream
            ...
            -> bt_ctf_trace_add_stream_class
              -> bt_ctf_stream_class_resolve_types
                 ...
                 -> bt_ctf_field_type_sequence_copy
                   ->bt_ctf_field_type_integer_copy
      
      This happens before byte order setting, so only the newly allocated
      type is initialized, the byte order of original type perf choose to
      create the first raw_data is still uncertain.
      
      Byte order in CTF output is not related to byte order in perf.data.
      Setting it to anything other than BT_CTF_BYTE_ORDER_NATIVE solves this
      problem (only BT_CTF_BYTE_ORDER_NATIVE needs to be fixed). To reduce
      behavior changing, set byte order according to compiling options.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jérémie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1456479154-136027-10-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f8dd2d5f