summaryrefslogtreecommitdiff
path: root/tests/eviction_common.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-02-26 12:01:47 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-02-26 12:06:10 +0000
commit8c475e0ba69c585bc11062edd1f7fc4bbded811c (patch)
tree6520bfcbe394e12ade9502dfcd46bee36a034796 /tests/eviction_common.c
parentea332b64b6e9f6935da4b43f05fefcdcea32cc64 (diff)
evictions: Limit the number of minor eviction surfaces to fit in RAM
We allocate more surfaces than used in a single pass in order to stress the eviction code between batches. The intent here is not to exercise swapping, and we fail to check that there is enough swap+memory to hold all our surfaces. So limit the number of surfaces we allocate to fit into RAM, and then require that the number of surfaces we need for testing is less than the number of surfaces we can allocate. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/eviction_common.c')
-rw-r--r--tests/eviction_common.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 91fb2dfe..d1c4798a 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -64,6 +64,7 @@ static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
{
uint32_t *bo, *sel;
int n, m, pass, fail;
+ int total_surfaces;
/* Make sure nr_surfaces is not divisible by seven
* to avoid duplicates in the selection loop below.
@@ -72,26 +73,26 @@ static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
nr_surfaces *= 7;
nr_surfaces += 3;
- igt_require((uint64_t)nr_surfaces * surface_size / (1024 * 1024)
- < intel_get_total_ram_mb() * 9 / 10);
+ total_surfaces = (uint64_t)intel_get_total_ram_mb() * 9 /10 * 1024 *1024 / surface_size;
+ igt_require(nr_surfaces < total_surfaces);
- bo = malloc(3*nr_surfaces*sizeof(*bo));
+ bo = malloc((nr_surfaces + total_surfaces)*sizeof(*bo));
igt_assert(bo);
- for (n = 0; n < 2*nr_surfaces; n++)
+ for (n = 0; n < total_surfaces; n++)
bo[n] = ops->create(fd, surface_size);
sel = bo + n;
for (fail = 0, m = 0; fail < 10; fail++) {
for (pass = 0; pass < 100; pass++) {
for (n = 0; n < nr_surfaces; n++, m += 7)
- sel[n] = bo[m%(2*nr_surfaces)];
+ sel[n] = bo[m%total_surfaces];
ops->copy(fd, sel[0], sel[1], sel, nr_surfaces, 0);
}
- ops->copy(fd, bo[0], bo[0], bo, 2*nr_surfaces, ENOSPC);
+ ops->copy(fd, bo[0], bo[0], bo, total_surfaces, ENOSPC);
}
- for (n = 0; n < 2*nr_surfaces; n++)
+ for (n = 0; n < total_surfaces; n++)
ops->close(fd, bo[n]);
free(bo);