Commit 207b7000 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Limit live_gtt allocation test to fit within RAM

Limit the GTT size we try and allocate to ensure that it fits within RAM
and does not trigger the oomkiller indiscriminately.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180706125338.24432-1-chris@chris-wilson.co.uk
parent 66daec6b
...@@ -148,7 +148,7 @@ static int igt_ppgtt_alloc(void *arg) ...@@ -148,7 +148,7 @@ static int igt_ppgtt_alloc(void *arg)
{ {
struct drm_i915_private *dev_priv = arg; struct drm_i915_private *dev_priv = arg;
struct i915_hw_ppgtt *ppgtt; struct i915_hw_ppgtt *ppgtt;
u64 size, last; u64 size, last, limit;
int err = 0; int err = 0;
/* Allocate a ppggt and try to fill the entire range */ /* Allocate a ppggt and try to fill the entire range */
...@@ -163,10 +163,18 @@ static int igt_ppgtt_alloc(void *arg) ...@@ -163,10 +163,18 @@ static int igt_ppgtt_alloc(void *arg)
if (!ppgtt->vm.allocate_va_range) if (!ppgtt->vm.allocate_va_range)
goto err_ppgtt_cleanup; goto err_ppgtt_cleanup;
/*
* While we only allocate the page tables here and so we could
* address a much larger GTT than we could actually fit into
* RAM, a practical limit is the amount of physical pages in the system.
* This should ensure that we do not run into the oomkiller during
* the test and take down the machine wilfully.
*/
limit = totalram_pages << PAGE_SHIFT;
limit = min(ppgtt->vm.total, limit);
/* Check we can allocate the entire range */ /* Check we can allocate the entire range */
for (size = 4096; for (size = 4096; size <= limit; size <<= 2) {
size <= ppgtt->vm.total;
size <<= 2) {
err = ppgtt->vm.allocate_va_range(&ppgtt->vm, 0, size); err = ppgtt->vm.allocate_va_range(&ppgtt->vm, 0, size);
if (err) { if (err) {
if (err == -ENOMEM) { if (err == -ENOMEM) {
...@@ -183,9 +191,7 @@ static int igt_ppgtt_alloc(void *arg) ...@@ -183,9 +191,7 @@ static int igt_ppgtt_alloc(void *arg)
} }
/* Check we can incrementally allocate the entire range */ /* Check we can incrementally allocate the entire range */
for (last = 0, size = 4096; for (last = 0, size = 4096; size <= limit; last = size, size <<= 2) {
size <= ppgtt->vm.total;
last = size, size <<= 2) {
err = ppgtt->vm.allocate_va_range(&ppgtt->vm, err = ppgtt->vm.allocate_va_range(&ppgtt->vm,
last, size - last); last, size - last);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment