diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-12-08 10:06:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-12-15 10:57:58 +0000 |
commit | 565d911f08df697fa211dbd1faefe2fd57066f71 (patch) | |
tree | 42b23dfb5b2c55fc1355a8a383329bb64d2f958d | |
parent | 9c6798317668dc9fb469c6efc28ba074bfdcddc8 (diff) |
i915/gem_shrink: Refactor allocation sizing based on available memory
Refactor the allocation such that we utilise just enough memory pressure
to invoke the shrinker, and just enough processes to spread across the
CPUs and contend on the shrinker.
v2: Reduce over-allocation from mem_size/2 to mem_size/8, and 9
processes per cpu.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-rw-r--r-- | tests/i915/gem_shrink.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c index 023db8c5..f1a4ee91 100644 --- a/tests/i915/gem_shrink.c +++ b/tests/i915/gem_shrink.c @@ -426,6 +426,7 @@ igt_main int num_processes = 0; igt_fixture { + const int ncpus = sysconf(_SC_NPROCESSORS_ONLN); uint64_t mem_size = intel_get_total_ram_mb(); int fd; @@ -434,16 +435,16 @@ igt_main /* * Spawn enough processes to use all memory, but each only - * uses half the available mappable aperture ~128MiB. + * uses a fraction of the available per-cpu memory. * Individually the processes would be ok, but en masse * we expect the shrinker to start purging objects, * and possibly fail. */ - alloc_size = gem_mappable_aperture_size(fd) / 2; - num_processes = 1 + (mem_size / (alloc_size >> 20)); + alloc_size = (mem_size + ncpus - 1) / ncpus / 8; + num_processes = ncpus + (mem_size / alloc_size); - igt_info("Using %d processes and %'lluMiB per process\n", - num_processes, (long long)(alloc_size >> 20)); + igt_info("Using %d processes and %'"PRIu64"MiB per process\n", + num_processes, alloc_size); intel_require_memory(num_processes, alloc_size, CHECK_SWAP | CHECK_RAM); |