On Sun, Dec 01, 2019 at 02:21:49AM +1100, Jonathan Gray wrote: > map linux /proc/meminfo "MemAvailable" to uvm free pages
On second thought HW_USERMEM64 may be a better fit here. "The amount of available non-kernel memory in bytes" Which ends up being physmem - uvmexp.wired (memory that can't be paged out) instead of the current amount of free memory. > > Signed-off-by: Jonathan Gray <j...@jsg.id.au> > --- > src/intel/vulkan/anv_device.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c > index 81e3905ae99..ce93718c106 100644 > --- a/src/intel/vulkan/anv_device.c > +++ b/src/intel/vulkan/anv_device.c > @@ -370,6 +370,16 @@ anv_physical_device_free_disk_cache(struct > anv_physical_device *device) > static uint64_t > get_available_system_memory() > { > +#ifdef __OpenBSD__ > + int uvmexp_mib[] = { CTL_VM, VM_UVMEXP }; > + struct uvmexp uvmexp; > + size_t size; > + > + size = sizeof(uvmexp); > + if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) == -1) > + return 0; > + return uvmexp.free * uvmexp.pagesize; > +#else > char *meminfo = os_read_file("/proc/meminfo"); > if (!meminfo) > return 0; > @@ -388,6 +398,7 @@ get_available_system_memory() > > free(meminfo); > return 0; > +#endif > } > > static VkResult > -- > 2.24.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev