diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-02-19 09:16:19 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-02-19 09:16:19 +0100 |
| commit | 6f9d025ad2eafdaedc636531db256e4f4649b8d9 (patch) | |
| tree | 1e5ad7db2e20a86f8ca7fe5e36c7814d07637f4e /src/common | |
| parent | ab129cf314f631d9c71ca264ef55a57d36e5b882 (diff) | |
[host_memory] avoid doing madvise(2) syscall for a simple memset op (#3108)
Signed-off-by: lizzie lizzie@eden-emu.dev
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3108
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/host_memory.cpp | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index a1e99a4c9d..a75152eec0 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -219,11 +219,6 @@ public: } } - bool ClearBackingRegion(size_t physical_offset, size_t length) { - // TODO: This does not seem to be possible on Windows. - return false; - } - void EnableDirectMappedAddress() { // TODO UNREACHABLE(); @@ -617,24 +612,6 @@ public: ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno)); } - bool ClearBackingRegion(size_t physical_offset, size_t length) { -#ifdef __linux__ - // Only incur syscall cost IF memset would be slower (theshold = 16MiB) - // TODO(lizzie): Smarter way to dynamically get this threshold (broadwell != raptor lake) for example - if (length >= 2097152UL * 8) { - // Set MADV_REMOVE on backing map to destroy it instantly. - // This also deletes the area from the backing file. - int ret = madvise(backing_base + physical_offset, length, MADV_REMOVE); - ASSERT_MSG(ret == 0, "madvise failed: {}", strerror(errno)); - return true; - } else { - return false; - } -#else - return false; -#endif - } - void EnableDirectMappedAddress() { virtual_base = nullptr; } @@ -748,9 +725,7 @@ void HostMemory::Protect(size_t virtual_offset, size_t length, MemoryPermission } void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 fill_value) { - if (!impl || fill_value != 0 || !impl->ClearBackingRegion(physical_offset, length)) { - std::memset(backing_base + physical_offset, fill_value, length); - } + std::memset(backing_base + physical_offset, fill_value, length); } void HostMemory::EnableDirectMappedAddress() { |
