File 0749-erts-Stop-using-MADV_DONTNEED-when-MADV_FREE-is-unav.patch of Package erlang

From 9eecebb81b8713093460aef7f9c64e7c822c9f93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Mon, 25 Jan 2021 09:33:15 +0100
Subject: [PATCH] erts: Stop using MADV_DONTNEED when MADV_FREE is unavailable

---
 erts/emulator/sys/common/erl_mmap.h | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/erts/emulator/sys/common/erl_mmap.h b/erts/emulator/sys/common/erl_mmap.h
index fac638c7d1..7a3fdd0aa9 100644
--- a/erts/emulator/sys/common/erl_mmap.h
+++ b/erts/emulator/sys/common/erl_mmap.h
@@ -208,20 +208,16 @@ ERTS_GLB_INLINE void erts_mem_discard(void *p, UWord size);
     #include <sys/mman.h>
 
     ERTS_GLB_INLINE void erts_mem_discard(void *ptr, UWord size) {
+        /* Note that we don't fall back to MADV_DONTNEED since it promises that
+         * the given region will be zeroed on access, which turned out to be
+         * too much of a performance hit. */
     #ifdef MADV_FREE
-        /* This is preferred as it doesn't necessarily free the pages right
-         * away, which is a bit faster than MADV_DONTNEED. */
         madvise(ptr, size, MADV_FREE);
     #else
-        madvise(ptr, size, MADV_DONTNEED);
+        (void)ptr;
+        (void)size;
     #endif
     }
-#elif defined(HAVE_SYS_MMAN_H) && defined(HAVE_POSIX_MADVISE) && !(defined(__sun) || defined(__sun__))
-    #include <sys/mman.h>
-
-    ERTS_GLB_INLINE void erts_mem_discard(void *ptr, UWord size) {
-        posix_madvise(ptr, size, POSIX_MADV_DONTNEED);
-    }
 #elif defined(_WIN32)
     #include <winbase.h>
 
-- 
2.26.2

openSUSE Build Service is sponsored by