diff options
| author | Qi Wang <interwq@gwu.edu> | 2018-04-11 15:15:26 -0700 |
|---|---|---|
| committer | Qi Wang <interwq@gmail.com> | 2018-04-11 21:21:54 -0700 |
| commit | 3f0dc64c6b8c1fd77c819028013dacbc6d2ad6b6 (patch) | |
| tree | 5dd852ac332d4be0160c2a318052bd1e583aeb87 /src | |
| parent | 02585420c34e08db1de4c26f3d5bc808d6910131 (diff) | |
| download | platform_external_jemalloc_new-3f0dc64c6b8c1fd77c819028013dacbc6d2ad6b6.tar.gz platform_external_jemalloc_new-3f0dc64c6b8c1fd77c819028013dacbc6d2ad6b6.tar.bz2 platform_external_jemalloc_new-3f0dc64c6b8c1fd77c819028013dacbc6d2ad6b6.zip | |
Allow setting extent hooks on uninitialized auto arenas.
Setting extent hooks can result in initializing an unused auto arena. This is
useful to install extent hooks on auto arenas from the beginning.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ctl.c | 45 |
1 files changed, 33 insertions, 12 deletions
@@ -2251,20 +2251,41 @@ arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx); MIB_UNSIGNED(arena_ind, 1); - if (arena_ind < narenas_total_get() && (arena = - arena_get(tsd_tsdn(tsd), arena_ind, false)) != NULL) { - if (newp != NULL) { - extent_hooks_t *old_extent_hooks; - extent_hooks_t *new_extent_hooks - JEMALLOC_CC_SILENCE_INIT(NULL); - WRITE(new_extent_hooks, extent_hooks_t *); - old_extent_hooks = extent_hooks_set(tsd, arena, - new_extent_hooks); + if (arena_ind < narenas_total_get()) { + extent_hooks_t *old_extent_hooks; + arena = arena_get(tsd_tsdn(tsd), arena_ind, false); + if (arena == NULL) { + if (arena_ind >= narenas_auto) { + ret = EFAULT; + goto label_return; + } + old_extent_hooks = + (extent_hooks_t *)&extent_hooks_default; READ(old_extent_hooks, extent_hooks_t *); + if (newp != NULL) { + /* Initialize a new arena as a side effect. */ + extent_hooks_t *new_extent_hooks + JEMALLOC_CC_SILENCE_INIT(NULL); + WRITE(new_extent_hooks, extent_hooks_t *); + arena = arena_init(tsd_tsdn(tsd), arena_ind, + new_extent_hooks); + if (arena == NULL) { + ret = EFAULT; + goto label_return; + } + } } else { - extent_hooks_t *old_extent_hooks = - extent_hooks_get(arena); - READ(old_extent_hooks, extent_hooks_t *); + if (newp != NULL) { + extent_hooks_t *new_extent_hooks + JEMALLOC_CC_SILENCE_INIT(NULL); + WRITE(new_extent_hooks, extent_hooks_t *); + old_extent_hooks = extent_hooks_set(tsd, arena, + new_extent_hooks); + READ(old_extent_hooks, extent_hooks_t *); + } else { + old_extent_hooks = extent_hooks_get(arena); + READ(old_extent_hooks, extent_hooks_t *); + } } } else { ret = EFAULT; |
