summaryrefslogtreecommitdiff
path: root/lib/igt_perf.c
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-21 10:29:57 +0000
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-02-22 05:50:47 +0000
commitaf65798b6674e28816bd13c096963c2d7fcdd856 (patch)
tree188e596c56bf2bdededee7a59c599f3e95df6c60 /lib/igt_perf.c
parent44cc1249457f916295c47ef3a8ce03716692a203 (diff)
lib/igt_perf: Find active perf CPU
Instead of assuming PMU runs on CPU0, try all possible CPUs if that is not the case. This makes the callers handle fallout from broken tests better, as well as sysadmin interventions where callers are not tests. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_perf.c')
-rw-r--r--lib/igt_perf.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/igt_perf.c b/lib/igt_perf.c
index 0221461e..99d82ea5 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/sysinfo.h>
#include "igt_perf.h"
@@ -31,6 +32,8 @@ static int
_perf_open(uint64_t type, uint64_t config, int group, uint64_t format)
{
struct perf_event_attr attr = { };
+ int nr_cpus = get_nprocs_conf();
+ int cpu = 0, ret;
attr.type = type;
if (attr.type == 0)
@@ -42,7 +45,11 @@ _perf_open(uint64_t type, uint64_t config, int group, uint64_t format)
attr.read_format = format;
attr.config = config;
- return perf_event_open(&attr, -1, 0, group, 0);
+ do {
+ ret = perf_event_open(&attr, -1, cpu++, group, 0);
+ } while ((ret < 0 && errno == EINVAL) && (cpu < nr_cpus));
+
+ return ret;
}
int perf_i915_open(uint64_t config)