diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-02-29 15:33:26 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-02-29 15:40:21 +0000 |
commit | 925e5e1caef9b56bd53df457735514b644c7a399 (patch) | |
tree | 877954751c3ebb340de03204a760b5f1a5ccb4d7 /lib/intel_os.c | |
parent | a508fc86224887c413d99e55b524f3b03a073ed5 (diff) |
lib: Check required number of surfaces against VFS file limits
If we want to create more file handles than VFS supports (itself often a
memory limited value), report that we can not create that many objects
via intel_require_memory().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/intel_os.c')
-rw-r--r-- | lib/intel_os.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c index 2851dba0..b6a61921 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -192,6 +192,20 @@ intel_get_total_swap_mb(void) return retval / (1024*1024); } +static uint64_t vfs_file_max(void) +{ + static long long unsigned max; + if (max == 0) { + FILE *file = fopen("/proc/sys/fs/file-max", "r"); + max = 80000; + if (file) { + igt_assert(fscanf(file, "%llu", &max) == 1); + fclose(file); + } + } + return max; +} + int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode, uint64_t *out_required, uint64_t *out_total) { @@ -221,6 +235,9 @@ int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode, if (out_total) *out_total = total; + if (count > vfs_file_max()) + return false; + return required < total; } @@ -253,11 +270,13 @@ void intel_require_memory(uint64_t count, uint64_t size, unsigned mode) igt_skip_on_f(!__intel_check_memory(count, size, mode, &required, &total), - "Estimated that we need %'llu MiB for the test, but only have %'llu MiB available (%s%s)\n", + "Estimated that we need %'llu objects and %'llu MiB for the test, but only have %'llu MiB available (%s%s) and a maximum of %'llu objects\n", + (long long)count, (long long)((required + ((1<<20) - 1)) >> 20), (long long)(total >> 20), mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "", - mode & CHECK_SWAP ? " + swap": ""); + mode & CHECK_SWAP ? " + swap": "", + (long long)vfs_file_max()); igt_skip_on_simulation(); } |