diff options
author | Jason Evans <jasone@canonware.com> | 2016-11-04 04:14:59 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-11-04 05:33:35 (GMT) |
commit | 4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a (patch) | |
tree | 747d5a917ea38829d7e88a173da9160db3a4138e /src/extent.c | |
parent | ea9961acdbc9f7e2c95a3b55ce0ac1024af5d167 (diff) | |
download | jemalloc-4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a.zip jemalloc-4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a.tar.gz jemalloc-4a7852137d8b6598fdb90ea8e1fd3bc8a8b94a3a.tar.bz2 |
Fix extent_recycle()'s cache-oblivious padding support.
Add padding *after* computing the size class, so that the optimal size
class isn't skipped during search for a usable extent. This regression
was caused by b46261d58b449cc4c099ed2384451a2499688f0e (Implement
cache-oblivious support for huge size classes.).
Diffstat (limited to 'src/extent.c')
-rw-r--r-- | src/extent.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/extent.c b/src/extent.c index a802ad9..e190adc 100644 --- a/src/extent.c +++ b/src/extent.c @@ -427,12 +427,13 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks, assert(prev == NULL || extent_past_get(prev) == new_addr); } - size = usize + pad; - alloc_size = (new_addr != NULL) ? size : s2u(size + - PAGE_CEILING(alignment) - PAGE); - /* Beware size_t wrap-around. */ - if (alloc_size < usize) + alloc_size = ((new_addr != NULL) ? usize : s2u(usize + + PAGE_CEILING(alignment) - PAGE)) + pad; + if (alloc_size > LARGE_MAXCLASS + pad || alloc_size < usize) { + /* Too large, possibly wrapped around. */ return (NULL); + } + size = usize + pad; if (!locked) malloc_mutex_lock(tsdn, &arena->extents_mtx); extent_hooks_assure_initialized(arena, r_extent_hooks); |