summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMerry <git@mary.rs>2023-01-01 12:38:49 +0100
committerMerry <git@mary.rs>2023-01-01 12:40:35 +0100
commitfd1831b65bc8a0817776ac41f82b6ff053247b1b (patch)
tree75154b03fc6d2e94660da0ec150ec8c147c06d2c
parenthost_memory: Allocate virtual_base with MAP_NORESERVE (diff)
downloadyuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar.gz
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar.bz2
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar.lz
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar.xz
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.tar.zst
yuzu-fd1831b65bc8a0817776ac41f82b6ff053247b1b.zip
Diffstat (limited to '')
-rw-r--r--src/common/host_memory.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 4a67f77b2..611c7d1a3 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -393,12 +393,27 @@ public:
}
// Virtual memory initialization
+#if defined(__FreeBSD__)
+ virtual_base =
+ static_cast<u8*>(mmap(nullptr, virtual_size, PROT_NONE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER, -1, 0));
+ if (virtual_base == MAP_FAILED) {
+ virtual_base = static_cast<u8*>(
+ mmap(nullptr, virtual_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
+ if (virtual_base == MAP_FAILED) {
+ LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno));
+ throw std::bad_alloc{};
+ }
+ }
+#else
virtual_base = static_cast<u8*>(mmap(nullptr, virtual_size, PROT_NONE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0));
if (virtual_base == MAP_FAILED) {
LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno));
throw std::bad_alloc{};
}
+ madvise(virtual_base, virtual_size, MADV_HUGEPAGE);
+#endif
good = true;
}