Skip to content

Commit 1dd5f78

Browse files
captain5050acmel
authored andcommitted
perf pmus: Ensure all PMUs are read for find_by_type
perf_pmus__find_by_type may be called for something like a raw event, in which case the PMU isn't guaranteed to have been looked up. Add a second check to make sure all PMUs are loaded. Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Ian 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-32-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 8e7d8a2 commit 1dd5f78

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/perf/util/pmus.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,34 @@ static void pmu_read_sysfs(bool core_only)
142142
}
143143
}
144144

145-
struct perf_pmu *perf_pmus__find_by_type(unsigned int type)
145+
static struct perf_pmu *__perf_pmus__find_by_type(unsigned int type)
146146
{
147147
struct perf_pmu *pmu;
148148

149149
list_for_each_entry(pmu, &core_pmus, list) {
150150
if (pmu->type == type)
151151
return pmu;
152152
}
153+
153154
list_for_each_entry(pmu, &other_pmus, list) {
154155
if (pmu->type == type)
155156
return pmu;
156157
}
157158
return NULL;
158159
}
159160

161+
struct perf_pmu *perf_pmus__find_by_type(unsigned int type)
162+
{
163+
struct perf_pmu *pmu = __perf_pmus__find_by_type(type);
164+
165+
if (pmu || read_sysfs_all_pmus)
166+
return pmu;
167+
168+
pmu_read_sysfs(/*core_only=*/false);
169+
pmu = __perf_pmus__find_by_type(type);
170+
return pmu;
171+
}
172+
160173
/*
161174
* pmu iterator: If pmu is NULL, we start at the begin, otherwise return the
162175
* next pmu. Returns NULL on end.

0 commit comments

Comments
 (0)