aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-11-17 10:24:51 -0800
committerJason Evans <jasone@canonware.com>2016-11-17 10:37:48 -0800
commit62f2d84e7aebaa25df32a0ae882cc856e5218687 (patch)
tree5a07f5969ccc5b761f6f00c3b928a9acb52a8a18 /include
parente7ca53bac2dbd281779b431b6ab29e9c39984256 (diff)
downloadjemalloc-62f2d84e7aebaa25df32a0ae882cc856e5218687.tar.gz
Refactor madvise(2) configuration.
Add feature tests for the MADV_FREE and MADV_DONTNEED flags to madvise(2), so that MADV_FREE is detected and used for Linux kernel versions 4.5 and newer. Refactor pages_purge() so that on systems which support both flags, MADV_FREE is preferred over MADV_DONTNEED. This resolves #387.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/jemalloc_internal_defs.h.in21
1 files changed, 9 insertions, 12 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in
index 9b3dca5..5419513 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h.in
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in
@@ -56,11 +56,6 @@
#undef JEMALLOC_HAVE_BUILTIN_CLZ
/*
- * Defined if madvise(2) is available.
- */
-#undef JEMALLOC_HAVE_MADVISE
-
-/*
* Defined if os_unfair_lock_*() functions are available, as provided by Darwin.
*/
#undef JEMALLOC_OS_UNFAIR_LOCK
@@ -252,18 +247,20 @@
#undef JEMALLOC_SYSCTL_VM_OVERCOMMIT
#undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY
+/* Defined if madvise(2) is available. */
+#undef JEMALLOC_HAVE_MADVISE
+
/*
* Methods for purging unused pages differ between operating systems.
*
- * madvise(..., MADV_DONTNEED) : On Linux, this immediately discards pages,
- * such that new pages will be demand-zeroed if
- * the address region is later touched.
- * madvise(..., MADV_FREE) : On FreeBSD and Darwin, this marks pages as being
- * unused, such that they will be discarded rather
- * than swapped out.
+ * madvise(..., MADV_FREE) : This marks pages as being unused, such that they
+ * will be discarded rather than swapped out.
+ * madvise(..., MADV_DONTNEED) : This immediately discards pages, such that
+ * new pages will be demand-zeroed if the
+ * address region is later touched.
*/
-#undef JEMALLOC_PURGE_MADVISE_DONTNEED
#undef JEMALLOC_PURGE_MADVISE_FREE
+#undef JEMALLOC_PURGE_MADVISE_DONTNEED
/* Define if operating system has alloca.h header. */
#undef JEMALLOC_HAS_ALLOCA_H