aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/pmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/pmu.c')
-rw-r--r--tools/perf/util/pmu.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index ddb0261b2577..2babcdf62839 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -445,14 +445,23 @@ static struct cpu_map *pmu_cpumask(const char *name)
445 FILE *file; 445 FILE *file;
446 struct cpu_map *cpus; 446 struct cpu_map *cpus;
447 const char *sysfs = sysfs__mountpoint(); 447 const char *sysfs = sysfs__mountpoint();
448 const char *templates[] = {
449 "%s/bus/event_source/devices/%s/cpumask",
450 "%s/bus/event_source/devices/%s/cpus",
451 NULL
452 };
453 const char **template;
448 454
449 if (!sysfs) 455 if (!sysfs)
450 return NULL; 456 return NULL;
451 457
452 snprintf(path, PATH_MAX, 458 for (template = templates; *template; template++) {
453 "%s/bus/event_source/devices/%s/cpumask", sysfs, name); 459 snprintf(path, PATH_MAX, *template, sysfs, name);
460 if (stat(path, &st) == 0)
461 break;
462 }
454 463
455 if (stat(path, &st) < 0) 464 if (!*template)
456 return NULL; 465 return NULL;
457 466
458 file = fopen(path, "r"); 467 file = fopen(path, "r");