1. 27 May, 2023 17 commits
    • Ian Rogers's avatar
      perf tools: Warn if no user requested CPUs match PMU's CPUs · 5ac72634
      Ian Rogers authored
      In commit 1d3351e6 ("perf tools: Enable on a list of CPUs for hybrid")
      perf on hybrid will warn if a user requested CPU doesn't match the PMU
      of the given event but only for hybrid PMUs. Make the logic generic
      for all PMUs and remove the hybrid logic.
      
      Warn if a CPU is requested that isn't present/offline for events not
      on the core. Warn if a CPU is requested for a core PMU, but the CPU
      isn't within the cpu map of that PMU.
      
      For example on a 16 (0-15) CPU system:
      ```
      $ perf stat -e imc_free_running/data_read/,cycles -C 16 true
      WARNING: A requested CPU in '16' is not supported by PMU 'uncore_imc_free_running_1' (CPUs 0-15) for event 'imc_free_running/data_read/'
      WARNING: A requested CPU in '16' is not supported by PMU 'uncore_imc_free_running_0' (CPUs 0-15) for event 'imc_free_running/data_read/'
      WARNING: A requested CPU in '16' is not supported by PMU 'cpu' (CPUs 0-15) for event 'cycles'
      
       Performance counter stats for 'CPU(s) 16':
      
         <not supported> MiB  imc_free_running/data_read/
         <not supported>      cycles
      
             0.000575312 seconds time elapsed
      ```
      
      Remove evlist__fix_hybrid_cpus that previously produced the warnings
      and also perf_pmu__cpus_match that worked with evlist__fix_hybrid_cpus
      to change CPU maps for hybrid CPUs, something that is no longer
      necessary as CPU map propagation properly intersects user requested
      CPUs with the core PMU's CPU map.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-12-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ac72634
    • Ian Rogers's avatar
      perf target: Remove unused hybrid value · 8ec984d5
      Ian Rogers authored
      Previously this was used to modify CPU map propagation, but it is now
      unnecessary as map propagation ensure core PMUs only have valid PMUs
      in the CPU map from user requested CPUs.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-11-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8ec984d5
    • Ian Rogers's avatar
      perf evlist: Allow has_user_cpus to be set on hybrid · 42249160
      Ian Rogers authored
      Now that CPU map propagation only sets valid CPUs for core PMUs, there
      is no reason to disable "has_user_cpus" for hybrid.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42249160
    • Ian Rogers's avatar
      perf evlist: Propagate user CPU maps intersecting core PMU maps · ef91871c
      Ian Rogers authored
      The CPU map for a non-core PMU gives a default CPU value for
      perf_event_open. For core PMUs the CPU map lists all CPUs the evsel
      may be opened on. If there are >1 core PMU, the CPU maps will list the
      CPUs for that core PMU, but the user_requested_cpus may contain CPUs
      that are invalid for the PMU and cause perf_event_open to fail. To
      avoid this, when propagating the CPU map for core PMUs intersect it
      with the CPU map of the PMU (the evsel's "own_cpus").
      
      Add comments to __perf_evlist__propagate_maps to explain its somewhat
      complex behavior. Fix the related comments for system_wide in struct
      perf_evsel.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-9-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ef91871c
    • Ian Rogers's avatar
      perf pmu: Add CPU map for "cpu" PMUs · a0c41cae
      Ian Rogers authored
      A typical "cpu" PMU has no "cpus" or "cpumask" file meaning the CPU
      map is set to NULL, which also encodes an empty CPU map. Update
      pmu_cpumask so that if the "cpu" PMU fails to load a CPU map, use a
      default of all online PMUs.
      
      Remove const from cpu_map__online for the sake of reference counting.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-8-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a0c41cae
    • Ian Rogers's avatar
      perf evsel: Add is_pmu_core inorder to interpret own_cpus · 1578e63d
      Ian Rogers authored
      The behaviour of handling cpu maps varies for core and other PMUs. For
      core PMUs the cpu map lists all valid CPUs, whereas for other PMUs the
      map is the default CPU. Add a flag in the evsel to indicate if a PMU
      is core to help with later interpreting of the cpu maps and populate
      it when the evsel is created during parsing. When propagating cpu
      maps, core PMUs should intersect the cpu map of the PMU with the user
      requested one.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-7-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1578e63d
    • Ian Rogers's avatar
      perf pmu: Add is_core to pmu · e20d1f2f
      Ian Rogers authored
      Cache is_pmu_core in the pmu to avoid recomputation.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e20d1f2f
    • Ian Rogers's avatar
      perf pmu: Detect ARM and hybrid PMUs with sysfs · 4bf7e81a
      Ian Rogers authored
      is_arm_pmu_core detects a core PMU via the presence of a "cpus" file
      rather than a "cpumask" file. This pattern holds for hybrid PMUs so
      rename the function and remove redundant perf_pmu__is_hybrid
      tests.
      
      Add a new helper is_pmu_hybrid similar to is_pmu_core.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4bf7e81a
    • Ian Rogers's avatar
      libperf cpumap: Add "any CPU"/dummy test function · 916ce34a
      Ian Rogers authored
      It is common in the code currently to test a map for "empty" when in
      fact the "any CPU"/dummy value of -1 is being sought. Add a new
      function to enable this and document the behavior of two other
      functions.
      
      The term "any CPU" comes from perf_event_open, where the value is
      consumed, but it is more typical in the code to see this value/map
      referred to as the dummy value. This could be misleading due to the
      dummy event and also dummy not being intention revealing, so it is hoped
      to migrate the code to referring to this as "any CPU".
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      916ce34a
    • Ian Rogers's avatar
      perf cpumap: Add equal function · 74c075ca
      Ian Rogers authored
      Equality is a useful property to compare after merging and
      intersecting maps.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      74c075ca
    • Ian Rogers's avatar
      perf cpumap: Add internal nr and cpu accessors · 7d1b529f
      Ian Rogers authored
      These accessors assume the map is non-null. Rewrite functions to use
      rather than direct accesses. This also fixes a build regression for
      REFCNT_CHECKING in the intersect function.
      Suggested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230527072210.2900565-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7d1b529f
    • Ian Rogers's avatar
      perf test python: Put perf python at start of sys.path · caa90a7b
      Ian Rogers authored
      This avoids picking up a system installed version of the perf python module.
      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: 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/20230527055517.2711487-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      caa90a7b
    • Namhyung Kim's avatar
      perf test: Fix perf stat JSON output test · 540c910c
      Namhyung Kim authored
      The recent --per-cache option test caused a problem.  According to the
      option name, I think it should check args.per_cache instead of
      args.per_cache_instance.
      
        $ sudo ./perf test -v 99
         99: perf stat JSON output linter                                    :
        --- start ---
        test child forked, pid 3086101
        Checking json output: no args [Success]
        Checking json output: system wide [Success]
        Checking json output: interval [Success]
        Checking json output: event [Success]
        Checking json output: per thread [Success]
        Checking json output: per node [Success]
        Checking json output: system wide no aggregation [Success]
        Checking json output: per core [Success]
        Checking json output: per cache_instance Test failed for input:
        ...
        Traceback (most recent call last):
          File "linux/tools/perf/tests/shell/lib/perf_json_output_lint.py", line 88, in <module>
            elif args.per_core or args.per_socket or args.per_node or args.per_die or args.per_cache_instance:
        AttributeError: 'Namespace' object has no attribute 'per_cache_instance'
        test child finished with -1
        ---- end ----
        perf stat JSON output linter: FAILED!
      
      Fixes: bfce728d ("pert tests: Add tests for new "perf stat --per-cache" aggregation option")
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarK Prateek Nayak <kprateek.nayak@amd.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230524210600.3095830-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      540c910c
    • Ian Rogers's avatar
      perf tests: Organize cpu_map tests into a single suite · 5cebb33f
      Ian Rogers authored
      Go from 4 suites to a single suite with 4 test cases.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230526215410.2435674-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5cebb33f
    • Ian Rogers's avatar
      perf cpumap: Add intersect function · 237d41d4
      Ian Rogers authored
      The merge function gives the union of two cpu maps. Add an intersect
      function which is necessary, for example, when intersecting a PMUs
      supported CPUs with user requested.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ali Saidi <alisaidi@amazon.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      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: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230526215410.2435674-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      237d41d4
    • Ian Rogers's avatar
      perf vendor events intel: Add metricgroup descriptions for all models · 6ac2230b
      Ian Rogers authored
      Add metric group descriptions created by:
      https://github.com/intel/perfmon/blob/main/scripts/create_perf_json.py
      The descriptions add some additional detail in perf list.
      
      Committer notes:
      
      Removed unrelated changes to tools/perf/pmu-events/arch/x86/mapfile.csv
      that removed AMD mappings and ended up breaking the build with things
      like:
      
          CC      /tmp/build/perf-tools-next/pmu-events/pmu-events.o
        /tmp/build/perf-tools-next/pmu-events/pmu-events.c:23808:39: error: ‘pmu_metrics__amdzen4’ defined but not used [-Werror=unused-const-variable=]
        23808 | static const struct compact_pmu_event pmu_metrics__amdzen4[] = {
              |                                       ^~~~~~~~~~~~~~~~~~~~
        /tmp/build/perf-tools-next/pmu-events/pmu-events.c:23316:39: error: ‘pmu_events__amdzen4’ defined but not used [-Werror=unused-const-variable=]
        23316 | static const struct compact_pmu_event pmu_events__amdzen4[] = {
              |                                       ^~~~~~~~~~~~~~~~~~~
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230517173805.602113-16-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6ac2230b
    • Ian Rogers's avatar
      perf jevents: Add support for metricgroup descriptions · 66c6e0c1
      Ian Rogers authored
      Metrics have a field where the groups they belong to are listed like
      the following from
      tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json:
      
              "MetricGroup": "PGO;TmaL1;TopdownL1;tma_L1_group",
              "MetricName": "tma_frontend_bound",
      
      The metric groups are shown in 'perf list' like the following where
      TopdownL1 is a metric group:
      
      TopdownL1:
        tma_backend_bound
             [This category represents fraction of slots where no uops are being
              delivered due to a lack of required resources for accepting new uops
              in the Backend]
        tma_bad_speculation
             [This category represents fraction of slots wasted due to incorrect
              speculations]
        tma_frontend_bound
             [This category represents fraction of slots where the processor's
              Frontend undersupplies its Backend]
        tma_retiring
             [This category represents fraction of slots utilized by useful work
              i.e. issued uops that eventually get retired]
      
      This patch adds support for a new json file in each model directory
      called metricgroups.json that comprises a dictionary containing
      entries that map from a metric group to a description:
      
      {
      ...
          "TopdownL1": "Metrics for top-down breakdown at level 1",
      ...
      }
      
      perf list is then updated to support this changing the above output
      to:
      
        TopdownL1: [Metrics for top-down breakdown at level 1]
      
      Committer notes:
      
      Added a (int) cast to the ARRAY_SIZE() introduced in this patch to
      address:
      
        /tmp/build/perf-tools-next/pmu-events/pmu-events.c: In function ‘describe_metricgroup’:
        /var/home/acme/git/perf-tools-next/tools/include/linux/kernel.h:102:25: error: overflow in conversion from ‘long unsigned int’ to ‘int’ changes value from ‘18446744073709551615’ to ‘-1’ [-Werror=overflow]
          102 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
              |                         ^
        /tmp/build/perf-tools-next/pmu-events/pmu-events.c:61603:29: note: in expansion of macro ‘ARRAY_SIZE’
        61603 |         int low = 0, high = ARRAY_SIZE(metricgroups) - 1;
              |                             ^~~~~~~~~~
        cc1: all warnings being treated as errors
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230517173805.602113-15-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      66c6e0c1
  2. 23 May, 2023 18 commits
  3. 22 May, 2023 2 commits
    • Anup Sharma's avatar
      perf test: Add test validating JSON generated by 'perf data convert --to-json' · 68d12418
      Anup Sharma authored
      This commit adds support for testing the JSON output generated by the
      'perf data' command's conversion to JSON functionality.
      
      The test script now includes a step to ensure that the resulting JSON
      file contains valid data.
      
      Changes:
      V1 -> V2:
      
      Added a check for the existence of the result output file.
      Replaced the usage of jq with json.load for validating the JSON format.
      Checks using ShellCheck and checkpatch, addressing and resolving warnings.
      Removed the unnecessary root permission check.
      Modified the 'perf record' command to avoid requiring root permissions.
      
      Committer testing:
      
        $ perf test to-json
        115: 'perf data convert --to-json' command test                      : Ok
        $ perf test -v to-json
        Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
        115: 'perf data convert --to-json' command test                      :
        --- start ---
        test child forked, pid 1746867
        Testing Perf Data Convertion Command to JSON
        Perf Data Converter Command to JSON [SUCCESS]
        Validating Perf Data Converted JSON file
        The file contains valid JSON format [SUCCESS]
        test child finished with 0
        ---- end ----
        'perf data convert --to-json' command test: Ok
        $
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Link: https://lore.kernel.org/r/ZGcoJBAGlknjsA/n@yogaTested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Anup Sharma <anupnewsmail@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      [ Fixup indentation to use consistently tabs, not a mixture of spaces and tabs, have 'if ... ; then'  on the same line ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      68d12418
    • Arnaldo Carvalho de Melo's avatar
      Merge remote-tracking branch 'acme/perf-tools' into perf-tools-next · 7cdda699
      Arnaldo Carvalho de Melo authored
      To pick up fixes that were already merged upstream.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7cdda699
  4. 19 May, 2023 3 commits