1. 25 Aug, 2023 2 commits
    • Ian Rogers's avatar
      perf pmu: Remove logic for PMU name being NULL · c091ee90
      Ian Rogers authored
      The PMU name could be NULL in the case of the fake_pmu. Initialize the
      name for the fake_pmu to "fake" so that all other logic can assume it
      is initialized. Add a const to the type of name so that a literal can
      be used to avoid additional initialization code. Propagate the cost
      through related routines and remove now unnecessary "(char *)"
      casts. Doing this located a bug in builtin-list for the pmu_glob that
      was missing a strdup.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Link: https://lore.kernel.org/r/20230825024002.801955-3-irogers@google.com
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Wei Li <liwei391@huawei.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c091ee90
    • Ian Rogers's avatar
      perf header: Fix missing PMU caps · 9897009e
      Ian Rogers authored
      PMU caps are written as HEADER_PMU_CAPS or for the special case of the
      PMU "cpu" as HEADER_CPU_PMU_CAPS. As the PMU "cpu" is special, and not
      any "core" PMU, the logic had become broken and core PMUs not called
      "cpu" were not having their caps written.
      
      This affects ARM and s390 non-hybrid PMUs.
      
      Simplify the PMU caps writing logic to scan one fewer time and to be
      more explicit in its behavior.
      
      Fixes: 178ddf3b ("perf header: Avoid hybrid PMU list in write_pmu_caps")
      Reported-by: default avatarWei Li <liwei391@huawei.com>
      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: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      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: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230825024002.801955-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9897009e
  2. 24 Aug, 2023 20 commits
    • Ian Rogers's avatar
      perf jevents: Don't append Unit to desc · eeb6b129
      Ian Rogers authored
      Unit with the PMU name is appended to desc in jevents.py, but on
      hybrid platforms it causes the desc to differ from the regular
      non-hybrid system with a PMU of 'cpu'. Having differing descs means
      the events don't deduplicate. To make the perf list output not differ,
      append the Unit on again in the perf list printing code.
      
      On x86 reduces the binary size by 409,600 bytes or about 4%. Update
      pmu-events test expectations to match the differently generated
      pmu-events.c code.
      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/20230824183212.374787-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eeb6b129
    • Anup Sharma's avatar
      perf scripts python gecko: Launch the profiler UI on the default browser with the appropriate URL · f208b2c6
      Anup Sharma authored
      All required libraries have been imported and make sure that none of
      them are external dependencies. To achieve this, created a virt env and
      verified.
      
      Modified usage information and added combined command.
      
      Modified the main() function to read the --save-only command-line option
      and set the output_file variable accordingly.
      
      Modified the trace_end() function to check for the output_file variable.
      If it is set, the profiler data is saved to a local file in Gecko
      Profile format, or the profiler.firefox.com is opened on the default
      browser.
      
      Included trace_begin() to initialize the Firefox Profiler and launch the
      default browser to display the profiler.firefox.com.
      
      Added a new function launchFirefox() to start a local server and launch
      the profiler UI on the default browser with the appropriate URL.
      
      Created the "CORSRequestHandler" class to enable Cross-Origin Resource
      Sharing.
      
      Summary:
      
      This integration now includes a exiting feature to conveniently host the
      Gecko Profile data on a local server and open it directly in the default
      web browser.
      
      This means that users can now effortlessly visualize and analyze the
      profiler results with just a single click.
      
      The addition of the --save-only command-line option allows users to save
      the profiler output to a local file in Gecko Profile format, but the
      real highlight lies in the capability to seamlessly launch a local
      server, making the data accessible to Firefox Profiler via a web
      browser.
      
      In addition, it's important to highlight that all data are hosted
      locally, eliminating any concerns about data privacy rules and
      regulations.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Tested-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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>
      Link: https://lore.kernel.org/r/ZNOS0vo58DnVLpD8@yogaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f208b2c6
    • Anup Sharma's avatar
      perf scripts python: Add support for input args in gecko script · 43803cb1
      Anup Sharma authored
      Refines the argument handling mechanism in the "gecko-report" script to
      enable better compatibility and improved user experience.
      
      The script now differentiates between scenarios where arguments are
      provided for record and report cases where gecko.py arguments are
      passed.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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>
      Link: https://lore.kernel.org/r/ZNf7W+EIrrCSHZN0@yogaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      43803cb1
    • Ian Rogers's avatar
      perf jevents: Sort strings in the big C string to reduce faults · f85d120c
      Ian Rogers authored
      Sort the strings within the big C string based on whether they were
      for a metric and then by when they were added. This helps group
      related strings and reduce minor faults by approximately 10 in 1740,
      about 0.57%.
      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-18-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f85d120c
    • Ian Rogers's avatar
      perf pmu: Lazily load sysfs aliases · 8d4b6d37
      Ian Rogers authored
      Don't load sysfs aliases for a PMU when the PMU is first created, defer
      until an alias needs to be found. For the pmu-scan benchmark, average
      core PMU scanning is reduced by 30.8%, and average PMU scanning by
      12.6%.
      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-17-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d4b6d37
    • Ian Rogers's avatar
      perf pmu: Be lazy about loading event info files from sysfs · 7b723dbb
      Ian Rogers authored
      Event info is only needed when an event is parsed or when merging data
      from an JSON and sysfs event. Be lazy in its loading to reduce file
      accesses.
      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-16-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7b723dbb
    • Ian Rogers's avatar
      perf pmu: Scan type early to fail an invalid PMU quickly · 88ed9184
      Ian Rogers authored
      Scan sysfs PMU's type early so that format and aliases aren't
      attempted to be loaded if the PMU name is invalid.
      
      This is the case for event_pmu tokens in parse-events.y where a wildcard
      name is first assumed to be a PMU name.
      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-15-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      88ed9184
    • Ian Rogers's avatar
      perf pmu: Lazily add JSON events · e6ff1eed
      Ian Rogers authored
      Rather than scanning all JSON events and adding them when a PMU is
      created, add the alias when the JSON event is needed.
      
      Average core PMU scanning run time reduced by 60.2%. Average PMU
      scanning run time reduced by 15%. Page faults with no events reduced by
      74 page faults, 4% of total.
      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-14-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e6ff1eed
    • 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
  3. 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
  4. 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
  5. 21 Aug, 2023 7 commits