[igt-dev] [PATCH i-g-t v3] tests/gem_evict_everything fix for mlocked-* subtests
Ewelina Musial
ewelina.musial at intel.com
Mon Jun 11 13:28:13 UTC 2018
Add check to avoid locking biggest mem size than is available.
Trying to allocate size returned by intel_get_avail_ram_mb()
triggers OOM killer. It looks like available RAM is not fully free
so my idea is to decrease this size of 1024MB and before allocating
increase mem size in loop till will be maximally big.
Also, changed surface_count. Few thousands of iterations is not
necessary and is taking a lot of time. This change should cover
previous functionality.
Using __igt_waitchildren() instead of igt_waitchildren() avoids
failing test if OOM killer stops process run by igt_fork() (OOM killer
is expected).
v2: Remove flag variable and do some cosmetic changes (Chris)
v3: Rebase after merging __igt_waitchildren() functionality
References: https://bugs.freedesktop.org/show_bug.cgi?id=101857
Signed-off-by: Ewelina Musial <ewelina.musial at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski at intel.com>
---
tests/eviction_common.c | 43 ++++++++++++++++++++++++++++++++++++-------
tests/gem_evict_everything.c | 6 +++---
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 300eb03d..8982865a 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -134,14 +134,19 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
uint64_t surface_count)
{
unsigned int *can_mlock;
- uint64_t sz, pin;
+ uint64_t sz, pin, *update_pin = 0;
intel_require_memory(surface_count, surface_size, CHECK_RAM);
sz = surface_size*surface_count;
- pin = intel_get_avail_ram_mb();
+ pin = intel_get_avail_ram_mb() - 1024;
pin *= 1024 * 1024;
igt_require(pin > sz);
+
+ update_pin = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ igt_assert(update_pin != MAP_FAILED);
+ *update_pin = pin;
+
pin -= sz;
igt_debug("Pinning [%'lld, %'lld] MiB\n",
@@ -151,16 +156,40 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
can_mlock = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
igt_assert(can_mlock != MAP_FAILED);
+ igt_fork(child, 1)
+ {
+ void *lock;
+ uint64_t update_step = (5 << 22);
+
+ do {
+ lock = malloc(*update_pin + update_step);
+ if (lock && !mlock(lock, *update_pin + update_step)) {
+ free(lock);
+ *update_pin += update_step;
+ }
+ } while (1);
+ }
+ __igt_waitchildren();
+
+ igt_require(*update_pin);
+
igt_fork(child, 1) {
void *locked;
- locked = malloc(pin + sz);
- if (locked != NULL && !mlock(locked, pin + sz))
+ locked = malloc(*update_pin);
+ if (locked && !mlock(locked, *update_pin)) {
*can_mlock = 1;
+ if (*update_pin >= pin + sz)
+ pin = *update_pin - sz;
+ else
+ exit(1);
+ }
}
igt_waitchildren();
+
igt_require(*can_mlock);
munmap(can_mlock, 4096);
+ munmap(update_pin, 4096);
igt_fork(child, 1) {
void *locked;
@@ -172,7 +201,7 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
igt_assert(bo);
locked = malloc(pin);
- if (locked == NULL || mlock(locked, pin))
+ if (!locked || mlock(locked, pin))
exit(ENOSPC);
for (n = 0; n < surface_count; n++)
@@ -190,14 +219,14 @@ static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
*/
locked = malloc(surface_size);
- if (locked == NULL || mlock(locked, surface_size))
+ if (!locked || mlock(locked, surface_size))
free(locked);
+
}
for (n = 0; n < surface_count; n++)
ops->close(fd, bo[n]);
}
-
igt_waitchildren();
}
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index f3607648..9552a061 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -190,7 +190,7 @@ igt_main
count = gem_aperture_size(fd);
if (count >> 32)
count = MAX_32b;
- count = 3 * count / size / 4;
+ count = count / size / 4;
igt_fork_hang_detector(fd);
}
@@ -230,7 +230,7 @@ igt_main
count = gem_aperture_size(fd);
if (count >> 32)
count = MAX_32b;
- count = 3 * count / size / 4;
+ count = count / size / 4;
}
igt_fork_signal_helper();
@@ -261,7 +261,7 @@ igt_main
count = gem_aperture_size(fd);
if (count >> 32)
count = MAX_32b;
- count = 3 * count / size / 4;
+ count = count / size / 4;
}
igt_subtest("mlocked-hang")
--
2.14.4
More information about the igt-dev
mailing list