xref: /openbmc/linux/tools/perf/util/pmus.c (revision 1b8012b2)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/list.h>
3 #include <string.h>
4 #include "pmus.h"
5 #include "pmu.h"
6 
7 LIST_HEAD(pmus);
8 
9 const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str)
10 {
11 	struct perf_pmu *pmu = NULL;
12 
13 	while ((pmu = perf_pmu__scan(pmu)) != NULL) {
14 		if (!strcmp(pmu->name, str))
15 			return pmu;
16 		/* Ignore "uncore_" prefix. */
17 		if (!strncmp(pmu->name, "uncore_", 7)) {
18 			if (!strcmp(pmu->name + 7, str))
19 				return pmu;
20 		}
21 		/* Ignore "cpu_" prefix on Intel hybrid PMUs. */
22 		if (!strncmp(pmu->name, "cpu_", 4)) {
23 			if (!strcmp(pmu->name + 4, str))
24 				return pmu;
25 		}
26 	}
27 	return NULL;
28 }
29