]> git.saurik.com Git - redis.git/commitdiff
Update to jemalloc 2.2.5
authorjbergstroem <bugs@bergstroem.nu>
Wed, 23 Nov 2011 20:36:25 +0000 (21:36 +0100)
committerjbergstroem <bugs@bergstroem.nu>
Wed, 23 Nov 2011 20:36:25 +0000 (21:36 +0100)
24 files changed:
deps/jemalloc/ChangeLog
deps/jemalloc/INSTALL
deps/jemalloc/Makefile.in
deps/jemalloc/VERSION
deps/jemalloc/configure
deps/jemalloc/configure.ac
deps/jemalloc/doc/jemalloc.3
deps/jemalloc/doc/jemalloc.html
deps/jemalloc/doc/jemalloc.xml.in
deps/jemalloc/include/jemalloc/internal/chunk.h
deps/jemalloc/include/jemalloc/internal/hash.h
deps/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in
deps/jemalloc/include/jemalloc/internal/private_namespace.h [new file with mode: 0644]
deps/jemalloc/include/jemalloc/internal/prof.h
deps/jemalloc/include/jemalloc/jemalloc_defs.h.in
deps/jemalloc/src/arena.c
deps/jemalloc/src/chunk.c
deps/jemalloc/src/ckh.c
deps/jemalloc/src/ctl.c
deps/jemalloc/src/huge.c
deps/jemalloc/src/jemalloc.c
deps/jemalloc/src/prof.c
deps/jemalloc/src/stats.c
deps/jemalloc/test/rallocm.c

index 7b262c9590b16a5ad21fcc2c9e74ace4c7d39b0f..326ee7a97e1e9e3d4607347fb94a7386c90940d9 100644 (file)
@@ -6,6 +6,43 @@ found in the git revision history:
     http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git
     git://canonware.com/jemalloc.git
 
     http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git
     git://canonware.com/jemalloc.git
 
+* 2.2.5 (November 14, 2011)
+
+  Bug fixes:
+  - Fix huge_ralloc() race when using mremap(2).  This is a serious bug that
+    could cause memory corruption and/or crashes.
+  - Fix huge_ralloc() to maintain chunk statistics.
+  - Fix malloc_stats_print(..., "a") output.
+
+* 2.2.4 (November 5, 2011)
+
+  Bug fixes:
+  - Initialize arenas_tsd before using it.  This bug existed for 2.2.[0-3], as
+    well as for --disable-tls builds in earlier releases.
+  - Do not assume a 4 KiB page size in test/rallocm.c.
+
+* 2.2.3 (August 31, 2011)
+
+  This version fixes numerous bugs related to heap profiling.
+
+  Bug fixes:
+  - Fix a prof-related race condition.  This bug could cause memory corruption,
+    but only occurred in non-default configurations (prof_accum:false).
+  - Fix off-by-one backtracing issues (make sure that prof_alloc_prep() is
+    excluded from backtraces).
+  - Fix a prof-related bug in realloc() (only triggered by OOM errors).
+  - Fix prof-related bugs in allocm() and rallocm().
+  - Fix prof_tdata_cleanup() for --disable-tls builds.
+  - Fix a relative include path, to fix objdir builds.
+
+* 2.2.2 (July 30, 2011)
+
+  Bug fixes:
+  - Fix a build error for --disable-tcache.
+  - Fix assertions in arena_purge() (for real this time).
+  - Add the --with-private-namespace option.  This is a workaround for symbol
+    conflicts that can inadvertently arise when using static libraries.
+
 * 2.2.1 (March 30, 2011)
 
   Bug fixes:
 * 2.2.1 (March 30, 2011)
 
   Bug fixes:
index 11a457aeb1f83b85c5e8ef1ad773b599bce7490b..2a1e469cb8b01a81758e16cf31bb8fe0cb0f6bbe 100644 (file)
@@ -42,6 +42,12 @@ any of the following arguments (not a definitive list) to 'configure':
     jemalloc overlays the default malloc zone, but makes no attempt to actually
     replace the "malloc", "calloc", etc. symbols.
 
     jemalloc overlays the default malloc zone, but makes no attempt to actually
     replace the "malloc", "calloc", etc. symbols.
 
+--with-private-namespace=<prefix>
+    Prefix all library-private APIs with <prefix>.  For shared libraries,
+    symbol visibility mechanisms prevent these symbols from being exported, but
+    for static libraries, naming collisions are a real possibility.  By
+    default, the prefix is "" (empty string).
+
 --with-install-suffix=<suffix>
     Append <suffix> to the base name of all installed files, such that multiple
     versions of jemalloc can coexist in the same installation directory.  For
 --with-install-suffix=<suffix>
     Append <suffix> to the base name of all installed files, such that multiple
     versions of jemalloc can coexist in the same installation directory.  For
index 26da0e28b26d67bc8c938c7b5364cc53ac3d3d2c..de7492f951aa2e91e89dc324a269feb9072b9d97 100644 (file)
@@ -136,9 +136,9 @@ doc: $(DOCS)
                 @objroot@lib/libjemalloc@install_suffix@.$(SO)
        @mkdir -p $(@D)
 ifneq (@RPATH@, )
                 @objroot@lib/libjemalloc@install_suffix@.$(SO)
        @mkdir -p $(@D)
 ifneq (@RPATH@, )
-       $(CC) -o $@ $< @RPATH@@objroot@lib -L@objroot@lib -ljemalloc@install_suffix@
+       $(CC) -o $@ $< @RPATH@@objroot@lib -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
 else
 else
-       $(CC) -o $@ $< -L@objroot@lib -ljemalloc@install_suffix@
+       $(CC) -o $@ $< -L@objroot@lib -ljemalloc@install_suffix@ -lpthread
 endif
 
 install_bin:
 endif
 
 install_bin:
index 7de6608e50c4b91c1d50c50cdf07ca564f242b78..aa85f5a2acfe3667b11500f2e7452c108846ca00 100644 (file)
@@ -1 +1 @@
-2.2.1-0-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862
+2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760
index b9877e4655fe6fbd279920483994e958454a2667..610884fb3235ac3fc0afe9ef9c9e9ddc68af9440 100755 (executable)
@@ -617,8 +617,6 @@ enable_prof
 enable_stats
 enable_debug
 install_suffix
 enable_stats
 enable_debug
 install_suffix
-jemalloc_cprefix
-jemalloc_prefix
 AUTOCONF
 LD
 AR
 AUTOCONF
 LD
 AR
@@ -705,6 +703,7 @@ with_xslroot
 with_rpath
 enable_autogen
 with_jemalloc_prefix
 with_rpath
 enable_autogen
 with_jemalloc_prefix
+with_private_namespace
 with_install_suffix
 enable_cc_silence
 enable_debug
 with_install_suffix
 enable_cc_silence
 enable_debug
@@ -1375,6 +1374,8 @@ Optional Packages:
   --with-rpath=<rpath>    Colon-separated rpath (ELF systems only)
   --with-jemalloc-prefix=<prefix>
                           Prefix to prepend to all public APIs
   --with-rpath=<rpath>    Colon-separated rpath (ELF systems only)
   --with-jemalloc-prefix=<prefix>
                           Prefix to prepend to all public APIs
+  --with-private-namespace=<prefix>
+                          Prefix to prepend to all library-private APIs
   --with-install-suffix=<suffix>
                           Suffix to append to all installed files
   --with-static-libunwind=<libunwind.a>
   --with-install-suffix=<suffix>
                           Suffix to append to all installed files
   --with-static-libunwind=<libunwind.a>
@@ -4800,12 +4801,33 @@ _ACEOF
 #define JEMALLOC_CPREFIX "$JEMALLOC_CPREFIX"
 _ACEOF
 
 #define JEMALLOC_CPREFIX "$JEMALLOC_CPREFIX"
 _ACEOF
 
-  jemalloc_prefix="$JEMALLOC_PREFIX"
-  jemalloc_cprefix="$JEMALLOC_CPREFIX"
+  cat >>confdefs.h <<_ACEOF
+#define JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix) ${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix
+_ACEOF
+
+fi
 
 
 
 
+# Check whether --with-private_namespace was given.
+if test "${with_private_namespace+set}" = set; then :
+  withval=$with_private_namespace; JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"
+else
+  JEMALLOC_PRIVATE_NAMESPACE=""
+
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define JEMALLOC_PRIVATE_NAMESPACE "$JEMALLOC_PRIVATE_NAMESPACE"
+_ACEOF
+
+if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
   cat >>confdefs.h <<_ACEOF
   cat >>confdefs.h <<_ACEOF
-#define JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix) ${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix
+#define JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix) ${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix
+_ACEOF
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix) string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix
 _ACEOF
 
 fi
 _ACEOF
 
 fi
@@ -5508,7 +5530,7 @@ fi
 
 
 
 
 
 
-if test -d "${srcroot}../.git" ; then
+if test -d "${srcroot}.git" ; then
   git describe --long --abbrev=40 > ${srcroot}VERSION
 fi
 jemalloc_version=`cat ${srcroot}VERSION`
   git describe --long --abbrev=40 > ${srcroot}VERSION
 fi
 jemalloc_version=`cat ${srcroot}VERSION`
@@ -7346,6 +7368,10 @@ $as_echo "abs_objroot        : ${abs_objroot}" >&6; }
 $as_echo "" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}" >&5
 $as_echo "JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}" >&6; }
 $as_echo "" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}" >&5
 $as_echo "JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: JEMALLOC_PRIVATE_NAMESPACE" >&5
+$as_echo "JEMALLOC_PRIVATE_NAMESPACE" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result:                    : ${JEMALLOC_PRIVATE_NAMESPACE}" >&5
+$as_echo "                   : ${JEMALLOC_PRIVATE_NAMESPACE}" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: install_suffix     : ${install_suffix}" >&5
 $as_echo "install_suffix     : ${install_suffix}" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: autogen            : ${enable_autogen}" >&5
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: install_suffix     : ${install_suffix}" >&5
 $as_echo "install_suffix     : ${install_suffix}" >&6; }
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: autogen            : ${enable_autogen}" >&5
index 412d3d1b006eec9fa0931bdddfe2ec84c2be9a8f..b58aa520998c316ca1b57c73f3c1bba679d99040 100644 (file)
@@ -292,13 +292,22 @@ if test "x$JEMALLOC_PREFIX" != "x" ; then
   JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
   AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
   AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
   JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
   AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
   AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
-  jemalloc_prefix="$JEMALLOC_PREFIX"
-  jemalloc_cprefix="$JEMALLOC_CPREFIX"
-  AC_SUBST([jemalloc_prefix])
-  AC_SUBST([jemalloc_cprefix])
   AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
 fi
 
   AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
 fi
 
