Module: Mesa Branch: staging/23.3 Commit: 8975c22b5259c69c404c06dde36b352b46303d28 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8975c22b5259c69c404c06dde36b352b46303d28
Author: Kenneth Graunke <[email protected]> Date: Wed Dec 6 08:01:36 2023 -0800 anv: Don't report more memory available than the heap size When calculating the system memory heap size, we report only 3/4 of the total RAM size (or 1/2 for systems with less than 4GB of RAM). In the memory budget extension query, we were reporting 90% of the available system memory. If most of the memory in the system is free, this could result in the total heap size being 3/4 of RAM, but the memory available being 9/10 of RAM. But if the application tried to allocate the memory reported as "available", it would exceed the heap size. This can confuse some applications. This patch makes the memory budget query clamp the available RAM to the heap size, so it will never report more available than the heap can provide. Unfortunately, this means that we'll report only 67.5% of system memory as available (3/4 * 9/10). We may want to adjust this estimate in the future. Cc: mesa-stable Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: José Roberto de Souza <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26553> (cherry picked from commit a7b054c974155183cbbc90f3929de37f40200b79) --- .pick_status.json | 2 +- src/intel/vulkan/anv_device.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index aa6dcd0bf01..d48193f4ee1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -464,7 +464,7 @@ "description": "anv: Don't report more memory available than the heap size", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 1b1c7fba3dc..e887e9e2f78 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2760,7 +2760,7 @@ anv_get_memory_budget(VkPhysicalDevice physicalDevice, } } else { total_heaps_size = total_sys_heaps_size; - mem_available = device->sys.available; + mem_available = MIN2(device->sys.available, total_heaps_size); } double heap_proportion = (double) heap_size / total_heaps_size;
