[igt-dev] [CI i-g-t] tests/perf_pmu: Raw CPU hotplug

Tvrtko Ursulin tursulin at ursulin.net
Tue Feb 6 14:36:19 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Just offline and online CPUs to see what happens.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 tests/perf_pmu.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index eedd87416cfb..681d4a55d006 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1027,6 +1027,35 @@ static void cpu_hotplug(int gem_fd)
 	assert_within_epsilon(val, ts[1] - ts[0], tolerance);
 }
 
+static void cpu_hotplug_raw(int gem_fd)
+{
+	int cpu = 0;
+	char name[128];
+	int cpufd;
+
+	igt_require(cpu0_hotplug_support());
+
+	for (;;) {
+		igt_assert_lt(snprintf(name, sizeof(name),
+				       "/sys/devices/system/cpu/cpu%d/online",
+				       cpu),
+			      sizeof(name));
+		cpufd = open(name, O_WRONLY);
+		if (cpufd == -1) {
+			igt_assert(cpu > 0);
+			break;
+		}
+
+		/* Offline followed by online a CPU. */
+		igt_assert_eq(write(cpufd, "0", 2), 2);
+		usleep(1e6);
+		igt_assert_eq(write(cpufd, "1", 2), 2);
+
+		close(cpufd);
+		cpu++;
+	}
+}
+
 static void
 test_interrupts(int gem_fd)
 {
@@ -1522,6 +1551,9 @@ igt_main
 	igt_subtest("cpu-hotplug")
 		cpu_hotplug(fd);
 
+	igt_subtest("cpu-hotplug-raw")
+		cpu_hotplug_raw(fd);
+
 	/**
 	 * Test GPU frequency.
 	 */
-- 
2.14.1



More information about the igt-dev mailing list