summaryrefslogtreecommitdiff
path: root/tools/perf/util/pmu-hybrid.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/pmu-hybrid.c')
-rw-r--r--tools/perf/util/pmu-hybrid.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/tools/perf/util/pmu-hybrid.c b/tools/perf/util/pmu-hybrid.c
index f51ccaac60ee..38628805a952 100644
--- a/tools/perf/util/pmu-hybrid.c
+++ b/tools/perf/util/pmu-hybrid.c
@@ -20,32 +20,15 @@ LIST_HEAD(perf_pmu__hybrid_pmus);
bool perf_pmu__hybrid_mounted(const char *name)
{
- char path[PATH_MAX];
- const char *sysfs;
- FILE *file;
- int n, cpu;
+ int cpu;
+ char pmu_name[PATH_MAX];
+ struct perf_pmu pmu = {.name = pmu_name};
if (strncmp(name, "cpu_", 4))
return false;
- sysfs = sysfs__mountpoint();
- if (!sysfs)
- return false;
-
- snprintf(path, PATH_MAX, CPUS_TEMPLATE_CPU, sysfs, name);
- if (!file_available(path))
- return false;
-
- file = fopen(path, "r");
- if (!file)
- return false;
-
- n = fscanf(file, "%u", &cpu);
- fclose(file);
- if (n <= 0)
- return false;
-
- return true;
+ strlcpy(pmu_name, name, sizeof(pmu_name));
+ return perf_pmu__scan_file(&pmu, "cpus", "%u", &cpu) > 0;
}
struct perf_pmu *perf_pmu__find_hybrid_pmu(const char *name)