Mesa (staging/20.1): anv: use os_get_total_physical_memory()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Sep 2 13:58:49 UTC 2020
Module: Mesa
Branch: staging/20.1
Commit: c9b3a0566eccf3aa2a875f1947ff3f4b66e01a12
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c9b3a0566eccf3aa2a875f1947ff3f4b66e01a12
Author: Jonathan Gray <jsg at jsg.id.au>
Date: Sat Nov 30 17:36:01 2019 +1100
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 at jsg.id.au>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6517>
(cherry picked from commit 81b163fb73ae73709d257badf4f5aaf3b63fca4a)
---
.pick_status.json | 2 +-
src/intel/vulkan/anv_device.c | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 281098e0920..839d11355f1 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -130,7 +130,7 @@
"description": "anv: use os_get_total_physical_memory()",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "060a6434eca9fb05ca2dfd612f8abd4786ee4549"
},
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 2f4e75d99ff..5785c790b43 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 <xf86drm.h>
@@ -37,6 +36,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/xmlpool.h"
@@ -103,10 +103,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.
More information about the mesa-commit
mailing list