From fdbdfaed0157bea23a17fef9fdbf3d380d7ff8ef Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Tue, 25 Mar 2025 17:19:28 -0700 Subject: [PATCH] anv: add ANV_SYS_MEM_LIMIT for debugging system memory restrictions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you suspect a workload is failing because it needs more memory, you can set ANV_SYS_MEM_LIMIT=100 to give it all the memory available. This could make, for example, certain games start working (it really depends on how much RAM you have and how much the game wants). If you suspect a workload is too resource hungry, you can try to limit it with ANV_SYS_MEM_LIMIT=30 (or some other value) to see if it can deal with the more restricted environment and behave accordingly. Reviewed-by: José Roberto de Souza Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_physical_device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 2918212cb1b..69dfd426a36 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -1993,6 +1993,17 @@ anv_restrict_sys_heap_size(struct anv_physical_device *device, return kmd_reported_sram; } + const char *env_limit = os_get_option("ANV_SYS_MEM_LIMIT"); + if (env_limit) { + int64_t limit_percent = debug_parse_num_option(env_limit, 75); + if (limit_percent < 10) + limit_percent = 10; + else if (limit_percent > 100) + limit_percent = 100; + + return kmd_reported_sram * limit_percent / 100; + } + if (kmd_reported_sram <= 4ull * 1024ull * 1024ull * 1024ull) return kmd_reported_sram / 2; else