From: Tvrtko Ursulin <tursulin@ursulin.net>
To: igt-dev@lists.freedesktop.org
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2 9/9] tests/perf_pmu: Use short batches from hotplug test
Date: Mon, 5 Feb 2018 11:38:10 +0000 [thread overview]
Message-ID: <20180205113810.15045-1-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <151760778327.15322.10262825883779352598@mail.alporthouse.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
This test emits a spin batch which runs roughly for N CPU cores seconds
As such these can be declared as GPU hangs, so work around that by looping
with shorter batches.
v2:
* Use overlapping spinners. (Chris Wilson)
* Go back to igt_fork. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
tests/perf_pmu.c | 89 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 69 insertions(+), 20 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 260b04b09c86..ffa67ffd2d09 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -88,15 +88,23 @@ init(int gem_fd, const struct intel_execution_engine2 *e, uint8_t sample)
}
}
-static uint64_t pmu_read_single(int fd)
+static uint64_t __pmu_read_single(int fd, uint64_t *ts)
{
uint64_t data[2];
igt_assert_eq(read(fd, data, sizeof(data)), sizeof(data));
+ if (ts)
+ *ts = data[1];
+
return data[0];
}
+static uint64_t pmu_read_single(int fd)
+{
+ return __pmu_read_single(fd, NULL);
+}
+
static void pmu_read_multi(int fd, unsigned int num, uint64_t *val)
{
uint64_t buf[2 + num];
@@ -919,19 +927,28 @@ static bool cpu0_hotplug_support(void)
static void cpu_hotplug(int gem_fd)
{
- struct timespec start = { };
- igt_spin_t *spin;
- uint64_t val, ref;
- int fd;
+ igt_spin_t *spin[2];
+ uint64_t ts[2];
+ uint64_t val;
+ int link[2];
+ int fd, ret;
+ int cur = 0;
igt_require(cpu0_hotplug_support());
- fd = perf_i915_open(I915_PMU_ENGINE_BUSY(I915_ENGINE_CLASS_RENDER, 0));
- igt_assert(fd >= 0);
+ fd = open_pmu(I915_PMU_ENGINE_BUSY(I915_ENGINE_CLASS_RENDER, 0));
- spin = igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER, 0);
+ /*
+ * Create two spinners so test can ensure shorter gaps in engine
+ * busyness as it is terminating one and re-starting the other.
+ */
+ spin[0] = igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER, 0);
+ spin[1] = __igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER, 0);
- igt_nsec_elapsed(&start);
+ val = __pmu_read_single(fd, &ts[0]);
+
+ ret = pipe2(link, O_NONBLOCK);
+ igt_assert_eq(ret, 0);
/*
* Toggle online status of all the CPUs in a child process and ensure
@@ -940,21 +957,29 @@ static void cpu_hotplug(int gem_fd)
igt_fork(child, 1) {
int cpu = 0;
+ close(link[0]);
+
for (;;) {
char name[128];
int cpufd;
- sprintf(name, "/sys/devices/system/cpu/cpu%d/online",
- cpu);
+ 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);
+ /*
+ * Signal parent that we cycled through all
+ * CPUs and we are done.
+ */
+ igt_assert_eq(write(link[1], "*", 1), 1);
break;
}
- igt_assert_eq(write(cpufd, "0", 2), 2);
+ /* 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);
@@ -962,17 +987,41 @@ static void cpu_hotplug(int gem_fd)
}
}
- igt_waitchildren();
+ close(link[1]);
- ref = igt_nsec_elapsed(&start);
- val = pmu_read_single(fd);
+ /*
+ * Very long batches can be declared as GPU hangs so emit shorter ones
+ * until the CPU core shuffler finishes one loop.
+ */
+ for (;;) {
+ char buf;
+ int ret2;
- igt_spin_batch_end(spin);
- gem_sync(gem_fd, spin->handle);
- igt_spin_batch_free(gem_fd, spin);
+ usleep(500e3);
+ end_spin(gem_fd, spin[cur], 0);
+
+ /* Check if the child is signaling completion. */
+ ret2 = read(link[0], &buf, 1);
+ if ( ret2 == 1 || (ret2 < 0 && errno != EAGAIN))
+ break;
+
+ igt_spin_batch_free(gem_fd, spin[cur]);
+ spin[cur] = __igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER,
+ 0);
+ cur ^= 1;
+ }
+
+ val = __pmu_read_single(fd, &ts[1]) - val;
+
+ end_spin(gem_fd, spin[0], FLAG_SYNC);
+ end_spin(gem_fd, spin[1], FLAG_SYNC);
+ igt_spin_batch_free(gem_fd, spin[0]);
+ igt_spin_batch_free(gem_fd, spin[1]);
+ igt_waitchildren();
close(fd);
+ close(link[0]);
- assert_within_epsilon(val, ref, tolerance);
+ assert_within_epsilon(val, ts[1] - ts[0], tolerance);
}
static void
--
2.14.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-02-05 11:38 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 18:37 [igt-dev] [PATCH v2 i-g-t 0/9] perf_pmu reliability improvements Tvrtko Ursulin
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 1/9] tests/perf_pmu: Tighten busy measurement Tvrtko Ursulin
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 2/9] tests/perf_pmu: More busy measurement tightening Tvrtko Ursulin
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 3/9] tests/perf_pmu: Use measured sleep in all time based tests Tvrtko Ursulin
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 4/9] tests/perf_pmu: Convert to flags Tvrtko Ursulin
2018-02-02 20:39 ` Chris Wilson
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 5/9] tests/perf_pmu: Add trailing edge idle test variants Tvrtko Ursulin
2018-02-02 20:45 ` Chris Wilson
2018-02-05 10:32 ` Tvrtko Ursulin
2018-02-05 11:36 ` [igt-dev] [PATCH i-g-t v2 " Tvrtko Ursulin
2018-02-05 14:08 ` Chris Wilson
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 6/9] tests/perf_pmu: PMU enable race test Tvrtko Ursulin
2018-02-02 20:52 ` Chris Wilson
2018-02-05 10:07 ` Tvrtko Ursulin
2018-02-05 10:16 ` Chris Wilson
2018-02-05 10:40 ` Tvrtko Ursulin
2018-02-05 14:11 ` Chris Wilson
2018-02-05 15:01 ` [igt-dev] [PATCH i-g-t v3 " Tvrtko Ursulin
2018-02-05 11:36 ` [igt-dev] [PATCH i-g-t v2 " Tvrtko Ursulin
2018-02-05 14:12 ` Chris Wilson
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 7/9] tests/perf_pmu: Always skip missing engines Tvrtko Ursulin
2018-02-02 20:54 ` Chris Wilson
2018-02-05 11:37 ` [igt-dev] [PATCH i-g-t v2 " Tvrtko Ursulin
2018-02-05 14:13 ` Chris Wilson
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 8/9] tests/perf_pmu: Explicitly test for engine availability in init tests Tvrtko Ursulin
2018-02-02 20:57 ` Chris Wilson
2018-02-05 11:37 ` [igt-dev] [PATCH i-g-t v2 " Tvrtko Ursulin
2018-02-05 14:14 ` Chris Wilson
2018-02-05 15:02 ` [igt-dev] [PATCH i-g-t v3 " Tvrtko Ursulin
2018-02-02 18:37 ` [igt-dev] [PATCH i-g-t 9/9] tests/perf_pmu: Use short batches from hotplug test Tvrtko Ursulin
2018-02-02 21:43 ` Chris Wilson
2018-02-05 11:38 ` Tvrtko Ursulin [this message]
2018-02-05 14:37 ` [igt-dev] [PATCH i-g-t v2 " Chris Wilson
2018-02-05 11:59 ` [igt-dev] [PATCH i-g-t " Tvrtko Ursulin
2018-02-02 19:18 ` [igt-dev] ✓ Fi.CI.BAT: success for perf_pmu reliability improvements (rev2) Patchwork
2018-02-02 22:20 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-02-05 12:12 ` [igt-dev] ✓ Fi.CI.BAT: success for perf_pmu reliability improvements (rev7) Patchwork
2018-02-05 13:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-02-05 15:21 ` [igt-dev] ✓ Fi.CI.BAT: success for perf_pmu reliability improvements (rev9) Patchwork
2018-02-05 17:35 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180205113810.15045-1-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=igt-dev@lists.freedesktop.org \
--cc=tvrtko.ursulin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox