summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-04-13 03:20:58 (GMT)
committerJason Evans <je@fb.com>2012-04-13 03:20:58 (GMT)
commit7ca0fdfb85b2a9fc7a112e158892c098e004385b (patch)
tree6c08126277a935f1cedb9108d25cb2315f2e8c97 /configure.ac
parentd6abcbb14b8d1c8beb1c61bfc5a24cb54578b85c (diff)
downloadjemalloc-7ca0fdfb85b2a9fc7a112e158892c098e004385b.zip
jemalloc-7ca0fdfb85b2a9fc7a112e158892c098e004385b.tar.gz
jemalloc-7ca0fdfb85b2a9fc7a112e158892c098e004385b.tar.bz2
Disable munmap() if it causes VM map holes.
Add a configure test to determine whether common mmap()/munmap() patterns cause VM map holes, and only use munmap() to discard unused chunks if the problem does not exist. Unify the chunk caching for mmap and dss. Fix options processing to limit lg_chunk to be large enough that redzones will always fit.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac67
1 files changed, 67 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 739cfa9..8d20659 100644
--- a/configure.ac
+++ b/configure.ac
@@ -817,6 +817,73 @@ else
AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
fi
+dnl Determine whether common sequences of mmap()/munmap() calls will leave
+dnl semi-permanent VM map holes. If so, disable munmap.
+AC_CACHE_CHECK([whether munmap() leaves semi-permanent VM map holes],
+ [je_cv_vmmap_hole],
+ AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+
+#define NPTRS 11
+#define MMAP_SIZE ((size_t)(1U << 22))
+
+static void *
+do_mmap(size_t size)
+{
+ void *ret;
+
+ ret = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1,
+ 0);
+ if (ret == MAP_FAILED) {
+ fprintf(stderr, "mmap() error\n");
+ exit(1);
+ }
+
+ return (ret);
+}
+
+static void
+do_munmap(void *ptr, size_t size)
+{
+ if (munmap(ptr, size) == -1) {
+ fprintf(stderr, "munmap() error\n");
+ exit(1);
+ }
+}
+]],
+[[
+ void *p0, *p1, *p2, *p3, *p4;
+ FILE *f;
+
+ f = fopen("conftest.out", "w");
+ if (f == NULL)
+ exit(1);
+
+ p0 = do_mmap(MMAP_SIZE);
+ p1 = do_mmap(MMAP_SIZE);
+ p2 = do_mmap(MMAP_SIZE);
+ do_munmap(p1, MMAP_SIZE);
+ p3 = do_mmap(MMAP_SIZE * 2);
+ do_munmap(p3, MMAP_SIZE * 2);
+ p4 = do_mmap(MMAP_SIZE);
+ if (p4 != p1) {
+ fprintf(stderr, "Hoped for %p, got %p\n", p1, p4);
+ fprintf(stderr, "%p..%p..%p..%p..%p\n", p0, p1, p2, p3, p4);
+ fprintf(f, "yes\n");
+ } else
+ fprintf(f, "no\n");
+
+ fclose(f);
+ return (0);
+]])],
+ [je_cv_vmmap_hole=`cat conftest.out`],
+ [je_cv_vmmap_hole=unknown]))
+if test "x$je_cv_vmmap_hole" = "xno" ; then
+ AC_DEFINE([JEMALLOC_MUNMAP], [ ])
+fi
+
dnl ============================================================================
dnl jemalloc configuration.
dnl