mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-13 02:46:23 +00:00
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>
This commit is contained in:
parent
a508fc8622
commit
925e5e1cae
@ -192,6 +192,20 @@ intel_get_total_swap_mb(void)
|
|||||||
return retval / (1024*1024);
|
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,
|
int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode,
|
||||||
uint64_t *out_required, uint64_t *out_total)
|
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)
|
if (out_total)
|
||||||
*out_total = total;
|
*out_total = total;
|
||||||
|
|
||||||
|
if (count > vfs_file_max())
|
||||||
|
return false;
|
||||||
|
|
||||||
return required < total;
|
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,
|
igt_skip_on_f(!__intel_check_memory(count, size, mode,
|
||||||
&required, &total),
|
&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)((required + ((1<<20) - 1)) >> 20),
|
||||||
(long long)(total >> 20),
|
(long long)(total >> 20),
|
||||||
mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
|
mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
|
||||||
mode & CHECK_SWAP ? " + swap": "");
|
mode & CHECK_SWAP ? " + swap": "",
|
||||||
|
(long long)vfs_file_max());
|
||||||
|
|
||||||
igt_skip_on_simulation();
|
igt_skip_on_simulation();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user