mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 08:37:18 +03:00
Fix huge-aligned allocation.
This regression was caused by
b9408d77a6 (Fix/simplify chunk_recycle()
allocation size computations.).
This resolves #647.
This commit is contained in:
parent
ed19a48928
commit
1e2c9ef8d6
6 changed files with 141 additions and 11 deletions
|
|
@ -188,12 +188,17 @@ chunk_deregister(const void *chunk, const extent_node_t *node)
|
|||
static extent_node_t *
|
||||
chunk_first_best_fit(arena_t *arena, extent_tree_t *chunks_szsnad, size_t size)
|
||||
{
|
||||
extent_node_t *node;
|
||||
size_t qsize;
|
||||
extent_node_t key;
|
||||
|
||||
assert(size == CHUNK_CEILING(size));
|
||||
|
||||
extent_node_init(&key, arena, NULL, size, 0, false, false);
|
||||
return (extent_tree_szsnad_nsearch(chunks_szsnad, &key));
|
||||
qsize = extent_size_quantize_ceil(size);
|
||||
extent_node_init(&key, arena, NULL, qsize, 0, false, false);
|
||||
node = extent_tree_szsnad_nsearch(chunks_szsnad, &key);
|
||||
assert(node == NULL || extent_node_size_get(node) >= size);
|
||||
return node;
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
|||
37
src/extent.c
37
src/extent.c
|
|
@ -3,13 +3,11 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
/*
|
||||
* Round down to the nearest chunk size that can actually be requested during
|
||||
* normal huge allocation.
|
||||
*/
|
||||
JEMALLOC_INLINE_C size_t
|
||||
extent_quantize(size_t size)
|
||||
{
|
||||
#ifndef JEMALLOC_JET
|
||||
static
|
||||
#endif
|
||||
size_t
|
||||
extent_size_quantize_floor(size_t size) {
|
||||
size_t ret;
|
||||
szind_t ind;
|
||||
|
||||
|
|
@ -25,11 +23,32 @@ extent_quantize(size_t size)
|
|||
return (ret);
|
||||
}
|
||||
|
||||
size_t
|
||||
extent_size_quantize_ceil(size_t size) {
|
||||
size_t ret;
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
ret = extent_size_quantize_floor(size);
|
||||
if (ret < size) {
|
||||
/*
|
||||
* Skip a quantization that may have an adequately large extent,
|
||||
* because under-sized extents may be mixed in. This only
|
||||
* happens when an unusual size is requested, i.e. for aligned
|
||||
* allocation, and is just one of several places where linear
|
||||
* search would potentially find sufficiently aligned available
|
||||
* memory somewhere lower.
|
||||
*/
|
||||
ret = index2size(size2index(ret + 1));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
JEMALLOC_INLINE_C int
|
||||
extent_sz_comp(const extent_node_t *a, const extent_node_t *b)
|
||||
{
|
||||
size_t a_qsize = extent_quantize(extent_node_size_get(a));
|
||||
size_t b_qsize = extent_quantize(extent_node_size_get(b));
|
||||
size_t a_qsize = extent_size_quantize_floor(extent_node_size_get(a));
|
||||
size_t b_qsize = extent_size_quantize_floor(extent_node_size_get(b));
|
||||
|
||||
return ((a_qsize > b_qsize) - (a_qsize < b_qsize));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue