From c061991c43ce1d0bf2d47641893a9bd6ac662e72 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 18 Apr 2021 09:29:05 +0300 Subject: [PATCH] vm_native: supply only one madvise flag at a time --- rpcs3/util/vm_native.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/vm_native.cpp b/rpcs3/util/vm_native.cpp index da625f937f..f23064328f 100644 --- a/rpcs3/util/vm_native.cpp +++ b/rpcs3/util/vm_native.cpp @@ -160,6 +160,10 @@ namespace utils { ensure(::madvise(ptr, orig_size, c_madv_no_dump) != -1); } + else + { + ensure(::madvise(ptr, orig_size, c_madv_free) != -1); + } return ptr; #endif @@ -172,7 +176,15 @@ namespace utils #else const u64 ptr64 = reinterpret_cast(pointer); ensure(::mprotect(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), +prot) != -1); - ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED | c_madv_dump) != -1); + + if constexpr (c_madv_dump != 0) + { + ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), c_madv_dump) != -1); + } + else + { + ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED) != -1); + } #endif } @@ -188,6 +200,10 @@ namespace utils { ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), c_madv_no_dump) != -1); } + else + { + ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), c_madv_free) != -1); + } #endif } @@ -208,7 +224,14 @@ namespace utils } } - ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED | c_madv_dump) != -1); + if constexpr (c_madv_dump != 0) + { + ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), c_madv_dump) != -1); + } + else + { + ensure(::madvise(reinterpret_cast(ptr64 & -4096), size + (ptr64 & 4095), MADV_WILLNEED) != -1); + } #endif }