diff options
author | Qi Wang <interwq@gwu.edu> | 2017-08-30 23:17:04 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-08-31 18:03:34 (GMT) |
commit | a315688be0f38188f16fe89ee1657c7f596f8cbb (patch) | |
tree | 8ef41b30e33326d91b67078a7fb3a0c3b9671c49 /src/extent.c | |
parent | e55c3ca26758bcb7f6f1621fd690caa245f16942 (diff) | |
download | jemalloc-a315688be0f38188f16fe89ee1657c7f596f8cbb.zip jemalloc-a315688be0f38188f16fe89ee1657c7f596f8cbb.tar.gz jemalloc-a315688be0f38188f16fe89ee1657c7f596f8cbb.tar.bz2 |
Relax constraints on reentrancy for extent hooks.
If we guarantee no malloc activity in extent hooks, it's possible to make
customized hooks working on arena 0. Remove the non-a0 assertion to enable such
use cases.
Diffstat (limited to 'src/extent.c')
-rw-r--r-- | src/extent.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/extent.c b/src/extent.c index f464de4..3f1c76f 100644 --- a/src/extent.c +++ b/src/extent.c @@ -1028,7 +1028,18 @@ extent_alloc_default(extent_hooks_t *extent_hooks, void *new_addr, size_t size, static void extent_hook_pre_reentrancy(tsdn_t *tsdn, arena_t *arena) { tsd_t *tsd = tsdn_null(tsdn) ? tsd_fetch() : tsdn_tsd(tsdn); - pre_reentrancy(tsd, arena); + if (arena == arena_get(tsd_tsdn(tsd), 0, false)) { + /* + * The only legitimate case of customized extent hooks for a0 is + * hooks with no allocation activities. One such example is to + * place metadata on pre-allocated resources such as huge pages. + * In that case, rely on reentrancy_level checks to catch + * infinite recursions. + */ + pre_reentrancy(tsd, NULL); + } else { + pre_reentrancy(tsd, arena); + } } static void |