diff options
author | Qi Wang <interwq@gwu.edu> | 2019-03-29 03:42:40 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2019-04-04 20:49:37 (GMT) |
commit | 93084cdc8960935d0acc93424dddd3a79a86e2da (patch) | |
tree | a26b01e44e61c61c914846381bbb45d72879c983 | |
parent | 9aab3f2be041b09f42375d3bf173d1a8795a1ee9 (diff) | |
download | jemalloc-93084cdc8960935d0acc93424dddd3a79a86e2da.zip jemalloc-93084cdc8960935d0acc93424dddd3a79a86e2da.tar.gz jemalloc-93084cdc8960935d0acc93424dddd3a79a86e2da.tar.bz2 |
Ensure page alignment on extent_alloc.
This is discovered and suggested by @jasone in #1468. When custom extent hooks
are in use, we should ensure page alignment on the extent alloc path, instead of
relying on the user hooks to do so.
-rw-r--r-- | src/extent.c | 7 | ||||
-rw-r--r-- | src/extent_dss.c | 2 | ||||
-rw-r--r-- | src/extent_mmap.c | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/extent.c b/src/extent.c index 814f0a3..66cbf05 100644 --- a/src/extent.c +++ b/src/extent.c @@ -1256,7 +1256,7 @@ extent_alloc_default(extent_hooks_t *extent_hooks, void *new_addr, size_t size, assert(arena != NULL); return extent_alloc_default_impl(tsdn, arena, new_addr, size, - alignment, zero, commit); + ALIGNMENT_CEILING(alignment, PAGE), zero, commit); } static void @@ -1493,14 +1493,15 @@ extent_alloc_wrapper_hard(tsdn_t *tsdn, arena_t *arena, return NULL; } void *addr; + size_t palignment = ALIGNMENT_CEILING(alignment, PAGE); if (*r_extent_hooks == &extent_hooks_default) { /* Call directly to propagate tsdn. */ addr = extent_alloc_default_impl(tsdn, arena, new_addr, esize, - alignment, zero, commit); + palignment, zero, commit); } else { extent_hook_pre_reentrancy(tsdn, arena); addr = (*r_extent_hooks)->alloc(*r_extent_hooks, new_addr, - esize, alignment, zero, commit, arena_ind_get(arena)); + esize, palignment, zero, commit, arena_ind_get(arena)); extent_hook_post_reentrancy(tsdn); } if (addr == NULL) { diff --git a/src/extent_dss.c b/src/extent_dss.c index 6c56cf6..69a7bee 100644 --- a/src/extent_dss.c +++ b/src/extent_dss.c @@ -113,7 +113,7 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size, cassert(have_dss); assert(size > 0); - assert(alignment > 0); + assert(alignment == ALIGNMENT_CEILING(alignment, PAGE)); /* * sbrk() uses a signed increment argument, so take care not to diff --git a/src/extent_mmap.c b/src/extent_mmap.c index 8d607dc..17fd1c8 100644 --- a/src/extent_mmap.c +++ b/src/extent_mmap.c @@ -21,8 +21,8 @@ bool opt_retain = void * extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero, bool *commit) { - void *ret = pages_map(new_addr, size, ALIGNMENT_CEILING(alignment, - PAGE), commit); + assert(alignment == ALIGNMENT_CEILING(alignment, PAGE)); + void *ret = pages_map(new_addr, size, alignment, commit); if (ret == NULL) { return NULL; } |