diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-13 14:02:50 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-22 16:49:24 +0000 |
commit | 4a3a8263427db6e1d2779a092ab6fc035e8aca3f (patch) | |
tree | 3d9dd8c6fbc1739036d1b72be126e40dc85f8f1c /lib | |
parent | e180bec7bc16e727cea2f99aeff10b642f7778be (diff) |
lib: Print memory requirements as MiB
Since we need a lot of memory, trim off the less significant digits for
easier human consumption.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_aux.h | 4 | ||||
-rw-r--r-- | lib/intel_os.c | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 82bd5962..427719ef 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -86,9 +86,9 @@ uint64_t intel_get_avail_ram_mb(void); uint64_t intel_get_total_ram_mb(void); uint64_t intel_get_total_swap_mb(void); -int __intel_check_memory(uint32_t count, uint64_t size, unsigned mode, +int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode, uint64_t *out_required, uint64_t *out_total); -void intel_require_memory(uint32_t count, uint64_t size, unsigned mode); +void intel_require_memory(uint64_t count, uint64_t size, unsigned mode); #define CHECK_RAM 0x1 #define CHECK_SWAP 0x2 diff --git a/lib/intel_os.c b/lib/intel_os.c index 64e37222..2851dba0 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -192,7 +192,7 @@ intel_get_total_swap_mb(void) return retval / (1024*1024); } -int __intel_check_memory(uint32_t count, uint64_t size, unsigned mode, +int __intel_check_memory(uint64_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 */ @@ -203,8 +203,8 @@ int __intel_check_memory(uint32_t count, uint64_t size, unsigned mode, 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, + igt_debug("Checking %'llu surfaces of size %'llu bytes (total %'llu) against %s%s\n", + (long long)count, (long long)size, (long long)required, mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", mode & CHECK_SWAP ? " + swap": ""); @@ -247,14 +247,15 @@ int __intel_check_memory(uint32_t count, uint64_t size, unsigned mode, * assumption that any test that needs to check for memory requirements is a * thrashing test unsuitable for slow simulated systems. */ -void intel_require_memory(uint32_t count, uint64_t size, unsigned mode) +void intel_require_memory(uint64_t count, uint64_t size, unsigned mode) { uint64_t required, total; 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, + "Estimated that we need %'llu MiB for the test, but only have %'llu MiB available (%s%s)\n", + (long long)((required + ((1<<20) - 1)) >> 20), + (long long)(total >> 20), mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", mode & CHECK_SWAP ? " + swap": ""); |