summaryrefslogtreecommitdiffstats
path: root/src/jemalloc.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-05-04 00:34:40 (GMT)
committerJason Evans <jasone@canonware.com>2016-05-04 00:34:40 (GMT)
commite02b83cc5e3c4d30f93dba945162e3aa58d962d6 (patch)
treedc1cf37bd624061c6351ea3a78f993d2a19310ac /src/jemalloc.c
parentdf900dbfaf4835d3efc06d771535f3e781544913 (diff)
parent2e5eb21184cccabc829265b5f5237f3c13563be6 (diff)
downloadjemalloc-4.1.1.zip
jemalloc-4.1.1.tar.gz
jemalloc-4.1.1.tar.bz2
Merge branch.4.1.1
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r--src/jemalloc.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 0735376..7120791 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -2644,7 +2644,8 @@ JEMALLOC_EXPORT void
_malloc_prefork(void)
#endif
{
- unsigned i, narenas;
+ unsigned i, j, narenas;
+ arena_t *arena;
#ifdef JEMALLOC_MUTEX_INIT_CB
if (!malloc_initialized())
@@ -2652,18 +2653,31 @@ _malloc_prefork(void)
#endif
assert(malloc_initialized());
+ narenas = narenas_total_get();
+
/* Acquire all mutexes in a safe order. */
ctl_prefork();
- prof_prefork();
malloc_mutex_prefork(&arenas_lock);
- for (i = 0, narenas = narenas_total_get(); i < narenas; i++) {
- arena_t *arena;
-
- if ((arena = arena_get(i, false)) != NULL)
- arena_prefork(arena);
+ prof_prefork0();
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < narenas; j++) {
+ if ((arena = arena_get(j, false)) != NULL) {
+ switch (i) {
+ case 0: arena_prefork0(arena); break;
+ case 1: arena_prefork1(arena); break;
+ case 2: arena_prefork2(arena); break;
+ default: not_reached();
+ }
+ }
+ }
}
- chunk_prefork();
base_prefork();
+ chunk_prefork();
+ for (i = 0; i < narenas; i++) {
+ if ((arena = arena_get(i, false)) != NULL)
+ arena_prefork3(arena);
+ }
+ prof_prefork1();
}
#ifndef JEMALLOC_MUTEX_INIT_CB
@@ -2683,16 +2697,16 @@ _malloc_postfork(void)
assert(malloc_initialized());
/* Release all mutexes, now that fork() has completed. */
- base_postfork_parent();
chunk_postfork_parent();
+ base_postfork_parent();
for (i = 0, narenas = narenas_total_get(); i < narenas; i++) {
arena_t *arena;
if ((arena = arena_get(i, false)) != NULL)
arena_postfork_parent(arena);
}
- malloc_mutex_postfork_parent(&arenas_lock);
prof_postfork_parent();
+ malloc_mutex_postfork_parent(&arenas_lock);
ctl_postfork_parent();
}
@@ -2704,16 +2718,16 @@ jemalloc_postfork_child(void)
assert(malloc_initialized());
/* Release all mutexes, now that fork() has completed. */
- base_postfork_child();
chunk_postfork_child();
+ base_postfork_child();
for (i = 0, narenas = narenas_total_get(); i < narenas; i++) {
arena_t *arena;
if ((arena = arena_get(i, false)) != NULL)
arena_postfork_child(arena);
}
- malloc_mutex_postfork_child(&arenas_lock);
prof_postfork_child();
+ malloc_mutex_postfork_child(&arenas_lock);
ctl_postfork_child();
}