summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-03 17:49:02 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-09-03 17:51:05 +0200
commit7db283f930b2e03f019bb23689d2c12daff8104c (patch)
treead3d7e43424b855ccbc399a9e85e540974807a6e
parent2c7166eb7a60a87477be762d45aaafafb15aceff (diff)
tests/gem_reloc_vs_gpu: add thrashing tests
Using the i915_gem_drop_caches debugfs interface to thrash without really thrashing. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--tests/gem_reloc_vs_gpu.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/tests/gem_reloc_vs_gpu.c b/tests/gem_reloc_vs_gpu.c
index 050e24af..c0b6c113 100644
--- a/tests/gem_reloc_vs_gpu.c
+++ b/tests/gem_reloc_vs_gpu.c
@@ -25,6 +25,7 @@
*
*/
+#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -33,6 +34,8 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <signal.h>
+#include <sys/wait.h>
#include "drm.h"
#include "i915_drm.h"
#include "drmtest.h"
@@ -273,13 +276,35 @@ static void do_test(int fd, bool faulting_reloc)
#define INTERRUPT (1 << 0)
#define FAULTING (1 << 1)
#define THRASH (1 << 2)
-#define ALL_FLAGS (INTERRUPT | FAULTING | THRASH)
+#define THRASH_INACTIVE (1 << 3)
+#define ALL_FLAGS (INTERRUPT | FAULTING | THRASH | THRASH_INACTIVE)
static void do_forked_test(int fd, unsigned flags)
{
int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
-
- if (flags & THRASH) {
-
+ pid_t pid = -1;
+
+ if (flags & (THRASH | THRASH_INACTIVE)) {
+ sighandler_t oldsig;
+ char fname[FILENAME_MAX];
+ int drop_caches_fd;
+ const char *data = THRASH_INACTIVE ? "0xf" : "0x7";
+
+ snprintf(fname, FILENAME_MAX, "%s/%i/%s",
+ "/sys/kernel/debug/dri", drm_get_card(),
+ "i915_gem_drop_caches");
+
+ drop_caches_fd = open(fname, O_WRONLY);
+ igt_require(drop_caches_fd >= 0);
+
+ oldsig = signal(SIGQUIT, SIG_DFL);
+ pid = fork();
+ signal(SIGQUIT, oldsig);
+ if (pid == 0) {
+ while (1) {
+ usleep(1000);
+ igt_assert(write(drop_caches_fd, data, strlen(data) + 1) == strlen(data) + 1);
+ }
+ }
}
igt_fork(i, num_threads * 4) {
@@ -297,6 +322,13 @@ static void do_forked_test(int fd, unsigned flags)
}
igt_waitchildren();
+
+ if (pid != -1) {
+ int exitcode;
+
+ kill(pid, SIGQUIT);
+ wait(&exitcode);
+ }
}
int fd;
@@ -334,10 +366,14 @@ int main(int argc, char **argv)
igt_stop_signal_helper();
for (unsigned flags = 0; flags <= ALL_FLAGS; flags++) {
- igt_subtest_f("forked%s%s%s",
+ if ((flags & THRASH) && (flags & THRASH_INACTIVE))
+ continue;
+
+ igt_subtest_f("forked%s%s%s%s",
flags & INTERRUPT ? "-interruptible" : "",
flags & FAULTING ? "-faulting-reloc" : "",
- flags & THRASH ? "-thrashing" : "")
+ flags & THRASH ? "-thrashing" : "",
+ flags & THRASH ? "-thrash-inactive" : "")
do_forked_test(fd, flags);
}