From 7db283f930b2e03f019bb23689d2c12daff8104c Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 3 Sep 2013 17:49:02 +0200 Subject: 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 --- tests/gem_reloc_vs_gpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'tests/gem_reloc_vs_gpu.c') 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 #include #include @@ -33,6 +34,8 @@ #include #include #include +#include +#include #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); } -- cgit v1.2.3