diff options
author | Qi Wang <interwq@gwu.edu> | 2017-06-02 23:27:05 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-06-05 17:56:25 (GMT) |
commit | 3a813946fb9b0ad93279ea30834df917b261a5a5 (patch) | |
tree | 47bf3ff155c1486631b8a48f08e64f1f1eddf777 | |
parent | 530c07a45ba3ea744b280c9df5d94165839f7b09 (diff) | |
download | jemalloc-3a813946fb9b0ad93279ea30834df917b261a5a5.zip jemalloc-3a813946fb9b0ad93279ea30834df917b261a5a5.tar.gz jemalloc-3a813946fb9b0ad93279ea30834df917b261a5a5.tar.bz2 |
Take background thread lock when setting extent hooks.
-rw-r--r-- | include/jemalloc/internal/extent_externs.h | 3 | ||||
-rw-r--r-- | src/ctl.c | 2 | ||||
-rw-r--r-- | src/extent.c | 14 |
3 files changed, 15 insertions, 4 deletions
diff --git a/include/jemalloc/internal/extent_externs.h b/include/jemalloc/internal/extent_externs.h index acb3ef4..489a813 100644 --- a/include/jemalloc/internal/extent_externs.h +++ b/include/jemalloc/internal/extent_externs.h @@ -15,7 +15,8 @@ extent_t *extent_alloc(tsdn_t *tsdn, arena_t *arena); void extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent); extent_hooks_t *extent_hooks_get(arena_t *arena); -extent_hooks_t *extent_hooks_set(arena_t *arena, extent_hooks_t *extent_hooks); +extent_hooks_t *extent_hooks_set(tsd_t *tsd, arena_t *arena, + extent_hooks_t *extent_hooks); #ifdef JEMALLOC_JET size_t extent_size_quantize_floor(size_t size); @@ -2154,7 +2154,7 @@ arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, extent_hooks_t *new_extent_hooks JEMALLOC_CC_SILENCE_INIT(NULL); WRITE(new_extent_hooks, extent_hooks_t *); - old_extent_hooks = extent_hooks_set(arena, + old_extent_hooks = extent_hooks_set(tsd, arena, new_extent_hooks); READ(old_extent_hooks, extent_hooks_t *); } else { diff --git a/src/extent.c b/src/extent.c index fb7a146..e95858e 100644 --- a/src/extent.c +++ b/src/extent.c @@ -197,8 +197,18 @@ extent_hooks_get(arena_t *arena) { } extent_hooks_t * -extent_hooks_set(arena_t *arena, extent_hooks_t *extent_hooks) { - return base_extent_hooks_set(arena->base, extent_hooks); +extent_hooks_set(tsd_t *tsd, arena_t *arena, extent_hooks_t *extent_hooks) { + background_thread_info_t *info; + if (have_background_thread) { + info = arena_background_thread_info_get(arena); + malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx); + } + extent_hooks_t *ret = base_extent_hooks_set(arena->base, extent_hooks); + if (have_background_thread) { + malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx); + } + + return ret; } static void |