diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2012-09-10 03:53:50 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-17 12:12:02 -0400 |
commit | 7ae92e744e3fb389afb1e24920ecda331d360c61 (patch) | |
tree | 46c5d4616a003011a1237ed8d31592a662cf9720 /tools/perf/util/pmu.c | |
parent | 314d9f63f385096580e9e2a06eaa0745d92fe4ac (diff) |
perf stat: Check PMU cpumask file
If user doesn't explicitly specify CPU list, perf-stat only collects
events on CPUs listed in the PMU cpumask file.
Signed-off-by: "Yah, Zheng" <zheng.z.yan@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1347263631-23175-3-git-send-email-zheng.z.yan@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/pmu.c')
-rw-r--r-- | tools/perf/util/pmu.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 6631d828db3d..8a2229da594f 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "util.h" | 9 | #include "util.h" |
10 | #include "pmu.h" | 10 | #include "pmu.h" |
11 | #include "parse-events.h" | 11 | #include "parse-events.h" |
12 | #include "cpumap.h" | ||
12 | 13 | ||
13 | #define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" | 14 | #define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" |
14 | 15 | ||
@@ -253,6 +254,33 @@ static void pmu_read_sysfs(void) | |||
253 | closedir(dir); | 254 | closedir(dir); |
254 | } | 255 | } |
255 | 256 | ||
257 | static struct cpu_map *pmu_cpumask(char *name) | ||
258 | { | ||
259 | struct stat st; | ||
260 | char path[PATH_MAX]; | ||
261 | const char *sysfs; | ||
262 | FILE *file; | ||
263 | struct cpu_map *cpus; | ||
264 | |||
265 | sysfs = sysfs_find_mountpoint(); | ||
266 | if (!sysfs) | ||
267 | return NULL; | ||
268 | |||
269 | snprintf(path, PATH_MAX, | ||
270 | "%s/bus/event_source/devices/%s/cpumask", sysfs, name); | ||
271 | |||
272 | if (stat(path, &st) < 0) | ||
273 | return NULL; | ||
274 | |||
275 | file = fopen(path, "r"); | ||
276 | if (!file) | ||
277 | return NULL; | ||
278 | |||
279 | cpus = cpu_map__read(file); | ||
280 | fclose(file); | ||
281 | return cpus; | ||
282 | } | ||
283 | |||
256 | static struct perf_pmu *pmu_lookup(char *name) | 284 | static struct perf_pmu *pmu_lookup(char *name) |
257 | { | 285 | { |
258 | struct perf_pmu *pmu; | 286 | struct perf_pmu *pmu; |
@@ -275,6 +303,8 @@ static struct perf_pmu *pmu_lookup(char *name) | |||
275 | if (!pmu) | 303 | if (!pmu) |
276 | return NULL; | 304 | return NULL; |
277 | 305 | ||
306 | pmu->cpus = pmu_cpumask(name); | ||
307 | |||
278 | pmu_aliases(name, &aliases); | 308 | pmu_aliases(name, &aliases); |
279 | 309 | ||
280 | INIT_LIST_HEAD(&pmu->format); | 310 | INIT_LIST_HEAD(&pmu->format); |