+dnl Do not mangle library-private APIs by default.
+AC_ARG_WITH([private_namespace],
+  [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
+  [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
+  [JEMALLOC_PRIVATE_NAMESPACE=""]
+)
+AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
+if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
+  AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
+else
+  AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
+fi
+
 dnl Do not add suffix to installed files by default.
 AC_ARG_WITH([install_suffix],
   [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
 dnl Do not add suffix to installed files by default.
 AC_ARG_WITH([install_suffix],
   [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
@@ -688,7 +697,7 @@ dnl jemalloc configuration.
 dnl 
 
 dnl Set VERSION if source directory has an embedded git repository.
 dnl 
 
 dnl Set VERSION if source directory has an embedded git repository.
-if test -d "${srcroot}../.git" ; then
+if test -d "${srcroot}.git" ; then
   git describe --long --abbrev=40 > ${srcroot}VERSION
 fi
 jemalloc_version=`cat ${srcroot}VERSION`
   git describe --long --abbrev=40 > ${srcroot}VERSION
 fi
 jemalloc_version=`cat ${srcroot}VERSION`
@@ -905,6 +914,8 @@ AC_MSG_RESULT([objroot            : ${objroot}])
 AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
 AC_MSG_RESULT([])
 AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
 AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
 AC_MSG_RESULT([])
 AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
+AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
+AC_MSG_RESULT([                   : ${JEMALLOC_PRIVATE_NAMESPACE}])
 AC_MSG_RESULT([install_suffix     : ${install_suffix}])
 AC_MSG_RESULT([autogen            : ${enable_autogen}])
 AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
 AC_MSG_RESULT([install_suffix     : ${install_suffix}])
 AC_MSG_RESULT([autogen            : ${enable_autogen}])
 AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
index f29c01de0cc251117cfe29c77f2be693f10dce7d..0401cfe895e22b6b8e66b03d93ea965da9cbb1f9 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: JEMALLOC
 .\"    Author: Jason Evans
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
 .\"     Title: JEMALLOC
 .\"    Author: Jason Evans
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\"      Date: 03/30/2011
+.\"      Date: 11/14/2011
 .\"    Manual: User Manual
 .\"    Manual: User Manual
-.\"    Source: jemalloc 2.2.1-0-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862
+.\"    Source: jemalloc 2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760
 .\"  Language: English
 .\"
 .\"  Language: English
 .\"
-.TH "JEMALLOC" "3" "03/30/2011" "jemalloc 2.2.1-0-g5ef7abf6d846" "User Manual"
+.TH "JEMALLOC" "3" "11/14/2011" "jemalloc 2.2.5-0-gfc1bb70e5f0d" "User Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
 jemalloc \- general purpose memory allocation functions
 .SH "LIBRARY"
 .PP
 jemalloc \- general purpose memory allocation functions
 .SH "LIBRARY"
 .PP
-This manual describes jemalloc 2\&.2\&.1\-0\-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862\&. More information can be found at the
+This manual describes jemalloc 2\&.2\&.5\-0\-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760\&. More information can be found at the
 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
 .SH "SYNOPSIS"
 .sp
 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
 .SH "SYNOPSIS"
 .sp
@@ -1215,7 +1215,7 @@ is successfully written to\&.
 Number of file descriptors in use for swap\&.
 .RE
 .PP
 Number of file descriptors in use for swap\&.
 .RE
 .PP
-"swap\&.fds" (\fBint *\fR) r\- [\fB\-\-enable\-swap\fR]
+"swap\&.fds" (\fBint *\fR) rw [\fB\-\-enable\-swap\fR]
 .RS 4
 When written to, the files associated with the specified file descriptors are contiguously mapped via
 \fBmmap\fR(2)\&. The resulting virtual memory region is preferred over anonymous
 .RS 4
 When written to, the files associated with the specified file descriptors are contiguously mapped via
 \fBmmap\fR(2)\&. The resulting virtual memory region is preferred over anonymous
index b1ba461be6bd661f524b6eb593139a28e7c8888a..fc2ba878e54370e4d583b067aa80833c56e40cad 100644 (file)
@@ -1,8 +1,8 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>JEMALLOC</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="JEMALLOC"><a name="id2783946"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>jemalloc &#8212; general purpose memory allocation functions</p></div><div class="refsect1" title="LIBRARY"><a name="library"></a><h2>LIBRARY</h2><p>This manual describes jemalloc 2.2.1-0-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862.  More information
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>JEMALLOC</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="JEMALLOC"><a name="id2968890"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>jemalloc &#8212; general purpose memory allocation functions</p></div><div class="refsect1" title="LIBRARY"><a name="library"></a><h2>LIBRARY</h2><p>This manual describes jemalloc 2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760.  More information
     can be found at the <a class="ulink" href="http://www.canonware.com/jemalloc/" target="_top">jemalloc website</a>.</p></div><div class="refsynopsisdiv" title="SYNOPSIS"><h2>SYNOPSIS</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;<code class="filename">stdlib.h</code>&gt;
     can be found at the <a class="ulink" href="http://www.canonware.com/jemalloc/" target="_top">jemalloc website</a>.</p></div><div class="refsynopsisdiv" title="SYNOPSIS"><h2>SYNOPSIS</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;<code class="filename">stdlib.h</code>&gt;
-#include &lt;<code class="filename">jemalloc/jemalloc.h</code>&gt;</pre><div class="refsect2" title="Standard API"><a name="id2830421"></a><h3>Standard API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">malloc</b>(</code></td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">calloc</b>(</code></td><td>size_t <var class="pdparam">number</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">posix_memalign</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">alignment</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">realloc</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">free</b>(</code></td><td>void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="refsect2" title="Non-standard API"><a name="id2837717"></a><h3>Non-standard API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">size_t <b class="fsfunc">malloc_usable_size</b>(</code></td><td>const void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">malloc_stats_print</b>(</code></td><td>void <var class="pdparam">(*write_cb)</var>
+#include &lt;<code class="filename">jemalloc/jemalloc.h</code>&gt;</pre><div class="refsect2" title="Standard API"><a name="id2992781"></a><h3>Standard API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">malloc</b>(</code></td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">calloc</b>(</code></td><td>size_t <var class="pdparam">number</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">posix_memalign</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">alignment</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">realloc</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">free</b>(</code></td><td>void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="refsect2" title="Non-standard API"><a name="id2998350"></a><h3>Non-standard API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">size_t <b class="fsfunc">malloc_usable_size</b>(</code></td><td>const void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">malloc_stats_print</b>(</code></td><td>void <var class="pdparam">(*write_cb)</var>
             <code>(</code>void *, const char *<code>)</code>
             <code>(</code>void *, const char *<code>)</code>
-          , </td></tr><tr><td> </td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">opts</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctl</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlnametomib</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">mibp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">miblenp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlbymib</b>(</code></td><td>const size_t *<var class="pdparam">mib</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">miblen</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">(*malloc_message)</b>(</code></td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">s</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><p><span class="type">const char *</span><code class="varname">malloc_conf</code>;</p></div><div class="refsect2" title="Experimental API"><a name="id2830042"></a><h3>Experimental API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">allocm</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">rallocm</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">extra</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">sallocm</b>(</code></td><td>const void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">dallocm</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div></div><div class="refsect1" title="DESCRIPTION"><a name="description"></a><h2>DESCRIPTION</h2><div class="refsect2" title="Standard API"><a name="id2840968"></a><h3>Standard API</h3><p>The <code class="function">malloc</code>(<em class="parameter"><code></code></em>) function allocates
+          , </td></tr><tr><td> </td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">opts</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctl</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlnametomib</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">mibp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">miblenp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlbymib</b>(</code></td><td>const size_t *<var class="pdparam">mib</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">miblen</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">(*malloc_message)</b>(</code></td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">s</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><p><span class="type">const char *</span><code class="varname">malloc_conf</code>;</p></div><div class="refsect2" title="Experimental API"><a name="id3014125"></a><h3>Experimental API</h3><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">allocm</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">rallocm</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">extra</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">sallocm</b>(</code></td><td>const void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">rsize</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">dallocm</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div></div><div class="refsect1" title="DESCRIPTION"><a name="description"></a><h2>DESCRIPTION</h2><div class="refsect2" title="Standard API"><a name="id3014924"></a><h3>Standard API</h3><p>The <code class="function">malloc</code>(<em class="parameter"><code></code></em>) function allocates
       <em class="parameter"><code>size</code></em> bytes of uninitialized memory.  The allocated
       space is suitably aligned (after possible pointer coercion) for storage
       of any type of object.</p><p>The <code class="function">calloc</code>(<em class="parameter"><code></code></em>) function allocates
       <em class="parameter"><code>size</code></em> bytes of uninitialized memory.  The allocated
       space is suitably aligned (after possible pointer coercion) for storage
       of any type of object.</p><p>The <code class="function">calloc</code>(<em class="parameter"><code></code></em>) function allocates
@@ -32,7 +32,7 @@
       <code class="function">malloc</code>(<em class="parameter"><code></code></em>) for the specified size.</p><p>The <code class="function">free</code>(<em class="parameter"><code></code></em>) function causes the
       allocated memory referenced by <em class="parameter"><code>ptr</code></em> to be made
       available for future allocations.  If <em class="parameter"><code>ptr</code></em> is
       <code class="function">malloc</code>(<em class="parameter"><code></code></em>) for the specified size.</p><p>The <code class="function">free</code>(<em class="parameter"><code></code></em>) function causes the
       allocated memory referenced by <em class="parameter"><code>ptr</code></em> to be made
       available for future allocations.  If <em class="parameter"><code>ptr</code></em> is
-      <code class="constant">NULL</code>, no action occurs.</p></div><div class="refsect2" title="Non-standard API"><a name="id2827225"></a><h3>Non-standard API</h3><p>The <code class="function">malloc_usable_size</code>(<em class="parameter"><code></code></em>) function
+      <code class="constant">NULL</code>, no action occurs.</p></div><div class="refsect2" title="Non-standard API"><a name="id3025603"></a><h3>Non-standard API</h3><p>The <code class="function">malloc_usable_size</code>(<em class="parameter"><code></code></em>) function
       returns the usable size of the allocation pointed to by
       <em class="parameter"><code>ptr</code></em>.  The return value may be larger than the size
       that was requested during allocation.  The
       returns the usable size of the allocation pointed to by
       <em class="parameter"><code>ptr</code></em>.  The return value may be larger than the size
       that was requested during allocation.  The
@@ -112,7 +112,7 @@ for (i = 0; i &lt; nbins; i++) {
        len = sizeof(bin_size);
        mallctlbymib(mib, miblen, &amp;bin_size, &amp;len, NULL, 0);
        /* Do something with bin_size... */
        len = sizeof(bin_size);
        mallctlbymib(mib, miblen, &amp;bin_size, &amp;len, NULL, 0);
        /* Do something with bin_size... */
-}</pre></div><div class="refsect2" title="Experimental API"><a name="id2807945"></a><h3>Experimental API</h3><p>The experimental API is subject to change or removal without regard
+}</pre></div><div class="refsect2" title="Experimental API"><a name="id3013809"></a><h3>Experimental API</h3><p>The experimental API is subject to change or removal without regard
       for backward compatibility.</p><p>The <code class="function">allocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">rallocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">sallocm</code>(<em class="parameter"><code></code></em>), and
       for backward compatibility.</p><p>The <code class="function">allocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">rallocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">sallocm</code>(<em class="parameter"><code></code></em>), and
@@ -1397,7 +1397,7 @@ malloc_conf = "xmalloc:true";</pre><p>
     "<code class="mallctl">swap.fds</code>"
   
           (<span class="type">int *</span>)
     "<code class="mallctl">swap.fds</code>"
   
           (<span class="type">int *</span>)
-          <code class="literal">r-</code>
+          <code class="literal">rw</code>
           [<code class="option">--enable-swap</code>]
         </span></dt><dd><p>When written to, the files associated with the
         specified file descriptors are contiguously mapped via
           [<code class="option">--enable-swap</code>]
         </span></dt><dd><p>When written to, the files associated with the
         specified file descriptors are contiguously mapped via
@@ -1447,7 +1447,7 @@ malloc_conf = "xmalloc:true";</pre><p>
     <code class="function">malloc_stats_print</code>(<em class="parameter"><code></code></em>), followed by a string
     pointer.  Please note that doing anything which tries to allocate memory in
     this function is likely to result in a crash or deadlock.</p><p>All messages are prefixed by
     <code class="function">malloc_stats_print</code>(<em class="parameter"><code></code></em>), followed by a string
     pointer.  Please note that doing anything which tries to allocate memory in
     this function is likely to result in a crash or deadlock.</p><p>All messages are prefixed by
-    &#8220;<code class="computeroutput">&lt;jemalloc&gt;: </code>&#8221;.</p></div><div class="refsect1" title="RETURN VALUES"><a name="return_values"></a><h2>RETURN VALUES</h2><div class="refsect2" title="Standard API"><a name="id2844722"></a><h3>Standard API</h3><p>The <code class="function">malloc</code>(<em class="parameter"><code></code></em>) and
+    &#8220;<code class="computeroutput">&lt;jemalloc&gt;: </code>&#8221;.</p></div><div class="refsect1" title="RETURN VALUES"><a name="return_values"></a><h2>RETURN VALUES</h2><div class="refsect2" title="Standard API"><a name="id3029250"></a><h3>Standard API</h3><p>The <code class="function">malloc</code>(<em class="parameter"><code></code></em>) and
       <code class="function">calloc</code>(<em class="parameter"><code></code></em>) functions return a pointer to the
       allocated memory if successful; otherwise a <code class="constant">NULL</code>
       pointer is returned and <code class="varname">errno</code> is set to
       <code class="function">calloc</code>(<em class="parameter"><code></code></em>) functions return a pointer to the
       allocated memory if successful; otherwise a <code class="constant">NULL</code>
       pointer is returned and <code class="varname">errno</code> is set to
@@ -1467,7 +1467,7 @@ malloc_conf = "xmalloc:true";</pre><p>
       allocation failure.  The <code class="function">realloc</code>(<em class="parameter"><code></code></em>)
       function always leaves the original buffer intact when an error occurs.
       </p><p>The <code class="function">free</code>(<em class="parameter"><code></code></em>) function returns no
       allocation failure.  The <code class="function">realloc</code>(<em class="parameter"><code></code></em>)
       function always leaves the original buffer intact when an error occurs.
       </p><p>The <code class="function">free</code>(<em class="parameter"><code></code></em>) function returns no
-      value.</p></div><div class="refsect2" title="Non-standard API"><a name="id2844875"></a><h3>Non-standard API</h3><p>The <code class="function">malloc_usable_size</code>(<em class="parameter"><code></code></em>) function
+      value.</p></div><div class="refsect2" title="Non-standard API"><a name="id3029403"></a><h3>Non-standard API</h3><p>The <code class="function">malloc_usable_size</code>(<em class="parameter"><code></code></em>) function
       returns the usable size of the allocation pointed to by
       <em class="parameter"><code>ptr</code></em>.  </p><p>The <code class="function">mallctl</code>(<em class="parameter"><code></code></em>),
       <code class="function">mallctlnametomib</code>(<em class="parameter"><code></code></em>), and
       returns the usable size of the allocation pointed to by
       <em class="parameter"><code>ptr</code></em>.  </p><p>The <code class="function">mallctl</code>(<em class="parameter"><code></code></em>),
       <code class="function">mallctlnametomib</code>(<em class="parameter"><code></code></em>), and
@@ -1486,7 +1486,7 @@ malloc_conf = "xmalloc:true";</pre><p>
             occurred.</p></dd><dt><span class="term"><span class="errorname">EFAULT</span></span></dt><dd><p>An interface with side effects failed in some way
             not directly related to <code class="function">mallctl*</code>(<em class="parameter"><code></code></em>)
             read/write processing.</p></dd></dl></div><p>
             occurred.</p></dd><dt><span class="term"><span class="errorname">EFAULT</span></span></dt><dd><p>An interface with side effects failed in some way
             not directly related to <code class="function">mallctl*</code>(<em class="parameter"><code></code></em>)
             read/write processing.</p></dd></dl></div><p>
-      </p></div><div class="refsect2" title="Experimental API"><a name="id2845053"></a><h3>Experimental API</h3><p>The <code class="function">allocm</code>(<em class="parameter"><code></code></em>),
+      </p></div><div class="refsect2" title="Experimental API"><a name="id3029581"></a><h3>Experimental API</h3><p>The <code class="function">allocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">rallocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">sallocm</code>(<em class="parameter"><code></code></em>), and
       <code class="function">dallocm</code>(<em class="parameter"><code></code></em>) functions return
       <code class="function">rallocm</code>(<em class="parameter"><code></code></em>),
       <code class="function">sallocm</code>(<em class="parameter"><code></code></em>), and
       <code class="function">dallocm</code>(<em class="parameter"><code></code></em>) functions return
index 13f3aae049ab39cecdd591e07e8a6672f75dfd12..7a32879abee7afaf0510bccc179dfad59e3cb130 100644 (file)
@@ -2025,7 +2025,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
         <term>
           <mallctl>swap.fds</mallctl>
           (<type>int *</type>)
         <term>
           <mallctl>swap.fds</mallctl>
           (<type>int *</type>)
-          <literal>r-</literal>
+          <literal>rw</literal>
           [<option>--enable-swap</option>]
         </term>
         <listitem><para>When written to, the files associated with the
           [<option>--enable-swap</option>]
         </term>
         <listitem><para>When written to, the files associated with the
index a60f0ad7498d5c68d3491bb0dc53629fd17ecc52..54b6a3ec886780587efa2a0d81d326d4ebf93ad9 100644 (file)
@@ -50,7 +50,7 @@ extern size_t         map_bias; /* Number of arena chunk header pages. */
 extern size_t          arena_maxclass; /* Max size class for arenas. */
 
 void   *chunk_alloc(size_t size, bool base, bool *zero);
 extern size_t          arena_maxclass; /* Max size class for arenas. */
 
 void   *chunk_alloc(size_t size, bool base, bool *zero);
-void   chunk_dealloc(void *chunk, size_t size);
+void   chunk_dealloc(void *chunk, size_t size, bool unmap);
 bool   chunk_boot(void);
 
 #endif /* JEMALLOC_H_EXTERNS */
 bool   chunk_boot(void);
 
 #endif /* JEMALLOC_H_EXTERNS */
index 93905bf8de6b9451b85b565d71ccc36261cbbc2e..8a46ce30803aef2518bccbed0c0151182af7a066 100644 (file)
@@ -26,7 +26,7 @@ uint64_t      hash(const void *key, size_t len, uint64_t seed);
 JEMALLOC_INLINE uint64_t
 hash(const void *key, size_t len, uint64_t seed)
 {
 JEMALLOC_INLINE uint64_t
 hash(const void *key, size_t len, uint64_t seed)
 {
-       const uint64_t m = 0xc6a4a7935bd1e995;
+       const uint64_t m = 0xc6a4a7935bd1e995LLU;
        const int r = 47;
        uint64_t h = seed ^ (len * m);
        const uint64_t *data = (const uint64_t *)key;
        const int r = 47;
        uint64_t h = seed ^ (len * m);
        const uint64_t *data = (const uint64_t *)key;
index 0dd9995cfe7779f639b7d9fa216b7b83ed0ec99a..a44f0978ae477a7a028ba481c37530a5c60458fc 100644 (file)
@@ -33,6 +33,8 @@
 #define        JEMALLOC_MANGLE
 #include "../jemalloc@install_suffix@.h"
 
 #define        JEMALLOC_MANGLE
 #include "../jemalloc@install_suffix@.h"
 
+#include "jemalloc/internal/private_namespace.h"
+
 #if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN))
 #include <libkern/OSAtomic.h>
 #endif
 #if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN))
 #include <libkern/OSAtomic.h>
 #endif
@@ -633,7 +635,11 @@ ipalloc(size_t usize, size_t alignment, bool zero)
        if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
                ret = arena_malloc(usize, zero);
        else {
        if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
                ret = arena_malloc(usize, zero);
        else {
-               size_t run_size = 0;
+               size_t run_size
+#ifdef JEMALLOC_CC_SILENCE
+                   = 0
+#endif
+                   ;
 
                /*
                 * Ideally we would only ever call sa2u() once per aligned
 
                /*
                 * Ideally we would only ever call sa2u() once per aligned
diff --git a/deps/jemalloc/include/jemalloc/internal/private_namespace.h b/deps/jemalloc/include/jemalloc/internal/private_namespace.h
new file mode 100644 (file)
index 0000000..d4f5f96
--- /dev/null
@@ -0,0 +1,195 @@
+#define        arena_bin_index JEMALLOC_N(arena_bin_index)
+#define        arena_boot JEMALLOC_N(arena_boot)
+#define        arena_dalloc JEMALLOC_N(arena_dalloc)
+#define        arena_dalloc_bin JEMALLOC_N(arena_dalloc_bin)
+#define        arena_dalloc_large JEMALLOC_N(arena_dalloc_large)
+#define        arena_malloc JEMALLOC_N(arena_malloc)
+#define        arena_malloc_large JEMALLOC_N(arena_malloc_large)
+#define        arena_malloc_small JEMALLOC_N(arena_malloc_small)
+#define        arena_new JEMALLOC_N(arena_new)
+#define        arena_palloc JEMALLOC_N(arena_palloc)
+#define        arena_prof_accum JEMALLOC_N(arena_prof_accum)
+#define        arena_prof_ctx_get JEMALLOC_N(arena_prof_ctx_get)
+#define        arena_prof_ctx_set JEMALLOC_N(arena_prof_ctx_set)
+#define        arena_prof_promoted JEMALLOC_N(arena_prof_promoted)
+#define        arena_purge_all JEMALLOC_N(arena_purge_all)
+#define        arena_ralloc JEMALLOC_N(arena_ralloc)
+#define        arena_ralloc_no_move JEMALLOC_N(arena_ralloc_no_move)
+#define        arena_run_regind JEMALLOC_N(arena_run_regind)
+#define        arena_salloc JEMALLOC_N(arena_salloc)
+#define        arena_salloc_demote JEMALLOC_N(arena_salloc_demote)
+#define        arena_stats_merge JEMALLOC_N(arena_stats_merge)
+#define        arena_tcache_fill_small JEMALLOC_N(arena_tcache_fill_small)
+#define        arenas_bin_i_index JEMALLOC_N(arenas_bin_i_index)
+#define        arenas_extend JEMALLOC_N(arenas_extend)
+#define        arenas_lrun_i_index JEMALLOC_N(arenas_lrun_i_index)
+#define        atomic_add_uint32 JEMALLOC_N(atomic_add_uint32)
+#define        atomic_add_uint64 JEMALLOC_N(atomic_add_uint64)
+#define        atomic_sub_uint32 JEMALLOC_N(atomic_sub_uint32)
+#define        atomic_sub_uint64 JEMALLOC_N(atomic_sub_uint64)
+#define        base_alloc JEMALLOC_N(base_alloc)
+#define        base_boot JEMALLOC_N(base_boot)
+#define        base_node_alloc JEMALLOC_N(base_node_alloc)
+#define        base_node_dealloc JEMALLOC_N(base_node_dealloc)
+#define        bitmap_full JEMALLOC_N(bitmap_full)
+#define        bitmap_get JEMALLOC_N(bitmap_get)
+#define        bitmap_info_init JEMALLOC_N(bitmap_info_init)
+#define        bitmap_info_ngroups JEMALLOC_N(bitmap_info_ngroups)
+#define        bitmap_init JEMALLOC_N(bitmap_init)
+#define        bitmap_set JEMALLOC_N(bitmap_set)
+#define        bitmap_sfu JEMALLOC_N(bitmap_sfu)
+#define        bitmap_size JEMALLOC_N(bitmap_size)
+#define        bitmap_unset JEMALLOC_N(bitmap_unset)
+#define        bt_init JEMALLOC_N(bt_init)
+#define        buferror JEMALLOC_N(buferror)
+#define        choose_arena JEMALLOC_N(choose_arena)
+#define        choose_arena_hard JEMALLOC_N(choose_arena_hard)
+#define        chunk_alloc JEMALLOC_N(chunk_alloc)
+#define        chunk_alloc_dss JEMALLOC_N(chunk_alloc_dss)
+#define        chunk_alloc_mmap JEMALLOC_N(chunk_alloc_mmap)
+#define        chunk_alloc_mmap_noreserve JEMALLOC_N(chunk_alloc_mmap_noreserve)
+#define        chunk_alloc_swap JEMALLOC_N(chunk_alloc_swap)
+#define        chunk_boot JEMALLOC_N(chunk_boot)
+#define        chunk_dealloc JEMALLOC_N(chunk_dealloc)
+#define        chunk_dealloc_dss JEMALLOC_N(chunk_dealloc_dss)
+#define        chunk_dealloc_mmap JEMALLOC_N(chunk_dealloc_mmap)
+#define        chunk_dealloc_swap JEMALLOC_N(chunk_dealloc_swap)
+#define        chunk_dss_boot JEMALLOC_N(chunk_dss_boot)
+#define        chunk_in_dss JEMALLOC_N(chunk_in_dss)
+#define        chunk_in_swap JEMALLOC_N(chunk_in_swap)
+#define        chunk_mmap_boot JEMALLOC_N(chunk_mmap_boot)
+#define        chunk_swap_boot JEMALLOC_N(chunk_swap_boot)
+#define        chunk_swap_enable JEMALLOC_N(chunk_swap_enable)
+#define        ckh_bucket_search JEMALLOC_N(ckh_bucket_search)
+#define        ckh_count JEMALLOC_N(ckh_count)
+#define        ckh_delete JEMALLOC_N(ckh_delete)
+#define        ckh_evict_reloc_insert JEMALLOC_N(ckh_evict_reloc_insert)
+#define        ckh_insert JEMALLOC_N(ckh_insert)
+#define        ckh_isearch JEMALLOC_N(ckh_isearch)
+#define        ckh_iter JEMALLOC_N(ckh_iter)
+#define        ckh_new JEMALLOC_N(ckh_new)
+#define        ckh_pointer_hash JEMALLOC_N(ckh_pointer_hash)
+#define        ckh_pointer_keycomp JEMALLOC_N(ckh_pointer_keycomp)
+#define        ckh_rebuild JEMALLOC_N(ckh_rebuild)
+#define        ckh_remove JEMALLOC_N(ckh_remove)
+#define        ckh_search JEMALLOC_N(ckh_search)
+#define        ckh_string_hash JEMALLOC_N(ckh_string_hash)
+#define        ckh_string_keycomp JEMALLOC_N(ckh_string_keycomp)
+#define        ckh_try_bucket_insert JEMALLOC_N(ckh_try_bucket_insert)
+#define        ckh_try_insert JEMALLOC_N(ckh_try_insert)
+#define        create_zone JEMALLOC_N(create_zone)
+#define        ctl_boot JEMALLOC_N(ctl_boot)
+#define        ctl_bymib JEMALLOC_N(ctl_bymib)
+#define        ctl_byname JEMALLOC_N(ctl_byname)
+#define        ctl_nametomib JEMALLOC_N(ctl_nametomib)
+#define        extent_tree_ad_first JEMALLOC_N(extent_tree_ad_first)
+#define        extent_tree_ad_insert JEMALLOC_N(extent_tree_ad_insert)
+#define        extent_tree_ad_iter JEMALLOC_N(extent_tree_ad_iter)
+#define        extent_tree_ad_iter_recurse JEMALLOC_N(extent_tree_ad_iter_recurse)
+#define        extent_tree_ad_iter_start JEMALLOC_N(extent_tree_ad_iter_start)
+#define        extent_tree_ad_last JEMALLOC_N(extent_tree_ad_last)
+#define        extent_tree_ad_new JEMALLOC_N(extent_tree_ad_new)
+#define        extent_tree_ad_next JEMALLOC_N(extent_tree_ad_next)
+#define        extent_tree_ad_nsearch JEMALLOC_N(extent_tree_ad_nsearch)
+#define        extent_tree_ad_prev JEMALLOC_N(extent_tree_ad_prev)
+#define        extent_tree_ad_psearch JEMALLOC_N(extent_tree_ad_psearch)
+#define        extent_tree_ad_remove JEMALLOC_N(extent_tree_ad_remove)
+#define        extent_tree_ad_reverse_iter JEMALLOC_N(extent_tree_ad_reverse_iter)
+#define        extent_tree_ad_reverse_iter_recurse JEMALLOC_N(extent_tree_ad_reverse_iter_recurse)
+#define        extent_tree_ad_reverse_iter_start JEMALLOC_N(extent_tree_ad_reverse_iter_start)
+#define        extent_tree_ad_search JEMALLOC_N(extent_tree_ad_search)
+#define        extent_tree_szad_first JEMALLOC_N(extent_tree_szad_first)
+#define        extent_tree_szad_insert JEMALLOC_N(extent_tree_szad_insert)
+#define        extent_tree_szad_iter JEMALLOC_N(extent_tree_szad_iter)
+#define        extent_tree_szad_iter_recurse JEMALLOC_N(extent_tree_szad_iter_recurse)
+#define        extent_tree_szad_iter_start JEMALLOC_N(extent_tree_szad_iter_start)
+#define        extent_tree_szad_last JEMALLOC_N(extent_tree_szad_last)
+#define        extent_tree_szad_new JEMALLOC_N(extent_tree_szad_new)
+#define        extent_tree_szad_next JEMALLOC_N(extent_tree_szad_next)
+#define        extent_tree_szad_nsearch JEMALLOC_N(extent_tree_szad_nsearch)
+#define        extent_tree_szad_prev JEMALLOC_N(extent_tree_szad_prev)
+#define        extent_tree_szad_psearch JEMALLOC_N(extent_tree_szad_psearch)
+#define        extent_tree_szad_remove JEMALLOC_N(extent_tree_szad_remove)
+#define        extent_tree_szad_reverse_iter JEMALLOC_N(extent_tree_szad_reverse_iter)
+#define        extent_tree_szad_reverse_iter_recurse JEMALLOC_N(extent_tree_szad_reverse_iter_recurse)
+#define        extent_tree_szad_reverse_iter_start JEMALLOC_N(extent_tree_szad_reverse_iter_start)
+#define        extent_tree_szad_search JEMALLOC_N(extent_tree_szad_search)
+#define        hash JEMALLOC_N(hash)
+#define        huge_boot JEMALLOC_N(huge_boot)
+#define        huge_dalloc JEMALLOC_N(huge_dalloc)
+#define        huge_malloc JEMALLOC_N(huge_malloc)
+#define        huge_palloc JEMALLOC_N(huge_palloc)
+#define        huge_prof_ctx_get JEMALLOC_N(huge_prof_ctx_get)
+#define        huge_prof_ctx_set JEMALLOC_N(huge_prof_ctx_set)
+#define        huge_ralloc JEMALLOC_N(huge_ralloc)
+#define        huge_ralloc_no_move JEMALLOC_N(huge_ralloc_no_move)
+#define        huge_salloc JEMALLOC_N(huge_salloc)
+#define        iallocm JEMALLOC_N(iallocm)
+#define        icalloc JEMALLOC_N(icalloc)
+#define        idalloc JEMALLOC_N(idalloc)
+#define        imalloc JEMALLOC_N(imalloc)
+#define        ipalloc JEMALLOC_N(ipalloc)
+#define        iralloc JEMALLOC_N(iralloc)
+#define        isalloc JEMALLOC_N(isalloc)
+#define        ivsalloc JEMALLOC_N(ivsalloc)
+#define        jemalloc_darwin_init JEMALLOC_N(jemalloc_darwin_init)
+#define        jemalloc_postfork JEMALLOC_N(jemalloc_postfork)
+#define        jemalloc_prefork JEMALLOC_N(jemalloc_prefork)
+#define        malloc_cprintf JEMALLOC_N(malloc_cprintf)
+#define        malloc_mutex_destroy JEMALLOC_N(malloc_mutex_destroy)
+#define        malloc_mutex_init JEMALLOC_N(malloc_mutex_init)
+#define        malloc_mutex_lock JEMALLOC_N(malloc_mutex_lock)
+#define        malloc_mutex_trylock JEMALLOC_N(malloc_mutex_trylock)
+#define        malloc_mutex_unlock JEMALLOC_N(malloc_mutex_unlock)
+#define        malloc_printf JEMALLOC_N(malloc_printf)
+#define        malloc_write JEMALLOC_N(malloc_write)
+#define        mb_write JEMALLOC_N(mb_write)
+#define        pow2_ceil JEMALLOC_N(pow2_ceil)
+#define        prof_backtrace JEMALLOC_N(prof_backtrace)
+#define        prof_boot0 JEMALLOC_N(prof_boot0)
+#define        prof_boot1 JEMALLOC_N(prof_boot1)
+#define        prof_boot2 JEMALLOC_N(prof_boot2)
+#define        prof_ctx_get JEMALLOC_N(prof_ctx_get)
+#define        prof_ctx_set JEMALLOC_N(prof_ctx_set)
+#define        prof_free JEMALLOC_N(prof_free)
+#define        prof_gdump JEMALLOC_N(prof_gdump)
+#define        prof_idump JEMALLOC_N(prof_idump)
+#define        prof_lookup JEMALLOC_N(prof_lookup)
+#define        prof_malloc JEMALLOC_N(prof_malloc)
+#define        prof_mdump JEMALLOC_N(prof_mdump)
+#define        prof_realloc JEMALLOC_N(prof_realloc)
+#define        prof_sample_accum_update JEMALLOC_N(prof_sample_accum_update)
+#define        prof_sample_threshold_update JEMALLOC_N(prof_sample_threshold_update)
+#define        prof_tdata_init JEMALLOC_N(prof_tdata_init)
+#define        pthread_create JEMALLOC_N(pthread_create)
+#define        rtree_get JEMALLOC_N(rtree_get)
+#define        rtree_get_locked JEMALLOC_N(rtree_get_locked)
+#define        rtree_new JEMALLOC_N(rtree_new)
+#define        rtree_set JEMALLOC_N(rtree_set)
+#define        s2u JEMALLOC_N(s2u)
+#define        sa2u JEMALLOC_N(sa2u)
+#define        stats_arenas_i_bins_j_index JEMALLOC_N(stats_arenas_i_bins_j_index)
+#define        stats_arenas_i_index JEMALLOC_N(stats_arenas_i_index)
+#define        stats_arenas_i_lruns_j_index JEMALLOC_N(stats_arenas_i_lruns_j_index)
+#define        stats_cactive_add JEMALLOC_N(stats_cactive_add)
+#define        stats_cactive_get JEMALLOC_N(stats_cactive_get)
+#define        stats_cactive_sub JEMALLOC_N(stats_cactive_sub)
+#define        stats_print JEMALLOC_N(stats_print)
+#define        szone2ozone JEMALLOC_N(szone2ozone)
+#define        tcache_alloc_easy JEMALLOC_N(tcache_alloc_easy)
+#define        tcache_alloc_large JEMALLOC_N(tcache_alloc_large)
+#define        tcache_alloc_small JEMALLOC_N(tcache_alloc_small)
+#define        tcache_alloc_small_hard JEMALLOC_N(tcache_alloc_small_hard)
+#define        tcache_bin_flush_large JEMALLOC_N(tcache_bin_flush_large)
+#define        tcache_bin_flush_small JEMALLOC_N(tcache_bin_flush_small)
+#define        tcache_boot JEMALLOC_N(tcache_boot)
+#define        tcache_create JEMALLOC_N(tcache_create)
+#define        tcache_dalloc_large JEMALLOC_N(tcache_dalloc_large)
+#define        tcache_dalloc_small JEMALLOC_N(tcache_dalloc_small)
+#define        tcache_destroy JEMALLOC_N(tcache_destroy)
+#define        tcache_event JEMALLOC_N(tcache_event)
+#define        tcache_get JEMALLOC_N(tcache_get)
+#define        tcache_stats_merge JEMALLOC_N(tcache_stats_merge)
+#define        thread_allocated_get JEMALLOC_N(thread_allocated_get)
+#define        thread_allocated_get_hard JEMALLOC_N(thread_allocated_get_hard)
+#define        u2s JEMALLOC_N(u2s)
index f943873507787c042ce219080d3dbc143e510865..e9064ba6e73ef956b4dc7cf729f79238e2d54cd4 100644 (file)
@@ -227,9 +227,60 @@ bool       prof_boot2(void);
 /******************************************************************************/
 #ifdef JEMALLOC_H_INLINES
 
 /******************************************************************************/
 #ifdef JEMALLOC_H_INLINES
 
+#define        PROF_ALLOC_PREP(nignore, size, ret) do {                        \
+       prof_tdata_t *prof_tdata;                                       \
+       prof_bt_t bt;                                                   \
+                                                                       \
+       assert(size == s2u(size));                                      \
+                                                                       \
+       prof_tdata = PROF_TCACHE_GET();                                 \
+       if (prof_tdata == NULL) {                                       \
+               prof_tdata = prof_tdata_init();                         \
+               if (prof_tdata == NULL) {                               \
+                       ret = NULL;                                     \
+                       break;                                          \
+               }                                                       \
+       }                                                               \
+                                                                       \
+       if (opt_prof_active == false) {                                 \
+               /* Sampling is currently inactive, so avoid sampling. */\
+               ret = (prof_thr_cnt_t *)(uintptr_t)1U;                  \
+       } else if (opt_lg_prof_sample == 0) {                           \
+               /* Don't bother with sampling logic, since sampling   */\
+               /* interval is 1.                                     */\
+               bt_init(&bt, prof_tdata->vec);                          \
+               prof_backtrace(&bt, nignore, prof_bt_max);              \
+               ret = prof_lookup(&bt);                                 \
+       } else {                                                        \
+               if (prof_tdata->threshold == 0) {                       \
+                       /* Initialize.  Seed the prng differently for */\
+                       /* each thread.                               */\
+                       prof_tdata->prn_state =                         \
+                           (uint64_t)(uintptr_t)&size;                 \
+                       prof_sample_threshold_update(prof_tdata);       \
+               }                                                       \
+                                                                       \
+               /* Determine whether to capture a backtrace based on  */\
+               /* whether size is enough for prof_accum to reach     */\
+               /* prof_tdata->threshold.  However, delay updating    */\
+               /* these variables until prof_{m,re}alloc(), because  */\
+               /* we don't know for sure that the allocation will    */\
+               /* succeed.                                           */\
+               /*                                                    */\
+               /* Use subtraction rather than addition to avoid      */\
+               /* potential integer overflow.                        */\
+               if (size >= prof_tdata->threshold -                     \
+                   prof_tdata->accum) {                                \
+                       bt_init(&bt, prof_tdata->vec);                  \
+                       prof_backtrace(&bt, nignore, prof_bt_max);      \
+                       ret = prof_lookup(&bt);                         \
+               } else                                                  \
+                       ret = (prof_thr_cnt_t *)(uintptr_t)1U;          \
+       }                                                               \
+} while (0)
+
 #ifndef JEMALLOC_ENABLE_INLINE
 void   prof_sample_threshold_update(prof_tdata_t *prof_tdata);
 #ifndef JEMALLOC_ENABLE_INLINE
 void   prof_sample_threshold_update(prof_tdata_t *prof_tdata);
-prof_thr_cnt_t *prof_alloc_prep(size_t size);
 prof_ctx_t     *prof_ctx_get(const void *ptr);
 void   prof_ctx_set(const void *ptr, prof_ctx_t *ctx);
 bool   prof_sample_accum_update(size_t size);
 prof_ctx_t     *prof_ctx_get(const void *ptr);
 void   prof_ctx_set(const void *ptr, prof_ctx_t *ctx);
 bool   prof_sample_accum_update(size_t size);
@@ -272,71 +323,6 @@ prof_sample_threshold_update(prof_tdata_t *prof_tdata)
            + (uint64_t)1U;
 }
 
            + (uint64_t)1U;
 }
 
-JEMALLOC_INLINE prof_thr_cnt_t *
-prof_alloc_prep(size_t size)
-{
-#ifdef JEMALLOC_ENABLE_INLINE
-   /* This function does not have its own stack frame, because it is inlined. */
-#  define NIGNORE 1
-#else
-#  define NIGNORE 2
-#endif
-       prof_thr_cnt_t *ret;
-       prof_tdata_t *prof_tdata;
-       prof_bt_t bt;
-
-       assert(size == s2u(size));
-
-       prof_tdata = PROF_TCACHE_GET();
-       if (prof_tdata == NULL) {
-               prof_tdata = prof_tdata_init();
-               if (prof_tdata == NULL)
-                       return (NULL);
-       }
-
-       if (opt_prof_active == false) {
-               /* Sampling is currently inactive, so avoid sampling. */
-               ret = (prof_thr_cnt_t *)(uintptr_t)1U;
-       } else if (opt_lg_prof_sample == 0) {
-               /*
-                * Don't bother with sampling logic, since sampling interval is
-                * 1.
-                */
-               bt_init(&bt, prof_tdata->vec);
-               prof_backtrace(&bt, NIGNORE, prof_bt_max);
-               ret = prof_lookup(&bt);
-       } else {
-               if (prof_tdata->threshold == 0) {
-                       /*
-                        * Initialize.  Seed the prng differently for each
-                        * thread.
-                        */
-                       prof_tdata->prn_state = (uint64_t)(uintptr_t)&size;
-                       prof_sample_threshold_update(prof_tdata);
-               }
-
-               /*
-                * Determine whether to capture a backtrace based on whether
-                * size is enough for prof_accum to reach
-                * prof_tdata->threshold.  However, delay updating these
-                * variables until prof_{m,re}alloc(), because we don't know
-                * for sure that the allocation will succeed.
-                *
-                * Use subtraction rather than addition to avoid potential
-                * integer overflow.
-                */
-               if (size >= prof_tdata->threshold - prof_tdata->accum) {
-                       bt_init(&bt, prof_tdata->vec);
-                       prof_backtrace(&bt, NIGNORE, prof_bt_max);
-                       ret = prof_lookup(&bt);
-               } else
-                       ret = (prof_thr_cnt_t *)(uintptr_t)1U;
-       }
-
-       return (ret);
-#undef NIGNORE
-}
-
 JEMALLOC_INLINE prof_ctx_t *
 prof_ctx_get(const void *ptr)
 {
 JEMALLOC_INLINE prof_ctx_t *
 prof_ctx_get(const void *ptr)
 {
@@ -415,7 +401,7 @@ prof_malloc(const void *ptr, size_t size, prof_thr_cnt_t *cnt)
                         * always possible to tell in advance how large an
                         * object's usable size will be, so there should never
                         * be a difference between the size passed to
                         * always possible to tell in advance how large an
                         * object's usable size will be, so there should never
                         * be a difference between the size passed to
-                        * prof_alloc_prep() and prof_malloc().
+                        * PROF_ALLOC_PREP() and prof_malloc().
                         */
                        assert((uintptr_t)cnt == (uintptr_t)1U);
                }
                         */
                        assert((uintptr_t)cnt == (uintptr_t)1U);
                }
@@ -459,7 +445,7 @@ prof_realloc(const void *ptr, size_t size, prof_thr_cnt_t *cnt,
                        if (prof_sample_accum_update(size)) {
                                /*
                                 * Don't sample.  The size passed to
                        if (prof_sample_accum_update(size)) {
                                /*
                                 * Don't sample.  The size passed to
-                                * prof_alloc_prep() was larger than what
+                                * PROF_ALLOC_PREP() was larger than what
                                 * actually got allocated, so a backtrace was
                                 * captured for this allocation, even though
                                 * its actual size was insufficient to cross
                                 * actually got allocated, so a backtrace was
                                 * captured for this allocation, even though
                                 * its actual size was insufficient to cross
index d8c81d7cb25c02bd94ae2371718393f743e495ea..9ac7e1c20768839c80de0347a5612c37f085e01b 100644 (file)
 #undef JEMALLOC_P
 #endif
 
 #undef JEMALLOC_P
 #endif
 
+/*
+ * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
+ * For shared libraries, symbol visibility mechanisms prevent these symbols
+ * from being exported, but for static libraries, naming collisions are a real
+ * possibility.
+ */
+#undef JEMALLOC_PRIVATE_NAMESPACE
+#undef JEMALLOC_N
+
 /*
  * Hyper-threaded CPUs may need a special instruction inside spin loops in
  * order to yield to another virtual CPU.
 /*
  * Hyper-threaded CPUs may need a special instruction inside spin loops in
  * order to yield to another virtual CPU.
index 9aaf47ff973bfeaebb8bbb8d24ec08f1ee72dd5b..d166ca1ec4dd61a397014f35f932dc17c4dbf247 100644 (file)
@@ -569,7 +569,7 @@ arena_chunk_dealloc(arena_t *arena, arena_chunk_t *chunk)
                        arena->ndirty -= spare->ndirty;
                }
                malloc_mutex_unlock(&arena->lock);
                        arena->ndirty -= spare->ndirty;
                }
                malloc_mutex_unlock(&arena->lock);
-               chunk_dealloc((void *)spare, chunksize);
+               chunk_dealloc((void *)spare, chunksize, true);
                malloc_mutex_lock(&arena->lock);
 #ifdef JEMALLOC_STATS
                arena->stats.mapped -= chunksize;
                malloc_mutex_lock(&arena->lock);
 #ifdef JEMALLOC_STATS
                arena->stats.mapped -= chunksize;
@@ -869,9 +869,9 @@ arena_purge(arena_t *arena, bool all)
        assert(ndirty == arena->ndirty);
 #endif
        assert(arena->ndirty > arena->npurgatory || all);
        assert(ndirty == arena->ndirty);
 #endif
        assert(arena->ndirty > arena->npurgatory || all);
-       assert(arena->ndirty > chunk_npages || all);
+       assert(arena->ndirty - arena->npurgatory > chunk_npages || all);
        assert((arena->nactive >> opt_lg_dirty_mult) < (arena->ndirty -
        assert((arena->nactive >> opt_lg_dirty_mult) < (arena->ndirty -
-           npurgatory) || all);
+           arena->npurgatory) || all);
 
 #ifdef JEMALLOC_STATS
        arena->stats.npurge++;
 
 #ifdef JEMALLOC_STATS
        arena->stats.npurge++;
@@ -1657,6 +1657,7 @@ arena_prof_promoted(const void *ptr, size_t size)
        assert(ptr != NULL);
        assert(CHUNK_ADDR2BASE(ptr) != ptr);
        assert(isalloc(ptr) == PAGE_SIZE);
        assert(ptr != NULL);
        assert(CHUNK_ADDR2BASE(ptr) != ptr);
        assert(isalloc(ptr) == PAGE_SIZE);
+       assert(size <= small_maxclass);
 
        chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
        pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> PAGE_SHIFT;
 
        chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
        pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> PAGE_SHIFT;
index 301519e8042fb350448d882753490a790a32aaf3..d190c6f49b37482f2b00deb0b5f5b0abca043976 100644 (file)
@@ -70,7 +70,7 @@ RETURN:
 #ifdef JEMALLOC_IVSALLOC
        if (base == false && ret != NULL) {
                if (rtree_set(chunks_rtree, (uintptr_t)ret, ret)) {
 #ifdef JEMALLOC_IVSALLOC
        if (base == false && ret != NULL) {
                if (rtree_set(chunks_rtree, (uintptr_t)ret, ret)) {
-                       chunk_dealloc(ret, size);
+                       chunk_dealloc(ret, size, true);
                        return (NULL);
                }
        }
                        return (NULL);
                }
        }
@@ -108,7 +108,7 @@ RETURN:
 }
 
 void
 }
 
 void
-chunk_dealloc(void *chunk, size_t size)
+chunk_dealloc(void *chunk, size_t size, bool unmap)
 {
 
        assert(chunk != NULL);
 {
 
        assert(chunk != NULL);
@@ -125,15 +125,17 @@ chunk_dealloc(void *chunk, size_t size)
        malloc_mutex_unlock(&chunks_mtx);
 #endif
 
        malloc_mutex_unlock(&chunks_mtx);
 #endif
 
+       if (unmap) {
 #ifdef JEMALLOC_SWAP
 #ifdef JEMALLOC_SWAP
-       if (swap_enabled && chunk_dealloc_swap(chunk, size) == false)
-               return;
+               if (swap_enabled && chunk_dealloc_swap(chunk, size) == false)
+                       return;
 #endif
 #ifdef JEMALLOC_DSS
 #endif
 #ifdef JEMALLOC_DSS
-       if (chunk_dealloc_dss(chunk, size) == false)
-               return;
+               if (chunk_dealloc_dss(chunk, size) == false)
+                       return;
 #endif
 #endif
-       chunk_dealloc_mmap(chunk, size);
+               chunk_dealloc_mmap(chunk, size);
+       }
 }
 
 bool
 }
 
 bool
index 143b5b5f95abde6a7b481210bc3d96c21bad2a43..43fcc25239d5f73a196aeb9df8fdca9b97e37536 100644 (file)
@@ -556,7 +556,7 @@ ckh_string_hash(const void *key, unsigned minbits, size_t *hash1, size_t *hash2)
        } else {
                ret1 = h;
                ret2 = hash(key, strlen((const char *)key),
        } else {
                ret1 = h;
                ret2 = hash(key, strlen((const char *)key),
-                   0x8432a476666bbc13U);
+                   0x8432a476666bbc13LLU);
        }
 
        *hash1 = ret1;
        }
 
        *hash1 = ret1;
index 40fdbacbcdee4733a0ec3b23e8a21a8ea581179d..e5336d36949f5ffd69b0f8c0f6ab6543a35033ef 100644 (file)
@@ -1151,11 +1151,13 @@ thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
 
                /* Set new arena association. */
                ARENA_SET(arena);
 
                /* Set new arena association. */
                ARENA_SET(arena);
+#ifdef JEMALLOC_TCACHE
                {
                        tcache_t *tcache = TCACHE_GET();
                        if (tcache != NULL)
                                tcache->arena = arena;
                }
                {
                        tcache_t *tcache = TCACHE_GET();
                        if (tcache != NULL)
                                tcache->arena = arena;
                }
+#endif
        }
 
        ret = 0;
        }
 
        ret = 0;
index ac3f3a0d848070ef9a1337bf0d4746e3532906ae..a4f9b054ed5924f0185bc8ed959ae30bc02fdaee 100644 (file)
@@ -110,12 +110,12 @@ huge_palloc(size_t size, size_t alignment, bool zero)
        if (offset == 0) {
                /* Trim trailing space. */
                chunk_dealloc((void *)((uintptr_t)ret + chunk_size), alloc_size
        if (offset == 0) {
                /* Trim trailing space. */
                chunk_dealloc((void *)((uintptr_t)ret + chunk_size), alloc_size
-                   - chunk_size);
+                   - chunk_size, true);
        } else {
                size_t trailsize;
 
                /* Trim leading space. */
        } else {
                size_t trailsize;
 
                /* Trim leading space. */
-               chunk_dealloc(ret, alignment - offset);
+               chunk_dealloc(ret, alignment - offset, true);
 
                ret = (void *)((uintptr_t)ret + (alignment - offset));
 
 
                ret = (void *)((uintptr_t)ret + (alignment - offset));
 
@@ -124,7 +124,7 @@ huge_palloc(size_t size, size_t alignment, bool zero)
                    /* Trim trailing space. */
                    assert(trailsize < alloc_size);
                    chunk_dealloc((void *)((uintptr_t)ret + chunk_size),
                    /* Trim trailing space. */
                    assert(trailsize < alloc_size);
                    chunk_dealloc((void *)((uintptr_t)ret + chunk_size),
-                       trailsize);
+                       trailsize, true);
                }
        }
 
                }
        }
 
@@ -234,6 +234,13 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
            ) {
                size_t newsize = huge_salloc(ret);
 
            ) {
                size_t newsize = huge_salloc(ret);
 
+               /*
+                * Remove ptr from the tree of huge allocations before
+                * performing the remap operation, in order to avoid the
+                * possibility of another thread acquiring that mapping before
+                * this one removes it from the tree.
+                */
+               huge_dalloc(ptr, false);
                if (mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE|MREMAP_FIXED,
                    ret) == MAP_FAILED) {
                        /*
                if (mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE|MREMAP_FIXED,
                    ret) == MAP_FAILED) {
                        /*
@@ -253,9 +260,8 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
                        if (opt_abort)
                                abort();
                        memcpy(ret, ptr, copysize);
                        if (opt_abort)
                                abort();
                        memcpy(ret, ptr, copysize);
-                       idalloc(ptr);
-               } else
-                       huge_dalloc(ptr, false);
+                       chunk_dealloc_mmap(ptr, oldsize);
+               }
        } else
 #endif
        {
        } else
 #endif
        {
@@ -295,9 +301,10 @@ huge_dalloc(void *ptr, bool unmap)
                        memset(node->addr, 0x5a, node->size);
 #endif
 #endif
                        memset(node->addr, 0x5a, node->size);
 #endif
 #endif
-               chunk_dealloc(node->addr, node->size);
        }
 
        }
 
+       chunk_dealloc(node->addr, node->size, unmap);
+
        base_node_dealloc(node);
 }
 
        base_node_dealloc(node);
 }
 
index e28751692d8532fb9ad555b1abd358532417250e..a161c2e26e173484f438c165c290c6d01abad846 100644 (file)
@@ -84,6 +84,7 @@ static void   malloc_conf_error(const char *msg, const char *k, size_t klen,
     const char *v, size_t vlen);
 static void    malloc_conf_init(void);
 static bool    malloc_init_hard(void);
     const char *v, size_t vlen);
 static void    malloc_conf_init(void);
 static bool    malloc_init_hard(void);
+static int     imemalign(void **memptr, size_t alignment, size_t size);
 
 /******************************************************************************/
 /* malloc_message() setup. */
 
 /******************************************************************************/
 /* malloc_message() setup. */
@@ -688,7 +689,7 @@ malloc_init_hard(void)
 
                result = sysconf(_SC_PAGESIZE);
                assert(result != -1);
 
                result = sysconf(_SC_PAGESIZE);
                assert(result != -1);
-               pagesize = (unsigned)result;
+               pagesize = (size_t)result;
 
                /*
                 * We assume that pagesize is a power of 2 when calculating
 
                /*
                 * We assume that pagesize is a power of 2 when calculating
@@ -768,6 +769,14 @@ malloc_init_hard(void)
        }
 #endif
 
        }
 #endif
 
+       if (malloc_mutex_init(&arenas_lock))
+               return (true);
+
+       if (pthread_key_create(&arenas_tsd, arenas_cleanup) != 0) {
+               malloc_mutex_unlock(&init_lock);
+               return (true);
+       }
+
        /*
         * Create enough scaffolding to allow recursive allocation in
         * malloc_ncpus().
        /*
         * Create enough scaffolding to allow recursive allocation in
         * malloc_ncpus().
@@ -794,14 +803,6 @@ malloc_init_hard(void)
        ARENA_SET(arenas[0]);
        arenas[0]->nthreads++;
 
        ARENA_SET(arenas[0]);
        arenas[0]->nthreads++;
 
-       if (malloc_mutex_init(&arenas_lock))
-               return (true);
-
-       if (pthread_key_create(&arenas_tsd, arenas_cleanup) != 0) {
-               malloc_mutex_unlock(&init_lock);
-               return (true);
-       }
-
 #ifdef JEMALLOC_PROF
        if (prof_boot2()) {
                malloc_mutex_unlock(&init_lock);
 #ifdef JEMALLOC_PROF
        if (prof_boot2()) {
                malloc_mutex_unlock(&init_lock);
@@ -939,7 +940,8 @@ JEMALLOC_P(malloc)(size_t size)
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
                usize = s2u(size);
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
                usize = s2u(size);
-               if ((cnt = prof_alloc_prep(usize)) == NULL) {
+               PROF_ALLOC_PREP(1, usize, cnt);
+               if (cnt == NULL) {
                        ret = NULL;
                        goto OOM;
                }
                        ret = NULL;
                        goto OOM;
                }
@@ -988,9 +990,15 @@ RETURN:
 }
 
 JEMALLOC_ATTR(nonnull(1))
 }
 
 JEMALLOC_ATTR(nonnull(1))
-JEMALLOC_ATTR(visibility("default"))
-int
-JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
+#ifdef JEMALLOC_PROF
+/*
+ * Avoid any uncertainty as to how many backtrace frames to ignore in 
+ * PROF_ALLOC_PREP().
+ */
+JEMALLOC_ATTR(noinline)
+#endif
+static int
+imemalign(void **memptr, size_t alignment, size_t size)
 {
        int ret;
        size_t usize
 {
        int ret;
        size_t usize
@@ -1057,7 +1065,8 @@ JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
 
 #ifdef JEMALLOC_PROF
                if (opt_prof) {
 
 #ifdef JEMALLOC_PROF
                if (opt_prof) {
-                       if ((cnt = prof_alloc_prep(usize)) == NULL) {
+                       PROF_ALLOC_PREP(2, usize, cnt);
+                       if (cnt == NULL) {
                                result = NULL;
                                ret = EINVAL;
                        } else {
                                result = NULL;
                                ret = EINVAL;
                        } else {
@@ -1110,6 +1119,15 @@ RETURN:
        return (ret);
 }
 
        return (ret);
 }
 
+JEMALLOC_ATTR(nonnull(1))
+JEMALLOC_ATTR(visibility("default"))
+int
+JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
+{
+
+       return imemalign(memptr, alignment, size);
+}
+
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
@@ -1165,7 +1183,8 @@ JEMALLOC_P(calloc)(size_t num, size_t size)
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
                usize = s2u(num_size);
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
                usize = s2u(num_size);
-               if ((cnt = prof_alloc_prep(usize)) == NULL) {
+               PROF_ALLOC_PREP(1, usize, cnt);
+               if (cnt == NULL) {
                        ret = NULL;
                        goto RETURN;
                }
                        ret = NULL;
                        goto RETURN;
                }
@@ -1278,7 +1297,9 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
                if (opt_prof) {
                        usize = s2u(size);
                        old_ctx = prof_ctx_get(ptr);
                if (opt_prof) {
                        usize = s2u(size);
                        old_ctx = prof_ctx_get(ptr);
-                       if ((cnt = prof_alloc_prep(usize)) == NULL) {
+                       PROF_ALLOC_PREP(1, usize, cnt);
+                       if (cnt == NULL) {
+                               old_ctx = NULL;
                                ret = NULL;
                                goto OOM;
                        }
                                ret = NULL;
                                goto OOM;
                        }
@@ -1288,8 +1309,13 @@ JEMALLOC_P(realloc)(void *ptr, size_t size)
                                    false, false);
                                if (ret != NULL)
                                        arena_prof_promoted(ret, usize);
                                    false, false);
                                if (ret != NULL)
                                        arena_prof_promoted(ret, usize);
-                       } else
+                               else
+                                       old_ctx = NULL;
+                       } else {
                                ret = iralloc(ptr, size, 0, 0, false, false);
                                ret = iralloc(ptr, size, 0, 0, false, false);
+                               if (ret == NULL)
+                                       old_ctx = NULL;
+                       }
                } else
 #endif
                {
                } else
 #endif
                {
@@ -1327,7 +1353,8 @@ OOM:
 #ifdef JEMALLOC_PROF
                        if (opt_prof) {
                                usize = s2u(size);
 #ifdef JEMALLOC_PROF
                        if (opt_prof) {
                                usize = s2u(size);
-                               if ((cnt = prof_alloc_prep(usize)) == NULL)
+                               PROF_ALLOC_PREP(1, usize, cnt);
+                               if (cnt == NULL)
                                        ret = NULL;
                                else {
                                        if (prof_promote && (uintptr_t)cnt !=
                                        ret = NULL;
                                else {
                                        if (prof_promote && (uintptr_t)cnt !=
@@ -1432,7 +1459,7 @@ JEMALLOC_P(memalign)(size_t alignment, size_t size)
 #ifdef JEMALLOC_CC_SILENCE
        int result =
 #endif
 #ifdef JEMALLOC_CC_SILENCE
        int result =
 #endif
-           JEMALLOC_P(posix_memalign)(&ret, alignment, size);
+           imemalign(&ret, alignment, size);
 #ifdef JEMALLOC_CC_SILENCE
        if (result != 0)
                return (NULL);
 #ifdef JEMALLOC_CC_SILENCE
        if (result != 0)
                return (NULL);
@@ -1451,7 +1478,7 @@ JEMALLOC_P(valloc)(size_t size)
 #ifdef JEMALLOC_CC_SILENCE
        int result =
 #endif
 #ifdef JEMALLOC_CC_SILENCE
        int result =
 #endif
-           JEMALLOC_P(posix_memalign)(&ret, PAGE_SIZE, size);
+           imemalign(&ret, PAGE_SIZE, size);
 #ifdef JEMALLOC_CC_SILENCE
        if (result != 0)
                return (NULL);
 #ifdef JEMALLOC_CC_SILENCE
        if (result != 0)
                return (NULL);
@@ -1566,14 +1593,14 @@ JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
        if (malloc_init())
                goto OOM;
 
        if (malloc_init())
                goto OOM;
 
-       usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment,
-           NULL);
+       usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment, NULL);
        if (usize == 0)
                goto OOM;
 
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
        if (usize == 0)
                goto OOM;
 
 #ifdef JEMALLOC_PROF
        if (opt_prof) {
-               if ((cnt = prof_alloc_prep(usize)) == NULL)
+               PROF_ALLOC_PREP(1, usize, cnt);
+               if (cnt == NULL)
                        goto OOM;
                if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && usize <=
                    small_maxclass) {
                        goto OOM;
                if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && usize <=
                    small_maxclass) {
@@ -1590,7 +1617,7 @@ JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
                        if (p == NULL)
                                goto OOM;
                }
                        if (p == NULL)
                                goto OOM;
                }
-
+               prof_malloc(p, usize, cnt);
                if (rsize != NULL)
                        *rsize = usize;
        } else
                if (rsize != NULL)
                        *rsize = usize;
        } else
@@ -1645,7 +1672,6 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
        bool no_move = flags & ALLOCM_NO_MOVE;
 #ifdef JEMALLOC_PROF
        prof_thr_cnt_t *cnt;
        bool no_move = flags & ALLOCM_NO_MOVE;
 #ifdef JEMALLOC_PROF
        prof_thr_cnt_t *cnt;
-       prof_ctx_t *old_ctx;
 #endif
 
        assert(ptr != NULL);
 #endif
 
        assert(ptr != NULL);
@@ -1660,25 +1686,33 @@ JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
                /*
                 * usize isn't knowable before iralloc() returns when extra is
                 * non-zero.  Therefore, compute its maximum possible value and
                /*
                 * usize isn't knowable before iralloc() returns when extra is
                 * non-zero.  Therefore, compute its maximum possible value and
-                * use that in prof_alloc_prep() to decide whether to capture a
+                * use that in PROF_ALLOC_PREP() to decide whether to capture a
                 * backtrace.  prof_realloc() will use the actual usize to
                 * decide whether to sample.
                 */
                size_t max_usize = (alignment == 0) ? s2u(size+extra) :
                    sa2u(size+extra, alignment, NULL);
                 * backtrace.  prof_realloc() will use the actual usize to
                 * decide whether to sample.
                 */
                size_t max_usize = (alignment == 0) ? s2u(size+extra) :
                    sa2u(size+extra, alignment, NULL);
+               prof_ctx_t *old_ctx = prof_ctx_get(p);
                old_size = isalloc(p);
                old_size = isalloc(p);
-               old_ctx = prof_ctx_get(p);
-               if ((cnt = prof_alloc_prep(max_usize)) == NULL)
+               PROF_ALLOC_PREP(1, max_usize, cnt);
+               if (cnt == NULL)
                        goto OOM;
                        goto OOM;
-               if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U && max_usize
-                   <= small_maxclass) {
+               /*
+                * Use minimum usize to determine whether promotion may happen.
+                */
+               if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U
+                   && ((alignment == 0) ? s2u(size) : sa2u(size,
+                   alignment, NULL)) <= small_maxclass) {
                        q = iralloc(p, small_maxclass+1, (small_maxclass+1 >=
                            size+extra) ? 0 : size+extra - (small_maxclass+1),
                            alignment, zero, no_move);
                        if (q == NULL)
                                goto ERR;
                        q = iralloc(p, small_maxclass+1, (small_maxclass+1 >=
                            size+extra) ? 0 : size+extra - (small_maxclass+1),
                            alignment, zero, no_move);
                        if (q == NULL)
                                goto ERR;
-                       usize = isalloc(q);
-                       arena_prof_promoted(q, usize);
+                       if (max_usize < PAGE_SIZE) {
+                               usize = max_usize;
+                               arena_prof_promoted(q, usize);
+                       } else
+                               usize = isalloc(q);
                } else {
                        q = iralloc(p, size, extra, alignment, zero, no_move);
                        if (q == NULL)
                } else {
                        q = iralloc(p, size, extra, alignment, zero, no_move);
                        if (q == NULL)
index 8370042b482b4e129a37b3ee86e12d50c9163e67..8a144b4e46c9e7e01e4b8df45021f4dedf2071b1 100644 (file)
@@ -474,11 +474,23 @@ prof_lookup(prof_bt_t *bt)
                        /*
                         * Artificially raise curobjs, in order to avoid a race
                         * condition with prof_ctx_merge()/prof_ctx_destroy().
                        /*
                         * Artificially raise curobjs, in order to avoid a race
                         * condition with prof_ctx_merge()/prof_ctx_destroy().
+                        *
+                        * No locking is necessary for ctx here because no other
+                        * threads have had the opportunity to fetch it from
+                        * bt2ctx yet.
                         */
                        ctx.p->cnt_merged.curobjs++;
                        new_ctx = true;
                         */
                        ctx.p->cnt_merged.curobjs++;
                        new_ctx = true;
-               } else
+               } else {
+                       /*
+                        * Artificially raise curobjs, in order to avoid a race
+                        * condition with prof_ctx_merge()/prof_ctx_destroy().
+                        */
+                       malloc_mutex_lock(&ctx.p->lock);
+                       ctx.p->cnt_merged.curobjs++;
+                       malloc_mutex_unlock(&ctx.p->lock);
                        new_ctx = false;
                        new_ctx = false;
+               }
                prof_leave();
 
                /* Link a prof_thd_cnt_t into ctx for this thread. */
                prof_leave();
 
                /* Link a prof_thd_cnt_t into ctx for this thread. */
@@ -491,8 +503,9 @@ prof_lookup(prof_bt_t *bt)
                         */
                        ret.p = ql_last(&prof_tdata->lru_ql, lru_link);
                        assert(ret.v != NULL);
                         */
                        ret.p = ql_last(&prof_tdata->lru_ql, lru_link);
                        assert(ret.v != NULL);
-                       ckh_remove(&prof_tdata->bt2cnt, ret.p->ctx->bt, NULL,
-                           NULL);
+                       if (ckh_remove(&prof_tdata->bt2cnt, ret.p->ctx->bt,
+                           NULL, NULL))
+                               assert(false);
                        ql_remove(&prof_tdata->lru_ql, ret.p, lru_link);
                        prof_ctx_merge(ret.p->ctx, ret.p);
                        /* ret can now be re-used. */
                        ql_remove(&prof_tdata->lru_ql, ret.p, lru_link);
                        prof_ctx_merge(ret.p->ctx, ret.p);
                        /* ret can now be re-used. */
@@ -503,11 +516,8 @@ prof_lookup(prof_bt_t *bt)
                        /* Allocate and partially initialize a new cnt. */
                        ret.v = imalloc(sizeof(prof_thr_cnt_t));
                        if (ret.p == NULL) {
                        /* Allocate and partially initialize a new cnt. */
                        ret.v = imalloc(sizeof(prof_thr_cnt_t));
                        if (ret.p == NULL) {
-                               if (new_ctx) {
-                                       malloc_mutex_lock(&ctx.p->lock);
-                                       ctx.p->cnt_merged.curobjs--;
-                                       malloc_mutex_unlock(&ctx.p->lock);
-                               }
+                               if (new_ctx)
+                                       prof_ctx_destroy(ctx.p);
                                return (NULL);
                        }
                        ql_elm_new(ret.p, cnts_link);
                                return (NULL);
                        }
                        ql_elm_new(ret.p, cnts_link);
@@ -518,19 +528,15 @@ prof_lookup(prof_bt_t *bt)
                ret.p->epoch = 0;
                memset(&ret.p->cnts, 0, sizeof(prof_cnt_t));
                if (ckh_insert(&prof_tdata->bt2cnt, btkey.v, ret.v)) {
                ret.p->epoch = 0;
                memset(&ret.p->cnts, 0, sizeof(prof_cnt_t));
                if (ckh_insert(&prof_tdata->bt2cnt, btkey.v, ret.v)) {
-                       if (new_ctx) {
-                               malloc_mutex_lock(&ctx.p->lock);
-                               ctx.p->cnt_merged.curobjs--;
-                               malloc_mutex_unlock(&ctx.p->lock);
-                       }
+                       if (new_ctx)
+                               prof_ctx_destroy(ctx.p);
                        idalloc(ret.v);
                        return (NULL);
                }
                ql_head_insert(&prof_tdata->lru_ql, ret.p, lru_link);
                malloc_mutex_lock(&ctx.p->lock);
                ql_tail_insert(&ctx.p->cnts_ql, ret.p, cnts_link);
                        idalloc(ret.v);
                        return (NULL);
                }
                ql_head_insert(&prof_tdata->lru_ql, ret.p, lru_link);
                malloc_mutex_lock(&ctx.p->lock);
                ql_tail_insert(&ctx.p->cnts_ql, ret.p, cnts_link);
-               if (new_ctx)
-                       ctx.p->cnt_merged.curobjs--;
+               ctx.p->cnt_merged.curobjs--;
                malloc_mutex_unlock(&ctx.p->lock);
        } else {
                /* Move ret to the front of the LRU. */
                malloc_mutex_unlock(&ctx.p->lock);
        } else {
                /* Move ret to the front of the LRU. */
@@ -644,11 +650,10 @@ prof_ctx_destroy(prof_ctx_t *ctx)
 
        /*
         * Check that ctx is still unused by any thread cache before destroying
 
        /*
         * Check that ctx is still unused by any thread cache before destroying
-        * it.  prof_lookup() interlocks bt2ctx_mtx and ctx->lock in order to
-        * avoid a race condition with this function, and prof_ctx_merge()
-        * artificially raises ctx->cnt_merged.curobjs in order to avoid a race
-        * between the main body of prof_ctx_merge() and entry into this
-        * function.
+        * it.  prof_lookup() artificially raises ctx->cnt_merge.curobjs in
+        * order to avoid a race condition with this function, as does
+        * prof_ctx_merge() in order to avoid a race between the main body of
+        * prof_ctx_merge() and entry into this function.
         */
        prof_enter();
        malloc_mutex_lock(&ctx->lock);
         */
        prof_enter();
        malloc_mutex_lock(&ctx->lock);
@@ -657,7 +662,8 @@ prof_ctx_destroy(prof_ctx_t *ctx)
                assert(ctx->cnt_merged.accumobjs == 0);
                assert(ctx->cnt_merged.accumbytes == 0);
                /* Remove ctx from bt2ctx. */
                assert(ctx->cnt_merged.accumobjs == 0);
                assert(ctx->cnt_merged.accumbytes == 0);
                /* Remove ctx from bt2ctx. */
-               ckh_remove(&bt2ctx, ctx->bt, NULL, NULL);
+               if (ckh_remove(&bt2ctx, ctx->bt, NULL, NULL))
+                       assert(false);
                prof_leave();
                /* Destroy ctx. */
                malloc_mutex_unlock(&ctx->lock);
                prof_leave();
                /* Destroy ctx. */
                malloc_mutex_unlock(&ctx->lock);
@@ -665,7 +671,10 @@ prof_ctx_destroy(prof_ctx_t *ctx)
                malloc_mutex_destroy(&ctx->lock);
                idalloc(ctx);
        } else {
                malloc_mutex_destroy(&ctx->lock);
                idalloc(ctx);
        } else {
-               /* Compensate for increment in prof_ctx_merge(). */
+               /*
+                * Compensate for increment in prof_ctx_merge() or
+                * prof_lookup().
+                */
                ctx->cnt_merged.curobjs--;
                malloc_mutex_unlock(&ctx->lock);
                prof_leave();
                ctx->cnt_merged.curobjs--;
                malloc_mutex_unlock(&ctx->lock);
                prof_leave();
@@ -1072,7 +1081,7 @@ prof_bt_hash(const void *key, unsigned minbits, size_t *hash1, size_t *hash2)
        } else {
                ret1 = h;
                ret2 = hash(bt->vec, bt->len * sizeof(void *),
        } else {
                ret1 = h;
                ret2 = hash(bt->vec, bt->len * sizeof(void *),
-                   0x8432a476666bbc13U);
+                   0x8432a476666bbc13LLU);
        }
 
        *hash1 = ret1;
        }
 
        *hash1 = ret1;
@@ -1109,7 +1118,6 @@ prof_tdata_init(void)
 
        prof_tdata->vec = imalloc(sizeof(void *) * prof_bt_max);
        if (prof_tdata->vec == NULL) {
 
        prof_tdata->vec = imalloc(sizeof(void *) * prof_bt_max);
        if (prof_tdata->vec == NULL) {
-
                ckh_delete(&prof_tdata->bt2cnt);
                idalloc(prof_tdata);
                return (NULL);
                ckh_delete(&prof_tdata->bt2cnt);
                idalloc(prof_tdata);
                return (NULL);
@@ -1127,33 +1135,26 @@ prof_tdata_init(void)
 static void
 prof_tdata_cleanup(void *arg)
 {
 static void
 prof_tdata_cleanup(void *arg)
 {
-       prof_tdata_t *prof_tdata;
+       prof_thr_cnt_t *cnt;
+       prof_tdata_t *prof_tdata = (prof_tdata_t *)arg;
 
 
-       prof_tdata = PROF_TCACHE_GET();
-       if (prof_tdata != NULL) {
-               prof_thr_cnt_t *cnt;
-
-               /*
-                * Delete the hash table.  All of its contents can still be
-                * iterated over via the LRU.
-                */
-               ckh_delete(&prof_tdata->bt2cnt);
+       /*
+        * Delete the hash table.  All of its contents can still be iterated
+        * over via the LRU.
+        */
+       ckh_delete(&prof_tdata->bt2cnt);
 
 
-               /*
-                * Iteratively merge cnt's into the global stats and delete
-                * them.
-                */
-               while ((cnt = ql_last(&prof_tdata->lru_ql, lru_link)) != NULL) {
-                       prof_ctx_merge(cnt->ctx, cnt);
-                       ql_remove(&prof_tdata->lru_ql, cnt, lru_link);
-                       idalloc(cnt);
-               }
+       /* Iteratively merge cnt's into the global stats and delete them. */
+       while ((cnt = ql_last(&prof_tdata->lru_ql, lru_link)) != NULL) {
+               ql_remove(&prof_tdata->lru_ql, cnt, lru_link);
+               prof_ctx_merge(cnt->ctx, cnt);
+               idalloc(cnt);
+       }
 
 
-               idalloc(prof_tdata->vec);
+       idalloc(prof_tdata->vec);
 
 
-               idalloc(prof_tdata);
-               PROF_TCACHE_SET(NULL);
-       }
+       idalloc(prof_tdata);
+       PROF_TCACHE_SET(NULL);
 }
 
 void
 }
 
 void
index cbbbb5ba6dcd22edc2e49a01c22fb72b06a9b6d4..dc172e425c0f7aee19ac024c9090e92ae4957153 100644 (file)
@@ -748,7 +748,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
                                                ninitialized++;
                                }
 
                                                ninitialized++;
                                }
 
-                               if (ninitialized > 1) {
+                               if (ninitialized > 1 || unmerged == false) {
                                        /* Print merged arena stats. */
                                        malloc_cprintf(write_cb, cbopaque,
                                            "\nMerged arenas stats:\n");
                                        /* Print merged arena stats. */
                                        malloc_cprintf(write_cb, cbopaque,
                                            "\nMerged arenas stats:\n");
index a8cadebc3d6175055f05ccf9267ed1889067f2cc..ccf326bb523d612273843f00dbf10962e7d53f94 100644 (file)
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include <string.h>
+#include <assert.h>
 
 #define        JEMALLOC_MANGLE
 #include "jemalloc_test.h"
 
 #define        JEMALLOC_MANGLE
 #include "jemalloc_test.h"
 int
 main(void)
 {
 int
 main(void)
 {
+       size_t pagesize;
        void *p, *q;
        size_t sz, tsz;
        int r;
 
        fprintf(stderr, "Test begin\n");
 
        void *p, *q;
        size_t sz, tsz;
        int r;
 
        fprintf(stderr, "Test begin\n");
 
+       /* Get page size. */
+       {
+               long result = sysconf(_SC_PAGESIZE);
+               assert(result != -1);
+               pagesize = (size_t)result;
+       }
+
        r = JEMALLOC_P(allocm)(&p, &sz, 42, 0);
        if (r != ALLOCM_SUCCESS) {
                fprintf(stderr, "Unexpected allocm() error\n");
        r = JEMALLOC_P(allocm)(&p, &sz, 42, 0);
        if (r != ALLOCM_SUCCESS) {
                fprintf(stderr, "Unexpected allocm() error\n");
@@ -66,7 +76,7 @@ main(void)
        p = q;
        sz = tsz;
 
        p = q;
        sz = tsz;
 
-       r = JEMALLOC_P(rallocm)(&q, &tsz, 8192, 0, 0);
+       r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*2, 0, 0);
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q == p)
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q == p)
@@ -78,7 +88,7 @@ main(void)
        p = q;
        sz = tsz;
 
        p = q;
        sz = tsz;
 
-       r = JEMALLOC_P(rallocm)(&q, &tsz, 16384, 0, 0);
+       r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*4, 0, 0);
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (tsz == sz) {
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (tsz == sz) {
@@ -88,7 +98,7 @@ main(void)
        p = q;
        sz = tsz;
 
        p = q;
        sz = tsz;
 
-       r = JEMALLOC_P(rallocm)(&q, &tsz, 8192, 0, ALLOCM_NO_MOVE);
+       r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*2, 0, ALLOCM_NO_MOVE);
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q != p)
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q != p)
@@ -99,7 +109,7 @@ main(void)
        }
        sz = tsz;
 
        }
        sz = tsz;
 
-       r = JEMALLOC_P(rallocm)(&q, &tsz, 16384, 0, ALLOCM_NO_MOVE);
+       r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*4, 0, ALLOCM_NO_MOVE);
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q != p)
        if (r != ALLOCM_SUCCESS)
                fprintf(stderr, "Unexpected rallocm() error\n");
        if (q != p)