1. Sep 01, 2022
    • Like Xu's avatar
      perf/x86/core: Completely disable guest PEBS via guest's global_ctrl · f2aeea57
      Like Xu authored
      When a guest PEBS counter is cross-mapped by a host counter, software
      will remove the corresponding bit in the arr[global_ctrl].guest and
      expect hardware to perform a change of state "from enable to disable"
      via the msr_slot[] switch during the vmx transaction.
      
      The real world is that if user adjust the counter overflow value small
      enough, it still opens a tiny race window for the previously PEBS-enabled
      counter to write cross-mapped PEBS records into the guest's PEBS buffer,
      when arr[global_ctrl].guest has been prioritised (switch_msr_special stuff)
      to switch into the enabled state, while the arr[pebs_enable].guest has not.
      
      Close this window by clearing invalid bits in the arr[global_ctrl].guest.
      
      Fixes: 85425032
      
       ("KVM: x86/pmu: Disable guest PEBS temporarily in two rare situations")
      Signed-off-by: default avatarLike Xu <likexu@tencent.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220831033524.58561-1-likexu@tencent.com
      f2aeea57
    • Kan Liang's avatar
      perf/x86/intel: Fix unchecked MSR access error for Alder Lake N · 24919fde
      Kan Liang authored
      For some Alder Lake N machine, the below unchecked MSR access error may be
      triggered.
      
      [ 0.088017] rcu: Hierarchical SRCU implementation.
      [ 0.088017] unchecked MSR access error: WRMSR to 0x38f (tried to write
      0x0001000f0000003f) at rIP: 0xffffffffb5684de8 (native_write_msr+0x8/0x30)
      [ 0.088017] Call Trace:
      [ 0.088017] <TASK>
      [ 0.088017] __intel_pmu_enable_all.constprop.46+0x4a/0xa0
      
      The Alder Lake N only has e-cores. The X86_FEATURE_HYBRID_CPU flag is
      not set. The perf cannot retrieve the correct CPU type via
      get_this_hybrid_cpu_type(). The model specific get_hybrid_cpu_type() is
      hardcode to p-core. The wrong CPU type is given to the PMU of the
      Alder Lake N.
      
      Since Alder Lake N isn't in fact a hybrid CPU, remove ALDERLAKE_N from
      the rest of {ALDER,RAPTOP}LAKE and create a non-hybrid PMU setup.
      
      The differences between Gracemont and the previous Tremont are,
      - Number of GP counters
      - Load and store latency Events
      - PEBS event_constraints
      - Instruction Latency support
      - Data source encoding
      - Memory access latency encoding
      
      Fixes: c2a960f7
      
       ("perf/x86: Add new Alder Lake and Raptor Lake support")
      Reported-by: default avatarJianfeng Gao <jianfeng.gao@intel.com>
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220831142702.153110-1-kan.liang@linux.intel.com
      24919fde
  2. Aug 29, 2022
  3. Aug 28, 2022
  4. Aug 27, 2022
    • Zhengjun Xing's avatar
      perf stat: Capitalize topdown metrics' names · 48648548
      Zhengjun Xing authored
      
      
      Capitalize topdown metrics' names to follow the intel SDM.
      
      Before:
      
       # ./perf stat -a  sleep 1
      
       Performance counter stats for 'system wide':
      
              228,094.05 msec cpu-clock                        #  225.026 CPUs utilized
                     842      context-switches                 #    3.691 /sec
                     224      cpu-migrations                   #    0.982 /sec
                      70      page-faults                      #    0.307 /sec
              23,164,105      cycles                           #    0.000 GHz
              29,403,446      instructions                     #    1.27  insn per cycle
               5,268,185      branches                         #   23.097 K/sec
                  33,239      branch-misses                    #    0.63% of all branches
             136,248,990      slots                            #  597.337 K/sec
              32,976,450      topdown-retiring                 #     24.2% retiring
               4,651,918      topdown-bad-spec                 #      3.4% bad speculation
              26,148,695      topdown-fe-bound                 #     19.2% frontend bound
              72,515,776      topdown-be-bound                 #     53.2% backend bound
               6,008,540      topdown-heavy-ops                #      4.4% heavy operations       #     19.8% light operations
               3,934,049      topdown-br-mispredict            #      2.9% branch mispredict      #      0.5% machine clears
              16,655,439      topdown-fetch-lat                #     12.2% fetch latency          #      7.0% fetch bandwidth
              41,635,972      topdown-mem-bound                #     30.5% memory bound           #     22.7% Core bound
      
             1.013634593 seconds time elapsed
      
      After:
      
       # ./perf stat -a  sleep 1
      
       Performance counter stats for 'system wide':
      
              228,081.94 msec cpu-clock                        #  225.003 CPUs utilized
                     824      context-switches                 #    3.613 /sec
                     224      cpu-migrations                   #    0.982 /sec
                      67      page-faults                      #    0.294 /sec
              22,647,423      cycles                           #    0.000 GHz
              28,870,551      instructions                     #    1.27  insn per cycle
               5,167,099      branches                         #   22.655 K/sec
                  32,383      branch-misses                    #    0.63% of all branches
             133,411,074      slots                            #  584.926 K/sec
              32,352,607      topdown-retiring                 #     24.3% Retiring
               4,456,977      topdown-bad-spec                 #      3.3% Bad Speculation
              25,626,487      topdown-fe-bound                 #     19.2% Frontend Bound
              70,955,316      topdown-be-bound                 #     53.2% Backend Bound
               5,834,844      topdown-heavy-ops                #      4.4% Heavy Operations       #     19.9% Light Operations
               3,738,781      topdown-br-mispredict            #      2.8% Branch Mispredict      #      0.5% Machine Clears
              16,286,803      topdown-fetch-lat                #     12.2% Fetch Latency          #      7.0% Fetch Bandwidth
              40,802,069      topdown-mem-bound                #     30.6% Memory Bound           #     22.6% Core Bound
      
             1.013683125 seconds time elapsed
      
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarXing Zhengjun <zhengjun.xing@linux.intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220825015458.3252239-1-zhengjun.xing@linux.intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      48648548
    • Kan Liang's avatar
      perf docs: Update the documentation for the save_type filter · 3126204c
      Kan Liang authored
      
      
      Update the documentation to reflect the kernel changes.
      
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220816125612.2042397-2-kan.liang@linux.intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3126204c
    • Ian Rogers's avatar
      perf sched: Fix memory leaks in __cmd_record detected with -fsanitize=address · d72e5cf3
      Ian Rogers authored
      
      
      An array of strings is passed to cmd_record but not freed. As
      cmd_record modifies the array, add another array as a copy that can be
      mutated allowing the original array contents to all be freed.
      
      Detected with -fsanitize=address.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220824145733.409005-1-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d72e5cf3
    • Andi Kleen's avatar
      perf record: Fix manpage formatting of description of support to hybrid systems · e89eaa61
      Andi Kleen authored
      
      
      The Intel hybrid description is written in a different style than the
      rest of the perf record man page. There were some new command line
      options added after it which resulted in very strange section ordering.
      Move the hybrid include last.
      
      Also the sub sections in the hybrid document don't fit the record
      manpage well (especially since it talks about all kinds of unrelated
      commands). I left this for now, but would be better to separate this
      properly in the different man pages.
      
      It would be better to use sub sections for the other sections, but these
      don't seem to be supported in AsciiDoc?
      
      Some of the examples are still misrendered in the manpage with an
      indented troff command, but I don't know how to fix that.
      
      In any case it's now better than before.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: zhengjun.xing@intel.com
      Link: https://lore.kernel.org/r/20220818100127.249401-1-ak@linux.intel.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e89eaa61
    • Ian Rogers's avatar
      perf test: Stat test for repeat with a weak group · 0c361c6e
      Ian Rogers authored
      
      
      Breaking a weak group requires multiple passes of an evlist, with
      multiple runs this can introduce bugs ultimately leading to
      segfaults. Add a test to cover this.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220822213352.75721-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c361c6e