summaryrefslogtreecommitdiff
path: root/tests/dumb_buffer.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-05-11 21:48:23 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-05-11 21:51:45 +0100
commit48ed99c40779fc1b1f0fee8d51a051d90a277436 (patch)
treed61e2522c62d3e49fb756585ef44aed8784442cd /tests/dumb_buffer.c
parent726e09870f0b502b60bb1ecd209fc8af209ed378 (diff)
dumb_buffer: Restrict maximum target allocation
If a pagefault handler fails with ENOMEM (VM_FAULT_OOM), it calls the oomkiller without warning. On smaller machines we are trying to utilize a dumb buffer as larger as memory, expectedly failing, but unexpectedly being killed before we perform the tests. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1182 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/dumb_buffer.c')
-rw-r--r--tests/dumb_buffer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index 362fe787..f7468af1 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -292,6 +292,8 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
.width = 1 << 20, /* in pixels */
.height = 1, /* in rows */
};
+ const unsigned long max_rows =
+ intel_get_total_ram_mb() / 2; /* leave some spare */
volatile uint64_t largest = 0;
char * volatile ptr = NULL;
@@ -307,7 +309,7 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
return largest;
}
- for (create.height = 1; create.height; create.height *= 2) {
+ for (create.height = 1; create.height < max_rows; create.height *= 2) {
if (__dumb_create(fd, &create))
longjmp(sigjmp, SIGABRT);