Skip to content

Commit

Permalink
mediumslab: stop assuming page-alignedness of objects
Browse files Browse the repository at this point in the history
With large pages (e.g. the 64K that Debian defaults to for ppc64), this
is a bit much to ask.  It's only not true for the bottom few medium size
classes, tho', as all sizes above 256K are multiples of 64K with the
current two mantissa bits size schedule.
  • Loading branch information
nwf committed May 23, 2020
1 parent 87dfd41 commit 3d3b048
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/mem/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,6 @@ namespace snmalloc
size_t size1 = sizeclass_to_size(sc1);
size_t size2 = sizeclass_to_size(sc2);

// All medium size classes are page aligned.
if (i > NUM_SMALL_CLASSES)
{
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(nullptr, size1));
}

SNMALLOC_ASSERT(sc1 == i);
SNMALLOC_ASSERT(sc1 == sc2);
SNMALLOC_ASSERT(size1 == size);
Expand Down
7 changes: 3 additions & 4 deletions src/mem/mediumslab.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ namespace snmalloc
void* p = pointer_offset(this, (static_cast<size_t>(index) << 8));
free--;

SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, OS_PAGE_SIZE));
size = bits::align_up(size, OS_PAGE_SIZE);

if constexpr (zero_mem == YesZero)
memory_provider.template zero<true>(p, size);
memory_provider.zero(p, size);
else
UNUSED(size);

return p;
}
Expand Down

0 comments on commit 3d3b048

Please sign in to comment.