if (!pm->metric_expr || !pm->compat)
return 0;
- while ((pmu = perf_pmus__scan(pmu))) {
-
- if (!pmu->id || !pmu_uncore_identifier_match(pm->compat, pmu->id))
- continue;
-
- return d->fn(pm, table, d->data);
- }
- return 0;
+ /* Only process with the iterator if there is a a PMU that matches the ID. */
+ pmu = perf_pmus__scan_for_uncore_id(pmu, pm->compat);
+ return pmu ? d->fn(pm, table, d->data) : 0;
}
int metricgroup__for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
if (!pmu) {
/*
* Core PMUs, other sysfs PMUs and tool PMU can have any name or
- * aren't wother optimizing for.
+ * aren't worth optimizing for.
*/
unsigned int to_read_pmus = PERF_TOOL_PMU_TYPE_PE_CORE_MASK |
PERF_TOOL_PMU_TYPE_PE_OTHER_MASK |
return NULL;
}
+struct perf_pmu *perf_pmus__scan_for_uncore_id(struct perf_pmu *pmu, const char *compat)
+{
+ if (!pmu) {
+ /* Only uncore PMUs can have identifiers. */
+ unsigned int to_read_pmus = PERF_TOOL_PMU_TYPE_PE_OTHER_MASK;
+
+ pmu_read_sysfs(to_read_pmus);
+ pmu = list_prepare_entry(pmu, &other_pmus, list);
+ }
+ list_for_each_entry_continue(pmu, &other_pmus, list) {
+ if (pmu->id && pmu_uncore_identifier_match(compat, pmu->id))
+ return pmu;
+ }
+ return NULL;
+}
+
const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str)
{
struct perf_pmu *pmu = NULL;
struct perf_pmu *perf_pmus__scan_core(struct perf_pmu *pmu);
struct perf_pmu *perf_pmus__scan_for_event(struct perf_pmu *pmu, const char *event);
struct perf_pmu *perf_pmus__scan_matching_wildcard(struct perf_pmu *pmu, const char *wildcard);
+struct perf_pmu *perf_pmus__scan_for_uncore_id(struct perf_pmu *pmu, const char *compat);
const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str);