1. 24 Aug, 2023 12 commits
    • Ian Rogers's avatar
      perf pmu: Cache JSON events table · 7c52f10c
      Ian Rogers authored
      Cache the JSON events table so that finding it isn't done per
      event/alias.
      
      Change the events table find so that when the PMU is given, if the PMU
      has no JSON events return null.
      
      Update usage to always use the PMU variable.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7c52f10c
    • Ian Rogers's avatar
      perf pmu: Merge JSON events with sysfs at load time · f63a536f
      Ian Rogers authored
      Rather than load all sysfs events then parsing all JSON events and
      merging with ones that already exist. When a sysfs event is loaded, look
      for a corresponding JSON event and merge immediately.
      
      To simplify the logic, early exit the perf_pmu__new_alias function if an
      alias is attempted to be added twice - as merging has already been
      explicitly handled.
      
      Fix the copying of terms to a merged alias and some ENOMEM paths.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-12-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f63a536f
    • Ian Rogers's avatar
      perf pmu: Prefer passing pmu to aliases list · f26d22f1
      Ian Rogers authored
      The aliases list is part of the PMU. Rather than pass the aliases
      list, pass the full PMU simplifying some callbacks.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-11-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f26d22f1
    • Ian Rogers's avatar
      perf pmu: Parse sysfs events directly from a file · edb217ff
      Ian Rogers authored
      Rather than read a sysfs events file into a 256 byte char buffer, pass
      the FILE* directly to the lex/yacc parser.
      
      This avoids there being a maximum events file size.
      
      While changing the API, constify some arguments to remove unnecessary
      casts.
      
      Allocating the read buffer decreases the performance of pmu-scan by
      around 3%.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edb217ff
    • Ian Rogers's avatar
      perf pmu-events: Add pmu_events_table__find_event() · 3d504549
      Ian Rogers authored
      jevents stores events sorted by name. Add a find function that will
      binary search event names avoiding the need to linearly search through
      events.
      
      Add a test in tests/pmu-events.c. If the PMU or event aren't found -1000
      is returned. If the event is found but no callback function given, 0 is
      returned.
      
      This allows the find function also act as a test for existence.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-9-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d504549
    • Ian Rogers's avatar
      perf pmu-events: Reduce processed events by passing PMU · e3edd6cf
      Ian Rogers authored
      Pass the PMU to pmu_events_table__for_each_event so that entries that
      don't match don't need to be processed by callback.
      
      If a NULL PMU is passed then all PMUs are processed.
      
      'perf bench internals pmu-scan's "Average PMU scanning" performance is
      reduced by about 5% on an Intel tigerlake.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-8-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e3edd6cf
    • Ian Rogers's avatar
      perf s390 s390_cpumcfdg_dump: Don't scan all PMUs · c4ac7f75
      Ian Rogers authored
      Rather than scanning all PMUs for a counter name, scan the PMU
      associated with the evsel of the sample. This is done to remove a
      dependence on pmu-events.h.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-7-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c4ac7f75
    • Ian Rogers's avatar
      perf parse-events: Improve error message for double setting · 9d31cb93
      Ian Rogers authored
      Double setting information for an event would produce an error message
      associated with the PMU rather than the term that was double setting.
      Improve the error message to be on the term.
      
      Before:
      
        $ perf stat -e 'cpu/inst_retired.any,inst_retired.any/' true
        event syntax error: 'cpu/inst_retired.any,inst_retired.any/'
                             \___ Bad event or PMU
      
        Unabled to find PMU or event on a PMU of 'cpu'
        Run 'perf list' for a list of valid events
        $
      
      After:
      
        $ perf stat -e 'cpu/inst_retired.any,inst_retired.any/' true
        event syntax error: '..etired.any,inst_retired.any/'
                                          \___ Bad event or PMU
      
        Unabled to find PMU or event on a PMU of 'cpu'
      
        Initial error:
      
        event syntax error: '..etired.any,inst_retired.any/'
                                          \___ Attempt to set event's scale twice
        Run 'perf list' for a list of valid events
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d31cb93
    • Ian Rogers's avatar
      perf jevents: Group events by PMU · 2e255b4f
      Ian Rogers authored
      Prior to this change a cpuid would map to a list of events where the PMU
      would be encoded alongside the event information. This change breaks
      apart each group of events so that there is a group per PMU. A new table
      is added with the PMU's name and the list of events, the original table
      now holding an array of these per PMU tables.
      
      These changes are to make it easier to get per PMU information about
      events, rather than the current approach of scanning all events. The
      perf binary size with BPF skeletons on x86 is reduced by about 1%. The
      unidentified PMU is now always expanded to "cpu".
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2e255b4f
    • Ian Rogers's avatar
      perf pmu-events: Add extra underscore to function names · 4000519e
      Ian Rogers authored
      Add extra underscore before "for" of pmu_events_table_for_each_event
      and pmu_metrics_table_for_each_metric.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4000519e
    • Ian Rogers's avatar
      perf pmu: Abstract alias/event struct · c3245d20
      Ian Rogers authored
      In order to be able to lazily compute aliases/events for a PMU, move
      the struct perf_pmu_alias into pmu.c.
      
      Add perf_pmu__find_event and perf_pmu__for_each_event that take a
      callback that is called for the found event or for each event.
      
      The layout of struct pmu and the event/alias list is unchanged but the
      API is altered so that aliases are no longer directly accessed, allowing
      for later changes.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3245d20
    • Ian Rogers's avatar
      perf pmu: Make the loading of formats lazy · 50402641
      Ian Rogers authored
      The sysfs format files are loaded eagerly in a PMU. Add a flag so that
      we create the format but only load the contents when necessary.
      
      Reduce the size of the value in struct perf_pmu_format and avoid holes
      so there is no additional space requirement.
      
      For "perf stat -e cycles true" this reduces the number of openat calls
      from 648 to 573 (about 12%). The benchmark pmu scan speed is improved
      by roughly 5%.
      
      Before:
      
        $ perf bench internals pmu-scan
        Computing performance of sysfs PMU event scan for 100 times
          Average core PMU scanning took: 1061.100 usec (+- 9.965 usec)
          Average PMU scanning took: 4725.300 usec (+- 260.599 usec)
      
      After:
      
        $ perf bench internals pmu-scan
        Computing performance of sysfs PMU event scan for 100 times
          Average core PMU scanning took: 989.170 usec (+- 6.873 usec)
          Average PMU scanning took: 4520.960 usec (+- 251.272 usec)
      
      Committer testing:
      
      On a AMD Ryzen 5950x:
      
      Before:
      
        $ perf bench internals pmu-scan -i1000
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 563.466 usec (+- 1.008 usec)
          Average PMU scanning took: 1619.174 usec (+- 23.627 usec)
        $ perf stat -r5 perf bench internals pmu-scan -i1000
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 583.401 usec (+- 2.098 usec)
          Average PMU scanning took: 1677.352 usec (+- 24.636 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 553.254 usec (+- 0.825 usec)
          Average PMU scanning took: 1635.655 usec (+- 24.312 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 557.733 usec (+- 0.980 usec)
          Average PMU scanning took: 1600.659 usec (+- 23.344 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 554.906 usec (+- 0.774 usec)
          Average PMU scanning took: 1595.338 usec (+- 23.288 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 551.798 usec (+- 0.967 usec)
          Average PMU scanning took: 1623.213 usec (+- 23.998 usec)
      
         Performance counter stats for 'perf bench internals pmu-scan -i1000' (5 runs):
      
                   3276.82 msec task-clock:u                     #    0.990 CPUs utilized               ( +-  0.82% )
                         0      context-switches:u               #    0.000 /sec
                         0      cpu-migrations:u                 #    0.000 /sec
                      1008      page-faults:u                    #  307.615 /sec                        ( +-  0.04% )
               12049614778      cycles:u                         #    3.677 GHz                         ( +-  0.07% )  (83.34%)
                 117507478      stalled-cycles-frontend:u        #    0.98% frontend cycles idle        ( +-  0.33% )  (83.32%)
                  27106761      stalled-cycles-backend:u         #    0.22% backend cycles idle         ( +-  9.55% )  (83.36%)
               33294953848      instructions:u                   #    2.76  insn per cycle
                                                                 #    0.00  stalled cycles per insn     ( +-  0.03% )  (83.31%)
                6849825049      branches:u                       #    2.090 G/sec                       ( +-  0.03% )  (83.37%)
                  71533903      branch-misses:u                  #    1.04% of all branches             ( +-  0.20% )  (83.30%)
      
                    3.3088 +- 0.0302 seconds time elapsed  ( +-  0.91% )
      
        $
      
      After:
      
        $ perf stat -r5 perf bench internals pmu-scan -i1000
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 550.702 usec (+- 0.958 usec)
          Average PMU scanning took: 1566.577 usec (+- 22.747 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 548.315 usec (+- 0.555 usec)
          Average PMU scanning took: 1565.499 usec (+- 22.760 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 548.073 usec (+- 0.555 usec)
          Average PMU scanning took: 1586.097 usec (+- 23.299 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 561.184 usec (+- 2.709 usec)
          Average PMU scanning took: 1567.153 usec (+- 22.548 usec)
        # Running 'internals/pmu-scan' benchmark:
        Computing performance of sysfs PMU event scan for 1000 times
          Average core PMU scanning took: 546.987 usec (+- 0.553 usec)
          Average PMU scanning took: 1562.814 usec (+- 22.729 usec)
      
         Performance counter stats for 'perf bench internals pmu-scan -i1000' (5 runs):
      
                   3170.86 msec task-clock:u                     #    0.992 CPUs utilized               ( +-  0.22% )
                         0      context-switches:u               #    0.000 /sec
                         0      cpu-migrations:u                 #    0.000 /sec
                      1010      page-faults:u                    #  318.526 /sec                        ( +-  0.04% )
               11890047674      cycles:u                         #    3.750 GHz                         ( +-  0.14% )  (83.27%)
                 119090499      stalled-cycles-frontend:u        #    1.00% frontend cycles idle        ( +-  0.46% )  (83.40%)
                  32502449      stalled-cycles-backend:u         #    0.27% backend cycles idle         ( +-  8.32% )  (83.30%)
               33119141261      instructions:u                   #    2.79  insn per cycle
                                                          #    0.00  stalled cycles per insn     ( +-  0.01% )  (83.37%)
                6812816561      branches:u                       #    2.149 G/sec                       ( +-  0.01% )  (83.29%)
                  70157855      branch-misses:u                  #    1.03% of all branches             ( +-  0.28% )  (83.38%)
      
                   3.19710 +- 0.00826 seconds time elapsed  ( +-  0.26% )
      
        $
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230824041330.266337-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      50402641
  2. 23 Aug, 2023 10 commits
    • Guilherme Amadio's avatar
      perf build: Allow customization of clang options for BPF target · 9e1f1693
      Guilherme Amadio authored
      This also puts an unconditional -Werror under control of WERROR. The
      clang includes added during the build can lead to a warning that may be
      turned into an error. In addition, hardened clang produces a warning
      about lack of support for -fstack-protector* options for the BPF target:
      
        clang -g -O2 -target bpf -Wall -Werror -Ilinux/tools/perf/util/bpf_skel/.tmp/.. \
          -I -idirafter /usr/lib/llvm/16/bin/../../../../lib/clang/16/include -idirafter /usr/local/include \
          -idirafter /usr/include  -Ilinux/tools/include/uapi -c util/bpf_skel/bperf_follower.bpf.c \
          -o linux/tools/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o && llvm-strip -g linux/tools/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o
        clang-16: error: /usr/lib/llvm/16/bin/../../../../lib/clang/16/include: 'linker' input unused [-Werror,-Wunused-command-line-argument]
        clang-16: error: ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]
        make[1]: *** [Makefile.perf:1082: linux/tools/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o] Error 1
      Signed-off-by: default avatarGuilherme Amadio <amadio@gentoo.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZOZQ2LDA+3Wg8x2T@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9e1f1693
    • Ian Rogers's avatar
      perf pmu: Pass PMU rather than aliases and format · 838a8c5f
      Ian Rogers authored
      Pass the pmu so the aliases and format list can be better abstracted
      and later lazily loaded.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-9-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      838a8c5f
    • Ian Rogers's avatar
      perf pmu: Avoid passing format list to perf_pmu__format_bits() · da6a5afd
      Ian Rogers authored
      Pass the PMU so the format list can be better abstracted and later
      lazily loaded.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-8-irogers@google.com
      [ Did missing conversions in tools/perf/arch/arm*/util/cs-etm.c ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      da6a5afd
    • Ian Rogers's avatar
      perf pmu: Avoid passing format list to perf_pmu__format_type · 7eb54733
      Ian Rogers authored
      Pass the pmu so the format list can be better abstracted and later
      lazily loaded.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-7-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7eb54733
    • Ian Rogers's avatar
      perf pmu: Avoid passing format list to perf_pmu__config_terms() · 804fee5d
      Ian Rogers authored
      Abstract the format list better, hiding it in the PMU, by changing
      perf_pmu__config_terms() the PMU rather than the format list in the PMU.
      
      Change the PMU test to pass a dummy PMU for this purpose. Changing the
      test allows perf_pmu__del_formats() to become static.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      804fee5d
    • Ian Rogers's avatar
      perf pmu: Reduce scope of perf_pmu_error() · 6f2f6eaf
      Ian Rogers authored
      Move declaration from header file to pmu.y and make static.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6f2f6eaf
    • Ian Rogers's avatar
      perf pmu: Move perf_pmu__set_format to pmu.y · cc5adb73
      Ian Rogers authored
      Avoid having the function in the C and header file, as it is only used
      locally by pmu.y.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cc5adb73
    • Ian Rogers's avatar
      perf pmu: Avoid a path name copy · e1a3aad3
      Ian Rogers authored
      Rather than read a base path and append into a 2nd path, read the base
      path directly into output buffer and append to that.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e1a3aad3
    • Ian Rogers's avatar
      perf script ibs: Remove unused include · 91e2e9f0
      Ian Rogers authored
      Done to reduce dependencies on pmu-events.h.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      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: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20230823080828.1460376-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      91e2e9f0
    • Kajol Jain's avatar
      perf bench breakpoint: Skip run if no breakpoints available · 9823ae6f
      Kajol Jain authored
      Based on commit 7d54a4ac ("perf test: Skip watchpoint tests if
      no watchpoints available"), hardware breakpoints are not available for
      power9 platform and because of that 'perf bench breakpoint' run fails on
      power9 platform.
      
      Add code to check for the return value of perf_event_open() in the
      breakpoint run and skip the 'perf bench breakpoint' run, if hardware
      breakpoints are not available.
      
      Result on power9 system before patch changes:
      
        [command]# perf bench breakpoint thread
        perf_event_open: No such device
      
      Result on power9 system after patch changes:
      
        [command]# ./perf bench breakpoint thread
        Skipping perf bench breakpoint thread: No hardware support
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Acked-by: default avatarNaveen N Rao <naveen@kernel.org>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230823075103.190565-1-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9823ae6f
  3. 22 Aug, 2023 1 commit
    • Arnaldo Carvalho de Melo's avatar
      perf lzma: Convert some pr_err() to pr_debug() as callers already use pr_debug() · 7a46404b
      Arnaldo Carvalho de Melo authored
      I noticed some error with:
      
        # perf list ex_ret_brn
        lzma: fopen failed on /usr/lib/modules/5.15.14-100.fc34.x86_64/kernel/net/bluetooth/bnep/bnep.ko.xz: 'No such file or directory'
        lzma: fopen failed on /usr/lib/modules/5.16.16-200.fc35.x86_64/kernel/drivers/gpu/drm/drm_kms_helper.ko.xz: 'No such file or directory'
        lzma: fopen failed on /usr/lib/modules/5.18.16-200.fc36.x86_64/kernel/arch/x86/crypto/crct10dif-pclmul.ko.xz: 'No such file or directory'
        lzma: fopen failed on /usr/lib/modules/5.16.16-200.fc35.x86_64/kernel/drivers/i2c/busses/i2c-piix4.ko.xz: 'No such file or directory'
        <BIG SNIP>
      
      Then using 'perf probe' + 'perf trace' to debug 'perf list', it seems
      its some inconsistency in the ~/.debug/ cache where broken build id
      symlinks that ends up making it try to uncompress some kernel modules
      using the lzma routines:
      
         395.309 perf/3594447 probe_perf:lzma_decompress_to_file(__probe_ip: 6118448, input_string: "/usr/lib/modules/5.18.17-200.fc36.x86_64/kernel/drivers/nvme/host/nvme.ko.xz")
                                             lzma_decompress_to_file (/var/home/acme/bin/perf)
                                             filename__decompress (/var/home/acme/bin/perf)
                                             filename__read_build_id (/var/home/acme/bin/perf)
                                             filename__sprintf_build_id (inlined)
                                             build_id_cache__valid_id (inlined)
                                             build_id_cache__list_all (/var/home/acme/bin/perf)
                                             print_sdt_events (/var/home/acme/bin/perf)
                                             cmd_list (/var/home/acme/bin/perf)
                                             run_builtin (/var/home/acme/bin/perf)
                                             handle_internal_command (inlined)
                                             run_argv (inlined)
                                             main (/var/home/acme/bin/perf)
                                             __libc_start_call_main (/usr/lib64/libc.so.6)
                                             __libc_start_main@@GLIBC_2.34 (/usr/lib64/libc.so.6)
                                             _start (/var/home/acme/bin/perf)
      
      But callers of filename__decompress() already check its return and use
      pr_debug(), so be consistent and make functions it calls also use
      pr_debug().
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZOUD0+GkuCVkYF7n@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a46404b
  4. 21 Aug, 2023 8 commits
  5. 18 Aug, 2023 2 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Use heuristic when deciding if a syscall tracepoint "const char *"... · 64917f4d
      Arnaldo Carvalho de Melo authored
      perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string
      
      'perf trace' tries to find BPF progs associated with a syscall that have
      a signature that is similar to syscalls without one to try and reuse,
      so, for instance, the 'open' signature can be reused with many other
      syscalls that have as its first arg a string.
      
      It uses the tracefs events format file for finding a signature that can
      be reused, but then comes the "write" syscall with its second argument
      as a "const char *":
      
        # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_write/format
        name: sys_enter_write
        ID: 746
        format:
        	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
        	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
        	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
        	field:int common_pid;	offset:4;	size:4;	signed:1;
      
        	field:int __syscall_nr;	offset:8;	size:4;	signed:1;
        	field:unsigned int fd;	offset:16;	size:8;	signed:0;
        	field:const char * buf;	offset:24;	size:8;	signed:0;
        	field:size_t count;	offset:32;	size:8;	signed:0;
      
        print fmt: "fd: 0x%08lx, buf: 0x%08lx, count: 0x%08lx", ((unsigned long)(REC->fd)), ((unsigned long)(REC->buf)), ((unsigned long)(REC->count))
        #
      
      Which isn't a string (the man page for glibc has buf as "void *"), so we
      have to use the name of the argument as an heuristic, to consider a
      string just args that are "const char *" and that have in its name  the
      "path", "file", etc substrings.
      
      With that now it reuses:
      
        [root@quaco ~]# perf trace -v --max-events=1 |& grep Reus
        Reusing "open" BPF sys_enter augmenter for "stat"
        Reusing "open" BPF sys_enter augmenter for "lstat"
        Reusing "open" BPF sys_enter augmenter for "access"
        Reusing "connect" BPF sys_enter augmenter for "accept"
        Reusing "sendto" BPF sys_enter augmenter for "recvfrom"
        Reusing "connect" BPF sys_enter augmenter for "bind"
        Reusing "connect" BPF sys_enter augmenter for "getsockname"
        Reusing "connect" BPF sys_enter augmenter for "getpeername"
        Reusing "open" BPF sys_enter augmenter for "execve"
        Reusing "open" BPF sys_enter augmenter for "truncate"
        Reusing "open" BPF sys_enter augmenter for "chdir"
        Reusing "open" BPF sys_enter augmenter for "mkdir"
        Reusing "open" BPF sys_enter augmenter for "rmdir"
        Reusing "open" BPF sys_enter augmenter for "creat"
        Reusing "open" BPF sys_enter augmenter for "link"
        Reusing "open" BPF sys_enter augmenter for "unlink"
        Reusing "open" BPF sys_enter augmenter for "symlink"
        Reusing "open" BPF sys_enter augmenter for "readlink"
        Reusing "open" BPF sys_enter augmenter for "chmod"
        Reusing "open" BPF sys_enter augmenter for "chown"
        Reusing "open" BPF sys_enter augmenter for "lchown"
        Reusing "open" BPF sys_enter augmenter for "mknod"
        Reusing "open" BPF sys_enter augmenter for "statfs"
        Reusing "open" BPF sys_enter augmenter for "pivot_root"
        Reusing "open" BPF sys_enter augmenter for "chroot"
        Reusing "open" BPF sys_enter augmenter for "acct"
        Reusing "open" BPF sys_enter augmenter for "swapon"
        Reusing "open" BPF sys_enter augmenter for "swapoff"
        Reusing "open" BPF sys_enter augmenter for "delete_module"
        Reusing "open" BPF sys_enter augmenter for "setxattr"
        Reusing "open" BPF sys_enter augmenter for "lsetxattr"
        Reusing "openat" BPF sys_enter augmenter for "fsetxattr"
        Reusing "open" BPF sys_enter augmenter for "getxattr"
        Reusing "open" BPF sys_enter augmenter for "lgetxattr"
        Reusing "openat" BPF sys_enter augmenter for "fgetxattr"
        Reusing "open" BPF sys_enter augmenter for "listxattr"
        Reusing "open" BPF sys_enter augmenter for "llistxattr"
        Reusing "open" BPF sys_enter augmenter for "removexattr"
        Reusing "open" BPF sys_enter augmenter for "lremovexattr"
        Reusing "fsetxattr" BPF sys_enter augmenter for "fremovexattr"
        Reusing "open" BPF sys_enter augmenter for "mq_open"
        Reusing "open" BPF sys_enter augmenter for "mq_unlink"
        Reusing "fsetxattr" BPF sys_enter augmenter for "add_key"
        Reusing "fremovexattr" BPF sys_enter augmenter for "request_key"
        Reusing "fremovexattr" BPF sys_enter augmenter for "inotify_add_watch"
        Reusing "fremovexattr" BPF sys_enter augmenter for "mkdirat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "mknodat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "fchownat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "futimesat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "newfstatat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "unlinkat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "linkat"
        Reusing "open" BPF sys_enter augmenter for "symlinkat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "readlinkat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "fchmodat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "faccessat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "utimensat"
        Reusing "connect" BPF sys_enter augmenter for "accept4"
        Reusing "fremovexattr" BPF sys_enter augmenter for "name_to_handle_at"
        Reusing "fremovexattr" BPF sys_enter augmenter for "renameat2"
        Reusing "open" BPF sys_enter augmenter for "memfd_create"
        Reusing "fremovexattr" BPF sys_enter augmenter for "execveat"
        Reusing "fremovexattr" BPF sys_enter augmenter for "statx"
        [root@quaco ~]#
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alan Maguire <alan.maguire@oracle.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZN5lrdeEdSMCn7hk@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      64917f4d
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Use the augmented_raw_syscall BPF skel only for tracing syscalls · 83a0943b
      Arnaldo Carvalho de Melo authored
      It is possible to use 'perf trace' with tracepoints and in that case we
      can't initialize/use the augmented_raw_syscalls BPF skel.
      
      For instance, this usecase:
      
        # perf trace -e sched:*exec --max-events=5
               ? (         ): NetworkManager/1183  ... [continued]: poll())                                             = 1
           0.043 ( 0.007 ms): NetworkManager/1183 epoll_wait(epfd: 17<anon_inode:[eventpoll]>, events: 0x55555f90e920, maxevents: 6) = 0
           0.060 ( 0.007 ms): NetworkManager/1183 write(fd: 3<anon_inode:[eventfd]>, buf: 0x7ffc5a27cd30, count: 8)     = 8
           0.073 ( 0.005 ms): NetworkManager/1183 epoll_wait(epfd: 24<anon_inode:[eventpoll]>, events: 0x7ffc5a27cd20, maxevents: 2) = 1
           0.082 ( 0.010 ms): NetworkManager/1183 recvmmsg(fd: 26<socket:[30298]>, mmsg: 0x7ffc5a27caa0, vlen: 8)       = 1
        #
      
      Where we want to trace just some sched tracepoints ending in 'exec' ends
      up tracing all syscalls.
      
      Fix it by checking existing trace->trace_syscalls boolean to see if we
      need the augmenter.
      
      A followup patch will move those sections of code used only with the
      augmenter to separate functions, to get it cleaner and remove the goto,
      done just for reviewing purposes.
      
      With this patch in place the previous behaviour is restored: no syscalls
      when we have other events and no syscall names:
      
        [root@quaco ~]# perf probe do_filp_open "filename=pathname->name:string"
        Added new event:
          probe:do_filp_open   (on do_filp_open with filename=pathname->name:string)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe:do_filp_open -aR sleep 1
      
        [root@quaco ~]# perf trace --max-events=10 -e probe:do_filp_open sleep 1
           0.000 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/etc/ld.so.cache")
           0.056 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/lib64/libc.so.6")
           0.481 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/locale-archive")
           0.501 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/share/locale/locale.alias")
           0.572 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/en_US.UTF-8/LC_IDENTIFICATION")
           0.581 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/en_US.utf8/LC_IDENTIFICATION")
           0.616 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib64/gconv/gconv-modules.cache")
           0.656 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/en_US.UTF-8/LC_MEASUREMENT")
           0.664 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/en_US.utf8/LC_MEASUREMENT")
           0.696 sleep/455122 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/en_US.UTF-8/LC_TELEPHONE")
        [root@quaco ~]#
      
      As well as mixing syscalls with tracepoints, getting the syscall
      tracepoints used augmented using the BPF skel:
      
        [root@quaco ~]# perf trace --max-events=10 -e open*,probe:do_filp_open sleep 1
           0.000 (         ): sleep/455124 openat(dfd: CWD, filename: "/etc/ld.so.cache", flags: RDONLY|CLOEXEC) ...
           0.005 (         ): sleep/455124 probe:do_filp_open(__probe_ip: -1186560412, filename: "/etc/ld.so.cache")
           0.000 ( 0.011 ms): sleep/455124  ... [continued]: openat())                                           = 3
           0.031 (         ): sleep/455124 openat(dfd: CWD, filename: "/lib64/libc.so.6", flags: RDONLY|CLOEXEC) ...
           0.033 (         ): sleep/455124 probe:do_filp_open(__probe_ip: -1186560412, filename: "/lib64/libc.so.6")
           0.031 ( 0.006 ms): sleep/455124  ... [continued]: openat())                                           = 3
           0.258 (         ): sleep/455124 openat(dfd: CWD, filename: "/usr/lib/locale/locale-archive", flags: RDONLY|CLOEXEC) ...
           0.261 (         ): sleep/455124 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/lib/locale/locale-archive")
           0.258 ( 0.006 ms): sleep/455124  ... [continued]: openat())                                           = -1 ENOENT (No such file or directory)
           0.272 (         ): sleep/455124 openat(dfd: CWD, filename: "/usr/share/locale/locale.alias", flags: RDONLY|CLOEXEC) ...
           0.273  (        ): sleep/455124 probe:do_filp_open(__probe_ip: -1186560412, filename: "/usr/share/locale/locale.alias")
      
      A final note: the probe:do_filp_open uses a kprobe (probably optimized
      as its in the start of a function) that uses the kprobe_tracer mechanism
      in the kernel to collect the pathname->name string and stash it into the
      tracepoint created by 'perf probe' for that:
      
        [root@quaco ~]# cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/do_filp_open _text+4621920 filename=+0(+0(%si)):string
        [root@quaco ~]#
      
      While the syscalls:sys_enter_openat tracepoint gets its string from a
      BPF program attached to raw_syscalls:sys_enter that tail calls into
      another BPF program that knows the types for the openat syscall args and
      thus can bpf_probe_read it right after the normal
      sys_enter/sys_enter_openat tracepoint payload that comes prefixed with
      whatever perf_event_open asked for (CPU, timestamp, etc):
      
        [root@quaco ~]# bpftool prog | grep -E "sys_enter |sys_enter_opena" -A3
        3176: tracepoint  name sys_enter  tag 0bc3fc9d11754ba1  gpl
      	loaded_at 2023-08-17T12:32:20-0300  uid 0
      	xlated 272B  jited 257B  memlock 4096B  map_ids 2462,2466,2463
      	btf_id 2976
        --
        3180: tracepoint  name sys_enter_opena  tag 19dd077f00ec2f58  gpl
      	  loaded_at 2023-08-17T12:32:20-0300  uid 0
      	  xlated 328B  jited 206B  memlock 4096B  map_ids 2466,2465
      	  btf_id 2976
        [root@quaco ~]#
      
      Fixes: 5e6da6be ("perf trace: Migrate BPF augmentation to use a skeleton")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/lkml/ZN4+s2Wl+zYmXTDj@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      83a0943b
  6. 17 Aug, 2023 7 commits
    • Arnaldo Carvalho de Melo's avatar
      perf lock: Don't pass an ERR_PTR() directly to perf_session__delete() · abaf1e03
      Arnaldo Carvalho de Melo authored
      While debugging a segfault on 'perf lock contention' without an
      available perf.data file I noticed that it was basically calling:
      
      	perf_session__delete(ERR_PTR(-1))
      
      Resulting in:
      
        (gdb) run lock contention
        Starting program: /root/bin/perf lock contention
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib64/libthread_db.so.1".
        failed to open perf.data: No such file or directory  (try 'perf record' first)
        Initializing perf session failed
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        2858		if (!session->auxtrace)
        (gdb) p session
        $1 = (struct perf_session *) 0xffffffffffffffff
        (gdb) bt
        #0  0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        #1  0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
        #2  0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
        #3  0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
        #4  0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
        #5  0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
        #6  0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
        #7  0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
        (gdb)
      
      So just set it to NULL after using PTR_ERR(session) to decode the error
      as perf_session__delete(NULL) is supported.
      
      Fixes: eef4fee5 ("perf lock: Dynamically allocate lockhash_table")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Ross Zwisler <zwisler@chromium.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/lkml/ZN4R1AYfsD2J8lRs@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      abaf1e03
    • Arnaldo Carvalho de Melo's avatar
      perf top: Don't pass an ERR_PTR() directly to perf_session__delete() · ef23cb59
      Arnaldo Carvalho de Melo authored
      While debugging a segfault on 'perf lock contention' without an
      available perf.data file I noticed that it was basically calling:
      
      	perf_session__delete(ERR_PTR(-1))
      
      Resulting in:
      
        (gdb) run lock contention
        Starting program: /root/bin/perf lock contention
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib64/libthread_db.so.1".
        failed to open perf.data: No such file or directory  (try 'perf record' first)
        Initializing perf session failed
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        2858		if (!session->auxtrace)
        (gdb) p session
        $1 = (struct perf_session *) 0xffffffffffffffff
        (gdb) bt
        #0  0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        #1  0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
        #2  0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
        #3  0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
        #4  0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
        #5  0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
        #6  0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
        #7  0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
        (gdb)
      
      So just set it to NULL after using PTR_ERR(session) to decode the error
      as perf_session__delete(NULL) is supported.
      
      The same problem was found in 'perf top' after an audit of all
      perf_session__new() failure handling.
      
      Fixes: 6ef81c55 ("perf session: Return error code for perf_session__new() function on failure")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Cc: Mukesh Ojha <mojha@codeaurora.org>
      Cc: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Shawn Landden <shawn@git.icu>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
      Link: https://lore.kernel.org/lkml/ZN4Q2rxxsL08A8rd@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ef23cb59
    • James Clark's avatar
      perf vendor events arm64: Update N2 and V2 metrics and events using Arm telemetry repo · 44739490
      James Clark authored
      Apart from some slight naming and grouping differences, the new metrics
      are functionally the same as the existing ones. Any missing metrics were
      manually appended to the end of the auto generated file.
      
      For the events, the new data includes descriptions that may have product
      specific details and new groupings that will be consistent with other
      products.
      
      After generating the metrics from the telemetry repo [1], the following
      manual steps were performed:
      
       * Change the topdown expressions to compare on CPUID and use
         #slots so that the same data can be shared between N2 and V2. Apart
         from these modifications, the expressions now match more closely with
         the Arm telemetry data which will hopefully make future updates
         easier.
      
       * Append some metrics from the old N2/V2 data that aren't present in
         the telemetry data. These will possibly be added to the
         telemetry-solution repo at a later time:
      
          l3d_cache_mpki, l3d_cache_miss_rate, branch_pki, ipc_rate, spec_ipc,
          retired_rate, wasted_rate, branch_immed_spec_rate,
          branch_return_spec_rate, branch_indirect_spec_rate
      
      [1]: https://gitlab.arm.com/telemetry-solution/telemetry-solution/-/blob/main/data/pmu/cpu/neoverse/neoverse-n2.jsonSigned-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-7-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      44739490
    • James Clark's avatar
      perf vendor events arm64: Update stall_slot workaround for N2 r0p3 · d43f5491
      James Clark authored
      N2 r0p3 doesn't require the workaround [1], so gating on (#slots - 5) no
      longer works because all N2s have 5 slots. Use the new expression
      builtin that allows calling strcmp_cpuid_str() and comparing CPUIDs in
      metric formulas.
      
      In this case, the commented formula looks like this:
      
        strcmp_cpuid_str(0x410fd493)        # greater than or equal to N2 r0p3
        | strcmp_cpuid_str(0x410fd490) ^ 1  # OR NOT any version of N2
      
      [1]: https://gitlab.arm.com/telemetry-solution/telemetry-solution/-/blob/main/data/pmu/cpu/neoverse/neoverse-n2-r0p3.jsonSigned-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d43f5491
    • James Clark's avatar
      perf jevents: Add a new expression builtin strcmp_cpuid_str() · 9d5da30e
      James Clark authored
      This will allow writing formulas that are conditional on a specific
      CPU type or CPU version. It calls through to the existing
      strcmp_cpuid_str() function in Perf which has a default weak version,
      and an arch specific version for x86 and arm64.
      
      The function takes an 'ID' type value, which is a string. But in this
      case Arm CPU IDs are hex numbers prefixed with '0x'. metric.py
      assumes strings are only used by event names, and that they can't start
      with a number ('0'), so an additional change has to be made to the
      regex to convert hex numbers back to 'ID' types.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d5da30e
    • James Clark's avatar
      perf test: Add a test for the new Arm CPU ID comparison behavior · 81f7da54
      James Clark authored
      Now that variant and revision fields are taken into account the behavior
      is slightly more complicated so add a test to ensure that this behaves
      as expected.
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-3-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      81f7da54
    • James Clark's avatar
      perf arm64: Allow version comparisons of CPU IDs · c3e1e8cf
      James Clark authored
      Currently variant and revision fields are masked out of the MIDR so
      it's not possible to compare different versions of the same CPU.
      In a later commit a workaround will be removed just for N2 r0p3, so
      enable comparisons on version.
      
      This has the side effect of changing the MIDR stored in the header of
      the perf.data file to no longer have masked version fields. It also
      affects the lookups in mapfile.csv, but as that currently only has
      zeroed version fields, it has no actual effect. The mapfile.csv
      documentation also states to zero the version fields, so unless this
      isn't done it will continue to have no effect.
      
      There is an existing weak default strcmp_cpuid_str() function, and an
      x86 version. This adds another version for arm64.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3e1e8cf