1. 13 9月, 2017 1 次提交
    • A
      perf tools: Support weak groups in 'perf stat' · 5a5dfe4b
      Andi Kleen 提交于
      Setting up groups can be complicated due to the complicated scheduling
      restrictions of different PMUs.
      
      User tools usually don't understand all these restrictions.
      
      Still in many cases it is useful to set up groups and they work most of
      the time. However if the group is set up wrong some members will not
      report any value because they never get scheduled.
      
      Add a concept of a 'weak group': try to set up a group, but if it's not
      schedulable fallback to not using a group. That gives us the best of
      both worlds: groups if they work, but still a usable fallback if they
      don't.
      
      In theory it would be possible to have more complex fallback strategies
      (e.g. try to split the group in half), but the simple fallback of not
      using a group seems to work for now.
      
      So far the weak group is only implemented for perf stat, not for record.
      
      Here's an unschedulable group (on IvyBridge with SMT on)
      
        % perf stat -e '{branches,branch-misses,l1d.replacement,l2_lines_in.all,l2_rqsts.all_code_rd}' -a sleep 1
      
              73,806,067      branches
               4,848,144      branch-misses             #    6.57% of all branches
              14,754,458      l1d.replacement
              24,905,558      l2_lines_in.all
         <not supported>      l2_rqsts.all_code_rd         <------- will never report anything
      
      With the weak group:
      
        % perf stat -e '{branches,branch-misses,l1d.replacement,l2_lines_in.all,l2_rqsts.all_code_rd}:W' -a sleep 1
      
             125,366,055      branches                                                      (80.02%)
               9,208,402      branch-misses             #    7.35% of all branches          (80.01%)
              24,560,249      l1d.replacement                                               (80.00%)
              43,174,971      l2_lines_in.all                                               (80.05%)
              31,891,457      l2_rqsts.all_code_rd                                          (79.92%)
      
      The extra event scheduled with some extra multiplexing
      
      v2: Move fallback code to separate function.
      Add comment on for_each_group_member
      Adjust to new perf_evsel__close interface
      v3: Fix debug print out.
      
      Committer testing:
      
      Before:
      
        # perf stat -e '{branches,branch-misses,l1d.replacement,l2_lines_in.all,l2_rqsts.all_code_rd}' -a sleep 1
      
         Performance counter stats for 'system wide':
      
           <not counted>      branches
           <not counted>      branch-misses
           <not counted>      l1d.replacement
           <not counted>      l2_lines_in.all
         <not supported>      l2_rqsts.all_code_rd
      
             1.002147212 seconds time elapsed
      
        # perf stat -e '{branches,l1d.replacement,l2_lines_in.all,l2_rqsts.all_code_rd}' -a sleep 1
      
         Performance counter stats for 'system wide':
      
              83,207,892      branches
              11,065,444      l1d.replacement
              28,484,024      l2_lines_in.all
              12,186,179      l2_rqsts.all_code_rd
      
             1.001739493 seconds time elapsed
      
      After:
      
        # perf stat -e '{branches,branch-misses,l1d.replacement,l2_lines_in.all,l2_rqsts.all_code_rd}':W -a sleep 1
      
         Performance counter stats for 'system wide':
      
             543,323,909      branches                                                      (80.01%)
              27,100,512      branch-misses             #    4.99% of all branches          (80.02%)
              50,402,905      l1d.replacement                                               (80.03%)
              67,385,892      l2_lines_in.all                                               (80.01%)
              21,352,885      l2_rqsts.all_code_rd                                          (79.94%)
      
             1.001086658 seconds time elapsed
      
        #
      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/20170831194036.30146-2-andi@firstfloor.org
      [ Add a "'perf stat' only, for now" comment in the man page, suggested by Jiri ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5a5dfe4b
  2. 02 9月, 2017 1 次提交
    • A
      perf stat: Only auto-merge events that are PMU aliases · 63ce8449
      Arnaldo Carvalho de Melo 提交于
      Peter reported that when he explicitely asked for multiple events with
      the same name on the command line it got coalesced into just one line,
      i.e.:
      
         # perf stat -e cycles -e cycles -e cycles usleep 1
      
         Performance counter stats for 'usleep 1':
      
               3,269,652      cycles
      
             0.000884123 seconds time elapsed
      
        #
      
      And while there is the --no-merges option to disable that auto-merging,
      this is a blunt change in behaviour for such explicit request, so change
      the code so that this auto merging is done only when handling the multi
      PMU aliases with the same name that introduced this coalescing,
      restoring the previous behaviour for the explicit case:
      
        # perf stat -e cycles -e cycles -e cycles usleep 1
      
         Performance counter stats for 'usleep 1':
      
               1,472,837      cycles
               1,472,837      cycles
               1,472,837      cycles
      
             0.001764870 seconds time elapsed
      
        #
      Reported-by: NPeter Zijlstra <peterz@infradead.org>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 430daf2d ("perf stat: Collapse identically named events")
      Link: http://lkml.kernel.org/r/20170831184122.GK4831@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      63ce8449
  3. 18 8月, 2017 3 次提交
  4. 19 7月, 2017 1 次提交
  5. 25 4月, 2017 2 次提交
  6. 20 4月, 2017 5 次提交
  7. 23 3月, 2017 3 次提交
    • A
      perf list: Move extra details printing to new option · bf874fcf
      Andi Kleen 提交于
      Move the printing of perf expressions and internal events to a new
      clearer --details flag, instead of lumping it together with other debug
      options in --debug. This makes it clearer to use.
      
      Before
      
        perf list --debug
        ...
        unc_m_power_critical_throttle_cycles
               [Cycles all ranks are in critical thermal throttle. Unit: uncore_imc]
                uncore_imc_2/event=0x86/  MetricName: power_critical_throttle_cycles % MetricExpr: (unc_m_power_critical_throttle_cycles / unc_m_clockticks) * 100.
      
      after
      
        perf list --details
        ...
        unc_m_power_critical_throttle_cycles
               [Cycles all ranks are in critical thermal throttle. Unit: uncore_imc]
                uncore_imc_2/event=0x86/  MetricName: power_critical_throttle_cycles % MetricExpr: (unc_m_power_critical_throttle_cycles / unc_m_clockticks) * 100.
      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/20170320201711.14142-14-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bf874fcf
    • A
      perf pmu: Add support for MetricName JSON attribute · 96284814
      Andi Kleen 提交于
      Add support for a new JSON event attribute to name MetricExpr for better
      output in perf stat.
      
      If the event has no MetricName it uses the normal event name instead to
      describe the metric.
      
      Before
      
        % perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}' --metric-only
                 time unc_p_freq_max_os_cycles
           1.000149775     15.7
           2.000344807     19.3
           3.000502544     16.7
           4.000640656      6.6
           5.000779955      9.9
      
      After
      
        % perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}' --metric-only
                 time freq_max_os_cycles %
           1.000149775     15.7
           2.000344807     19.3
           3.000502544     16.7
           4.000640656      6.6
           5.000779955      9.9
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20170320201711.14142-13-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      96284814
    • A
      perf stat: Output JSON MetricExpr metric · 37932c18
      Andi Kleen 提交于
      Add generic infrastructure to perf stat to output ratios for
      "MetricExpr" entries in the event lists. Many events are more useful as
      ratios than in raw form, typically some count in relation to total
      ticks.
      
      Transfer the MetricExpr information from the alias to the evsel.
      
      We mark the events that need to be collected for MetricExpr, and also
      link the events using them with a pointer. The code is careful to always
      prefer the right event in the same group to minimize multiplexing
      errors. At the moment only a single relation is supported.
      
      Then add a rblist to the stat shadow code that remembers stats based on
      the cpu and context.
      
      Then finally update and retrieve and print these values similarly to the
      existing hardcoded perf metrics. We use the simple expression parser
      added earlier to evaluate the expression.
      
      Normally we just output the result without further commentary, but for
      --metric-only this would lead to empty columns. So for this case use the
      original event as description.
      
      There is no attempt to automatically add the MetricExpr event, if it is
      missing, however we suggest it to the user, because the user tool
      doesn't have enough information to reliably construct a group that is
      guaranteed to schedule. So we leave that to the user.
      
        % perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}'
             1.000147889        800,085,181      unc_p_clockticks
             1.000147889         93,126,241      unc_p_freq_max_os_cycles  #     11.6
             2.000448381        800,218,217      unc_p_clockticks
             2.000448381        142,516,095      unc_p_freq_max_os_cycles  #     17.8
             3.000639852        800,243,057      unc_p_clockticks
             3.000639852        162,292,689      unc_p_freq_max_os_cycles  #     20.3
      
        % perf stat -a -I 1000 -e '{unc_p_clockticks,unc_p_freq_max_os_cycles}' --metric-only
        #    time         freq_max_os_cycles %
             1.000127077      0.9
             2.000301436      0.7
             3.000456379      0.0
      
      v2: Change from DivideBy to MetricExpr
      v3: Use expr__ prefix.  Support more than one other event.
      v4: Update description
      v5: Only print warning message once for multiple PMUs.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20170320201711.14142-11-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      37932c18
  8. 22 3月, 2017 2 次提交
  9. 04 3月, 2017 1 次提交
    • J
      perf tools: Force uncore events to system wide monitoring · e3ba76de
      Jiri Olsa 提交于
      Make system wide (-a) the default option if no target was specified and
      one of following conditions is met:
      
        - there's no workload specified (current behaviour)
        - there is workload specified but all requested
          events are system wide ones
      
      Mixed events core/uncore with workload:
      
        $ perf stat -e 'uncore_cbox_0/clockticks/,cycles' sleep 1
      
         Performance counter stats for 'sleep 1':
      
           <not supported>      uncore_cbox_0/clockticks/
                   980,489      cycles
      
               1.000897406 seconds time elapsed
      
      Uncore event with workload:
      
        $ perf stat -e 'uncore_cbox_0/clockticks/' sleep 1
      
         Performance counter stats for 'system wide':
      
        281,473,897,192,670      uncore_cbox_0/clockticks/
      
               1.000833784 seconds time elapsed
      
      Committer note:
      
      When testing I realized the default case for !root, i.e. no events
      passed via -e, was broke by v2 of this patch, reported and after a
      patch provided by Jiri it is back working:
      
        [acme@jouet linux]$ perf stat usleep 1
      
         Performance counter stats for 'usleep 1':
      
               0.401335      task-clock:u (msec)     #   0.297 CPUs utilized
                      0      context-switches:u      #   0.000 K/sec
                      0      cpu-migrations:u        #   0.000 K/sec
                     48      page-faults:u           #   0.120 M/sec
                458,146      cycles:u                #   1.142 GHz
                245,113      instructions:u          #   0.54  insn per cycle
                 47,991      branches:u              # 119.578 M/sec
                  4,022      branch-misses:u         #   8.38% of all branches
      
            0.001350029 seconds time elapsed
      
        [acme@jouet linux]$
      Suggested-and-Tested-by: NBorislav Petkov <bp@alien8.de>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      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: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170227094818.GA12764@kravaSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e3ba76de
  10. 18 2月, 2017 2 次提交
  11. 15 2月, 2017 1 次提交
  12. 08 2月, 2017 5 次提交
  13. 24 10月, 2016 1 次提交
  14. 04 10月, 2016 4 次提交
  15. 29 9月, 2016 3 次提交
  16. 14 9月, 2016 1 次提交
  17. 16 7月, 2016 1 次提交
    • W
      perf tools: Enable overwrite settings · 626a6b78
      Wang Nan 提交于
      This patch allows following config terms and option:
      
      Globally setting events to overwrite;
      
        # perf record --overwrite ...
      
      Set specific events to be overwrite or no-overwrite.
      
        # perf record --event cycles/overwrite/ ...
        # perf record --event cycles/no-overwrite/ ...
      
      Add missing config terms and update the config term array size because
      the longest string length has changed.
      
      For overwritable events, it automatically selects attr.write_backward
      since perf requires it to be backward for reading.
      
      Test result:
      
        # perf record --overwrite -e syscalls:*enter_nanosleep* usleep 1
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ]
        # perf evlist -v
        syscalls:sys_enter_nanosleep: type: 2, size: 112, config: 0x134, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, write_backward: 1
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-14-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      626a6b78
  18. 14 7月, 2016 3 次提交