1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/list.h>
3 #include <linux/compiler.h>
4 #include <linux/string.h>
5 #include <linux/zalloc.h>
15 #include <api/fs/fs.h>
17 #include "pmu-hybrid.h"
19 LIST_HEAD(perf_pmu__hybrid_pmus);
21 bool perf_pmu__hybrid_mounted(const char *name)
28 if (strncmp(name, "cpu_", 4))
31 sysfs = sysfs__mountpoint();
35 snprintf(path, PATH_MAX, CPUS_TEMPLATE_CPU, sysfs, name);
36 if (!file_available(path))
39 file = fopen(path, "r");
43 n = fscanf(file, "%u", &cpu);
51 struct perf_pmu *perf_pmu__find_hybrid_pmu(const char *name)
58 perf_pmu__for_each_hybrid_pmu(pmu) {
59 if (!strcmp(name, pmu->name))
66 bool perf_pmu__is_hybrid(const char *name)
68 return perf_pmu__find_hybrid_pmu(name) != NULL;
71 char *perf_pmu__hybrid_type_to_pmu(const char *type)
73 char *pmu_name = NULL;
75 if (asprintf(&pmu_name, "cpu_%s", type) < 0)
78 if (perf_pmu__is_hybrid(pmu_name))
82 * pmu may be not scanned, check the sysfs.
84 if (perf_pmu__hybrid_mounted(pmu_name))