PA: Add pa_extra.c and put PA forking there.
This commit is contained in:
parent
8164fad404
commit
f29f6090f5
@ -127,6 +127,7 @@ C_SRCS := $(srcroot)src/jemalloc.c \
|
|||||||
$(srcroot)src/mutex_pool.c \
|
$(srcroot)src/mutex_pool.c \
|
||||||
$(srcroot)src/nstime.c \
|
$(srcroot)src/nstime.c \
|
||||||
$(srcroot)src/pa.c \
|
$(srcroot)src/pa.c \
|
||||||
|
$(srcroot)src/pa_extra.c \
|
||||||
$(srcroot)src/pages.c \
|
$(srcroot)src/pages.c \
|
||||||
$(srcroot)src/prng.c \
|
$(srcroot)src/prng.c \
|
||||||
$(srcroot)src/prof.c \
|
$(srcroot)src/prof.c \
|
||||||
|
@ -211,4 +211,22 @@ bool pa_maybe_decay_purge(tsdn_t *tsdn, pa_shard_t *shard, decay_t *decay,
|
|||||||
pa_shard_decay_stats_t *decay_stats, ecache_t *ecache,
|
pa_shard_decay_stats_t *decay_stats, ecache_t *ecache,
|
||||||
pa_decay_purge_setting_t decay_purge_setting);
|
pa_decay_purge_setting_t decay_purge_setting);
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* Various bits of "boring" functionality that are still part of this module,
|
||||||
|
* but that we relegate to pa_extra.c, to keep the core logic in pa.c as
|
||||||
|
* readable as possible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These fork phases are synchronized with the arena fork phase numbering to
|
||||||
|
* make it easy to keep straight. That's why there's no prefork1.
|
||||||
|
*/
|
||||||
|
void pa_shard_prefork0(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
void pa_shard_prefork2(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
void pa_shard_prefork3(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
void pa_shard_prefork4(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
void pa_shard_postfork_parent(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
void pa_shard_postfork_child(tsdn_t *tsdn, pa_shard_t *shard);
|
||||||
|
|
||||||
#endif /* JEMALLOC_INTERNAL_PA_H */
|
#endif /* JEMALLOC_INTERNAL_PA_H */
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
<ClCompile Include="..\..\..\..\src\mutex_pool.c" />
|
<ClCompile Include="..\..\..\..\src\mutex_pool.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\nstime.c" />
|
<ClCompile Include="..\..\..\..\src\nstime.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\pa.c" />
|
<ClCompile Include="..\..\..\..\src\pa.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\src\pa_extra.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\pages.c" />
|
<ClCompile Include="..\..\..\..\src\pages.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\prng.c" />
|
<ClCompile Include="..\..\..\..\src\prng.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\prof.c" />
|
<ClCompile Include="..\..\..\..\src\prof.c" />
|
||||||
|
@ -88,6 +88,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\src\pa.c">
|
<ClCompile Include="..\..\..\..\src\pa.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\src\pa_extra.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\src\pages.c">
|
<ClCompile Include="..\..\..\..\src\pages.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
<ClCompile Include="..\..\..\..\src\mutex_pool.c" />
|
<ClCompile Include="..\..\..\..\src\mutex_pool.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\nstime.c" />
|
<ClCompile Include="..\..\..\..\src\nstime.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\pa.c" />
|
<ClCompile Include="..\..\..\..\src\pa.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\src\pa_extra.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\pages.c" />
|
<ClCompile Include="..\..\..\..\src\pages.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\prng.c" />
|
<ClCompile Include="..\..\..\..\src\prng.c" />
|
||||||
<ClCompile Include="..\..\..\..\src\prof.c" />
|
<ClCompile Include="..\..\..\..\src\prof.c" />
|
||||||
|
@ -88,6 +88,9 @@
|
|||||||
<ClCompile Include="..\..\..\..\src\pa.c">
|
<ClCompile Include="..\..\..\..\src\pa.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\..\src\pa_extra.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\..\src\pages.c">
|
<ClCompile Include="..\..\..\..\src\pages.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
27
src/arena.c
27
src/arena.c
@ -1739,8 +1739,7 @@ arena_boot(sc_data_t *sc_data) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
arena_prefork0(tsdn_t *tsdn, arena_t *arena) {
|
arena_prefork0(tsdn_t *tsdn, arena_t *arena) {
|
||||||
malloc_mutex_prefork(tsdn, &arena->pa_shard.decay_dirty.mtx);
|
pa_shard_prefork0(tsdn, &arena->pa_shard);
|
||||||
malloc_mutex_prefork(tsdn, &arena->pa_shard.decay_muzzy.mtx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1752,19 +1751,17 @@ arena_prefork1(tsdn_t *tsdn, arena_t *arena) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
arena_prefork2(tsdn_t *tsdn, arena_t *arena) {
|
arena_prefork2(tsdn_t *tsdn, arena_t *arena) {
|
||||||
ecache_grow_prefork(tsdn, &arena->pa_shard.ecache_grow);
|
pa_shard_prefork2(tsdn, &arena->pa_shard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arena_prefork3(tsdn_t *tsdn, arena_t *arena) {
|
arena_prefork3(tsdn_t *tsdn, arena_t *arena) {
|
||||||
ecache_prefork(tsdn, &arena->pa_shard.ecache_dirty);
|
pa_shard_prefork3(tsdn, &arena->pa_shard);
|
||||||
ecache_prefork(tsdn, &arena->pa_shard.ecache_muzzy);
|
|
||||||
ecache_prefork(tsdn, &arena->pa_shard.ecache_retained);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
arena_prefork4(tsdn_t *tsdn, arena_t *arena) {
|
arena_prefork4(tsdn_t *tsdn, arena_t *arena) {
|
||||||
edata_cache_prefork(tsdn, &arena->pa_shard.edata_cache);
|
pa_shard_prefork4(tsdn, &arena->pa_shard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1798,13 +1795,7 @@ arena_postfork_parent(tsdn_t *tsdn, arena_t *arena) {
|
|||||||
}
|
}
|
||||||
malloc_mutex_postfork_parent(tsdn, &arena->large_mtx);
|
malloc_mutex_postfork_parent(tsdn, &arena->large_mtx);
|
||||||
base_postfork_parent(tsdn, arena->base);
|
base_postfork_parent(tsdn, arena->base);
|
||||||
edata_cache_postfork_parent(tsdn, &arena->pa_shard.edata_cache);
|
pa_shard_postfork_parent(tsdn, &arena->pa_shard);
|
||||||
ecache_postfork_parent(tsdn, &arena->pa_shard.ecache_dirty);
|
|
||||||
ecache_postfork_parent(tsdn, &arena->pa_shard.ecache_muzzy);
|
|
||||||
ecache_postfork_parent(tsdn, &arena->pa_shard.ecache_retained);
|
|
||||||
ecache_grow_postfork_parent(tsdn, &arena->pa_shard.ecache_grow);
|
|
||||||
malloc_mutex_postfork_parent(tsdn, &arena->pa_shard.decay_dirty.mtx);
|
|
||||||
malloc_mutex_postfork_parent(tsdn, &arena->pa_shard.decay_muzzy.mtx);
|
|
||||||
if (config_stats) {
|
if (config_stats) {
|
||||||
malloc_mutex_postfork_parent(tsdn, &arena->tcache_ql_mtx);
|
malloc_mutex_postfork_parent(tsdn, &arena->tcache_ql_mtx);
|
||||||
}
|
}
|
||||||
@ -1844,13 +1835,7 @@ arena_postfork_child(tsdn_t *tsdn, arena_t *arena) {
|
|||||||
}
|
}
|
||||||
malloc_mutex_postfork_child(tsdn, &arena->large_mtx);
|
malloc_mutex_postfork_child(tsdn, &arena->large_mtx);
|
||||||
base_postfork_child(tsdn, arena->base);
|
base_postfork_child(tsdn, arena->base);
|
||||||
edata_cache_postfork_child(tsdn, &arena->pa_shard.edata_cache);
|
pa_shard_postfork_child(tsdn, &arena->pa_shard);
|
||||||
ecache_postfork_child(tsdn, &arena->pa_shard.ecache_dirty);
|
|
||||||
ecache_postfork_child(tsdn, &arena->pa_shard.ecache_muzzy);
|
|
||||||
ecache_postfork_child(tsdn, &arena->pa_shard.ecache_retained);
|
|
||||||
ecache_grow_postfork_child(tsdn, &arena->pa_shard.ecache_grow);
|
|
||||||
malloc_mutex_postfork_child(tsdn, &arena->pa_shard.decay_dirty.mtx);
|
|
||||||
malloc_mutex_postfork_child(tsdn, &arena->pa_shard.decay_muzzy.mtx);
|
|
||||||
if (config_stats) {
|
if (config_stats) {
|
||||||
malloc_mutex_postfork_child(tsdn, &arena->tcache_ql_mtx);
|
malloc_mutex_postfork_child(tsdn, &arena->tcache_ql_mtx);
|
||||||
}
|
}
|
||||||
|
55
src/pa_extra.c
Normal file
55
src/pa_extra.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||||
|
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is logically part of the PA module. While pa.c contains the core
|
||||||
|
* allocator functionality, this file contains boring integration functionality;
|
||||||
|
* things like the pre- and post- fork handlers, and stats merging for CTL
|
||||||
|
* refreshes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_prefork0(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
malloc_mutex_prefork(tsdn, &shard->decay_dirty.mtx);
|
||||||
|
malloc_mutex_prefork(tsdn, &shard->decay_muzzy.mtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_prefork2(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
ecache_grow_prefork(tsdn, &shard->ecache_grow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_prefork3(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
ecache_prefork(tsdn, &shard->ecache_dirty);
|
||||||
|
ecache_prefork(tsdn, &shard->ecache_muzzy);
|
||||||
|
ecache_prefork(tsdn, &shard->ecache_retained);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_prefork4(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
edata_cache_prefork(tsdn, &shard->edata_cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_postfork_parent(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
edata_cache_postfork_parent(tsdn, &shard->edata_cache);
|
||||||
|
ecache_postfork_parent(tsdn, &shard->ecache_dirty);
|
||||||
|
ecache_postfork_parent(tsdn, &shard->ecache_muzzy);
|
||||||
|
ecache_postfork_parent(tsdn, &shard->ecache_retained);
|
||||||
|
ecache_grow_postfork_parent(tsdn, &shard->ecache_grow);
|
||||||
|
malloc_mutex_postfork_parent(tsdn, &shard->decay_dirty.mtx);
|
||||||
|
malloc_mutex_postfork_parent(tsdn, &shard->decay_muzzy.mtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pa_shard_postfork_child(tsdn_t *tsdn, pa_shard_t *shard) {
|
||||||
|
edata_cache_postfork_child(tsdn, &shard->edata_cache);
|
||||||
|
ecache_postfork_child(tsdn, &shard->ecache_dirty);
|
||||||
|
ecache_postfork_child(tsdn, &shard->ecache_muzzy);
|
||||||
|
ecache_postfork_child(tsdn, &shard->ecache_retained);
|
||||||
|
ecache_grow_postfork_child(tsdn, &shard->ecache_grow);
|
||||||
|
malloc_mutex_postfork_child(tsdn, &shard->decay_dirty.mtx);
|
||||||
|
malloc_mutex_postfork_child(tsdn, &shard->decay_muzzy.mtx);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user