anv: add ANV_SYS_MEM_LIMIT for debugging system memory restrictions

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 <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28513>
This commit is contained in:
Paulo Zanoni 2025-03-25 17:19:28 -07:00 committed by Marge Bot
parent ec4b2ce664
commit fdbdfaed01

View file

@ -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