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 /lib/intel_os.c | |
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 'lib/intel_os.c')
-rw-r--r-- | lib/intel_os.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c index 06361f4c..64e37222 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -192,6 +192,38 @@ intel_get_total_swap_mb(void) return retval / (1024*1024); } +int __intel_check_memory(uint32_t count, uint64_t size, unsigned mode, + uint64_t *out_required, uint64_t *out_total) +{ +/* rough estimate of how many bytes the kernel requires to track each object */ +#define KERNEL_BO_OVERHEAD 512 + uint64_t required, total; + + required = count; + required *= size + KERNEL_BO_OVERHEAD; + required = ALIGN(required, 4096); + + igt_debug("Checking %'u surfaces of size %'llu bytes (total %'llu) against %s%s\n", + count, (long long)size, (long long)required, + mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", + mode & CHECK_SWAP ? " + swap": ""); + + total = 0; + if (mode & (CHECK_RAM | CHECK_SWAP)) + total += intel_get_avail_ram_mb(); + if (mode & CHECK_SWAP) + total += intel_get_total_swap_mb(); + total *= 1024 * 1024; + + if (out_required) + *out_required = required; + + if (out_total) + *out_total = total; + + return required < total; +} + /** * intel_require_memory: * @count: number of surfaces that will be created @@ -217,27 +249,10 @@ intel_get_total_swap_mb(void) */ void intel_require_memory(uint32_t count, uint64_t size, unsigned mode) { -/* rough estimate of how many bytes the kernel requires to track each object */ -#define KERNEL_BO_OVERHEAD 512 uint64_t required, total; - required = count; - required *= size + KERNEL_BO_OVERHEAD; - required = ALIGN(required, 4096); - - igt_debug("Checking %'u surfaces of size %'llu bytes (total %'llu) against %s%s\n", - count, (long long)size, (long long)required, - mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", - mode & CHECK_SWAP ? " + swap": ""); - - total = 0; - if (mode & (CHECK_RAM | CHECK_SWAP)) - total += intel_get_avail_ram_mb(); - if (mode & CHECK_SWAP) - total += intel_get_total_swap_mb(); - total *= 1024 * 1024; - - igt_skip_on_f(total <= required, + igt_skip_on_f(!__intel_check_memory(count, size, mode, + &required, &total), "Estimated that we need %'llu bytes for the test, but only have %'llu bytes available (%s%s)\n", (long long)required, (long long)total, mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", |