mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-09 17:06:14 +00:00
igt/gem_evict_everything: Use mlock to reduce available memory
The idea here is to check what happens when a large process requests memory from us - we create and utilize a bunch of surfaces then have to relinquish some but continue using the whole working set (so as to force reloads). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
b9b82fdc5f
commit
068f9ceb62
@ -130,6 +130,90 @@ static int major_evictions(int fd, struct igt_eviction_test_ops *ops,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mlocked_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||||
|
int surface_size,
|
||||||
|
int surface_count)
|
||||||
|
{
|
||||||
|
size_t sz, pin;
|
||||||
|
int result[2];
|
||||||
|
void *locked;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
intel_require_memory(surface_count, surface_size, CHECK_RAM);
|
||||||
|
igt_assert(pipe(result) == 0);
|
||||||
|
|
||||||
|
sz = surface_size*surface_count;
|
||||||
|
pin = intel_get_avail_ram_mb();
|
||||||
|
pin *= 1024 * 1024;
|
||||||
|
igt_require(pin > sz);
|
||||||
|
pin -= 3*sz/2;
|
||||||
|
|
||||||
|
igt_debug("Pinning [%ld, %ld] MiB\n",
|
||||||
|
(long)pin/(1024*1024), (long)(pin + sz)/(1024*1024));
|
||||||
|
|
||||||
|
locked = malloc(pin + sz);
|
||||||
|
if (locked != NULL && mlock(locked, pin + sz)) {
|
||||||
|
free(locked);
|
||||||
|
locked = NULL;
|
||||||
|
} else {
|
||||||
|
munlock(locked, pin + sz);
|
||||||
|
free(locked);
|
||||||
|
}
|
||||||
|
igt_require(locked);
|
||||||
|
|
||||||
|
igt_fork(child, 1) {
|
||||||
|
uint32_t *bo;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
bo = malloc(surface_count*sizeof(*bo));
|
||||||
|
igt_assert(bo);
|
||||||
|
|
||||||
|
locked = malloc(pin);
|
||||||
|
if (locked == NULL || mlock(locked, pin)) {
|
||||||
|
ret = ENOSPC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (n = 0; n < surface_count; n++)
|
||||||
|
bo[n] = ops->create(fd, surface_size);
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
for (n = 0; n < surface_count - 2; n++) {
|
||||||
|
igt_permute_array(bo, surface_count, exchange_uint32_t);
|
||||||
|
ret = ops->copy(fd, bo[0], bo[1], bo, surface_count-n);
|
||||||
|
if (ret)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Having used the surfaces (and so pulled out of
|
||||||
|
* our pages into memory), start a memory hog to
|
||||||
|
* force evictions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
locked = malloc(surface_size);
|
||||||
|
if (locked == NULL || mlock(locked, surface_size)) {
|
||||||
|
ret = ENOSPC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (n = 0; n < surface_count; n++)
|
||||||
|
ops->close(fd, bo[n]);
|
||||||
|
|
||||||
|
out:
|
||||||
|
write(result[1], &ret, sizeof(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
igt_waitchildren();
|
||||||
|
|
||||||
|
fcntl(result[0], F_SETFL, fcntl(result[0], F_GETFL) | O_NONBLOCK);
|
||||||
|
read(result[0], &ret, sizeof(ret));
|
||||||
|
close(result[0]);
|
||||||
|
close(result[1]);
|
||||||
|
|
||||||
|
errno = ret;
|
||||||
|
igt_assert(ret == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
|
static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
|
||||||
int surface_size,
|
int surface_size,
|
||||||
int working_surfaces,
|
int working_surfaces,
|
||||||
|
@ -160,6 +160,11 @@ static void test_forking_evictions(int fd, int size, int count,
|
|||||||
forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
|
forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_mlocked_evictions(int fd, int size, int count)
|
||||||
|
{
|
||||||
|
mlocked_evictions(fd, &fault_ops, size, count);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_swapping_evictions(int fd, int size, int count)
|
static void test_swapping_evictions(int fd, int size, int count)
|
||||||
{
|
{
|
||||||
int trash_count;
|
int trash_count;
|
||||||
@ -205,6 +210,9 @@ igt_main
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("mlocked-normal")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-normal")
|
igt_subtest("swapping-normal")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
@ -224,6 +232,9 @@ igt_main
|
|||||||
|
|
||||||
igt_fork_signal_helper();
|
igt_fork_signal_helper();
|
||||||
|
|
||||||
|
igt_subtest("mlocked-interruptible")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-interruptible")
|
igt_subtest("swapping-interruptible")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
@ -237,6 +248,14 @@ igt_main
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (igt_fork_hang_helper()) {
|
if (igt_fork_hang_helper()) {
|
||||||
|
igt_fixture {
|
||||||
|
size = 1024 * 1024;
|
||||||
|
count = 3*gem_aperture_size(fd) / size / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
igt_subtest("mlocked-hang")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-hang")
|
igt_subtest("swapping-hang")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
|
@ -1028,6 +1028,12 @@ static void test_forking_evictions(int fd, int size, int count,
|
|||||||
reset_handle_ptr();
|
reset_handle_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_mlocked_evictions(int fd, int size, int count)
|
||||||
|
{
|
||||||
|
mlocked_evictions(fd, &fault_ops, size, count);
|
||||||
|
reset_handle_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_swapping_evictions(int fd, int size, int count)
|
static void test_swapping_evictions(int fd, int size, int count)
|
||||||
{
|
{
|
||||||
int trash_count;
|
int trash_count;
|
||||||
@ -1395,6 +1401,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("mlocked-unsync-normal")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-unsync-normal")
|
igt_subtest("swapping-unsync-normal")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
@ -1416,6 +1425,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
igt_fork_signal_helper();
|
igt_fork_signal_helper();
|
||||||
|
|
||||||
|
igt_subtest("mlocked-unsync-interruptible")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-unsync-interruptible")
|
igt_subtest("swapping-unsync-interruptible")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
@ -1495,6 +1507,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("mlocked-normal-sync")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-normal-sync")
|
igt_subtest("swapping-normal-sync")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
@ -1516,6 +1531,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
igt_fork_signal_helper();
|
igt_fork_signal_helper();
|
||||||
|
|
||||||
|
igt_subtest("mlocked-sync-interruptible")
|
||||||
|
test_mlocked_evictions(fd, size, count);
|
||||||
|
|
||||||
igt_subtest("swapping-sync-interruptible")
|
igt_subtest("swapping-sync-interruptible")
|
||||||
test_swapping_evictions(fd, size, count);
|
test_swapping_evictions(fd, size, count);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user