[PATCH] D40666: [sanitizer] Use MADV_FREE on Darwin/BSD to release pages to the OS

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 14:48:03 PST 2017


kubamracek updated this revision to Diff 125030.
kubamracek edited the summary of this revision.

https://reviews.llvm.org/D40666

Files:
  lib/sanitizer_common/sanitizer_platform.h
  lib/sanitizer_common/sanitizer_posix_libcdep.cc


Index: lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -62,7 +62,8 @@
   uptr beg_aligned = RoundUpTo(beg, page_size);
   uptr end_aligned = RoundDownTo(end, page_size);
   if (beg_aligned < end_aligned)
-    madvise((void*)beg_aligned, end_aligned - beg_aligned, MADV_DONTNEED);
+    madvise((void *)beg_aligned, end_aligned - beg_aligned,
+            SANITIZER_MADVISE_DONTNEED);
 }
 
 void NoHugePagesInRegion(uptr addr, uptr size) {
Index: lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform.h
+++ lib/sanitizer_common/sanitizer_platform.h
@@ -282,5 +282,10 @@
 # define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 0
 #endif
 
+#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+# define SANITIZER_MADVISE_DONTNEED MADV_FREE
+#else
+# define SANITIZER_MADVISE_DONTNEED MADV_DONTNEED
+#endif
 
 #endif // SANITIZER_PLATFORM_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40666.125030.patch
Type: text/x-patch
Size: 1112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/a0420f65/attachment.bin>


More information about the llvm-commits mailing list