diff options
author | Jonathan Gray <jsg@jsg.id.au> | 2019-11-30 17:36:01 +1100 |
---|---|---|
committer | Jonathan Gray <jsg@jsg.id.au> | 2020-09-02 11:40:25 +1000 |
commit | 81b163fb73ae73709d257badf4f5aaf3b63fca4a (patch) | |
tree | 94a5515adb0e331242df790f1b3e5f5694270fc2 | |
parent | 0369dd907778d8636e2b074717846bb658d76d90 (diff) |
anv: use os_get_total_physical_memory()
Replace non-portable sysinfo() use with Mesa's
os_get_total_physical_memory()
Fixes: 060a6434eca ("anv: Advertise larger heap sizes")
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6517>
-rw-r--r-- | src/intel/vulkan/anv_device.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index be4d1909d2e..f670be5cc5c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -25,7 +25,6 @@ #include <stdbool.h> #include <string.h> #include <sys/mman.h> -#include <sys/sysinfo.h> #include <unistd.h> #include <fcntl.h> #include "drm-uapi/drm_fourcc.h" @@ -38,6 +37,7 @@ #include "util/disk_cache.h" #include "util/mesa-sha1.h" #include "util/os_file.h" +#include "util/os_misc.h" #include "util/u_atomic.h" #include "util/u_string.h" #include "util/driconf.h" @@ -107,10 +107,9 @@ static uint64_t anv_compute_heap_size(int fd, uint64_t gtt_size) { /* Query the total ram from the system */ - struct sysinfo info; - sysinfo(&info); - - uint64_t total_ram = (uint64_t)info.totalram * (uint64_t)info.mem_unit; + uint64_t total_ram; + if (!os_get_total_physical_memory(&total_ram)) + return 0; /* We don't want to burn too much ram with the GPU. If the user has 4GiB * or less, we use at most half. If they have more than 4GiB, we use 3/4. |