diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-07 11:19:26 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-19 14:03:15 +0000 |
commit | 42291f25100cd01653b3fb3a2a1fbe6975e9c1bf (patch) | |
tree | 614482a391de4afb27c02780f24ee58c93300d2e /tests | |
parent | 51e965f299284b3c9b96ac5e384ddeb22bd8d1fd (diff) |
gem_concurrent_blit: Don't call igt_require() outside of a subtest/fixture
gem_concurrent_blit tries to ensure that it doesn't try and run a test
that would grind the system to a halt, i.e. unexpectedly cause swap
thrashing. It currently calls intel_require_memory(), but outside of
the subtest (as the tests use fork, it cannot do requirement testing
within the test children) - but intel_require_memory() calls
igt_require() and triggers and abort. Wrapping that initial require
within an igt_fixture() stops the abort(), but also prevents any further
testing.
This patch restructures the requirement checking to ordinary conditions,
which though allowing the test to run, also prevents listing of subtests
on machines which cannot handle them.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gem_concurrent_all.c | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c index 558b9c13..a7db23cb 100644 --- a/tests/gem_concurrent_all.c +++ b/tests/gem_concurrent_all.c @@ -155,9 +155,9 @@ static bool can_create_stolen(void) static drm_intel_bo * (*create_func)(drm_intel_bufmgr *bufmgr, uint64_t size); -static void create_cpu_require(void) +static bool create_cpu_require(void) { - igt_require(create_func != create_stolen_bo); + return create_func != create_stolen_bo; } static drm_intel_bo * @@ -375,7 +375,7 @@ gpu_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height, drm_intel_bo * const struct access_mode { const char *name; - void (*require)(void); + bool (*require)(void); void (*set_bo)(drm_intel_bo *bo, uint32_t val, int w, int h); void (*cmp_bo)(drm_intel_bo *bo, uint32_t val, int w, int h, drm_intel_bo *tmp); drm_intel_bo *(*create_bo)(drm_intel_bufmgr *bufmgr, int width, int height); @@ -1321,24 +1321,22 @@ run_basic_modes(const char *prefix, } static void -run_modes(const char *style, const struct access_mode *mode) +run_modes(const char *style, const struct access_mode *mode, unsigned allow_mem) { - if (mode->require) - mode->require(); - - igt_debug("%s: using 2x%d buffers, each 1MiB\n", style, num_buffers); - intel_require_memory(2*num_buffers, 1024*1024, CHECK_RAM); + if (mode->require && !mode->require()) + return; - if (all) { - run_basic_modes(style, mode, "", run_single); + igt_debug("%s: using 2x%d buffers, each 1MiB\n", + style, num_buffers); + if (!__intel_check_memory(2*num_buffers, 1024*1024, allow_mem, + NULL, NULL)) + return; - igt_fork_signal_helper(); - run_basic_modes(style, mode, "-interruptible", run_interruptible); - igt_stop_signal_helper(); - } + run_basic_modes(style, mode, "", run_single); + run_basic_modes(style, mode, "-forked", run_forked); igt_fork_signal_helper(); - run_basic_modes(style, mode, "-forked", run_forked); + run_basic_modes(style, mode, "-interruptible", run_interruptible); run_basic_modes(style, mode, "-bomb", run_bomb); igt_stop_signal_helper(); } @@ -1355,6 +1353,8 @@ igt_main { "stolen-", create_stolen_bo, can_create_stolen }, { NULL, NULL } }, *c; + uint64_t pin_sz = 0; + void *pinned = NULL; int i; igt_skip_on_simulation(); @@ -1381,7 +1381,7 @@ igt_main if (c->require()) { snprintf(name, sizeof(name), "%s%s", c->name, "small"); for (i = 0; i < ARRAY_SIZE(access_modes); i++) - run_modes(name, &access_modes[i]); + run_modes(name, &access_modes[i], CHECK_RAM); } igt_fixture { @@ -1391,7 +1391,7 @@ igt_main if (c->require()) { snprintf(name, sizeof(name), "%s%s", c->name, "thrash"); for (i = 0; i < ARRAY_SIZE(access_modes); i++) - run_modes(name, &access_modes[i]); + run_modes(name, &access_modes[i], CHECK_RAM); } igt_fixture { @@ -1401,7 +1401,37 @@ igt_main if (c->require()) { snprintf(name, sizeof(name), "%s%s", c->name, "full"); for (i = 0; i < ARRAY_SIZE(access_modes); i++) - run_modes(name, &access_modes[i]); + run_modes(name, &access_modes[i], CHECK_RAM); + } + + igt_fixture { + num_buffers = gem_mappable_aperture_size() / (1024 * 1024); + pin_sz = intel_get_avail_ram_mb() - num_buffers; + + igt_debug("Pinning %ld MiB\n", pin_sz); + pin_sz *= 1024 * 1024; + + if (posix_memalign(&pinned, 4096, pin_sz) || + mlock(pinned, pin_sz) || + madvise(pinned, pin_sz, MADV_DONTFORK)) { + free(pinned); + pinned = NULL; + } + igt_require(pinned); + } + + if (c->require()) { + snprintf(name, sizeof(name), "%s%s", c->name, "swap"); + for (i = 0; i < ARRAY_SIZE(access_modes); i++) + run_modes(name, &access_modes[i], CHECK_RAM | CHECK_SWAP); + } + + igt_fixture { + if (pinned) { + munlock(pinned, pin_sz); + free(pinned); + pinned = NULL; + } } } } |