Skip to content

Commit

Permalink
Fix extent_quantize() to handle greater-than-huge-size extents.
Browse files Browse the repository at this point in the history
Allocation requests can't directly create extents that exceed
HUGE_MAXCLASS, but extent merging can create them.

This fixes a regression caused by
8a03cf0 (Implement cache index
randomization for large allocations.) and first released in 4.0.0.

This resolves jemalloc#497.
  • Loading branch information
jasone committed Nov 12, 2016
1 parent e916d55 commit 2cdf07a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@

/******************************************************************************/

/*
* 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)
{
size_t ret;
szind_t ind;

/*
* Round down to the nearest chunk size that can actually be requested
* during normal huge allocation.
*/
return (index2size(size2index(size + 1) - 1));
assert(size > 0);

ind = size2index(size + 1);
if (ind == NSIZES) {
/*
* Allocation requests can't directly create extents that exceed
* HUGE_MAXCLASS, but extent merging can create them.
*/
return (HUGE_MAXCLASS);
}
ret = index2size(ind - 1);
assert(ret <= size);
return (ret);
}

JEMALLOC_INLINE_C int
Expand Down

0 comments on commit 2cdf07a

Please sign in to comment.