Skip to content

Commit

Permalink
AddressSpaceManager is not a PAL
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf-msr authored and mjp41 committed Sep 9, 2020
1 parent bf3c99d commit d79a818
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/mem/address_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace snmalloc
* usual complexity of a buddy allocator.
*/
template<SNMALLOC_CONCEPT(ConceptPAL) PAL>
class AddressSpaceManager : public PAL
class AddressSpaceManager
{
/**
* Stores the blocks of address space
Expand Down Expand Up @@ -181,8 +181,7 @@ namespace snmalloc
if constexpr (pal_supports<AlignedAllocation, PAL>)
{
if (size >= PAL::minimum_alloc_size)
return static_cast<PAL*>(this)->template reserve_aligned<committed>(
size);
return PAL::template reserve_aligned<committed>(size);
}

void* res;
Expand All @@ -197,17 +196,15 @@ namespace snmalloc
if constexpr (pal_supports<AlignedAllocation, PAL>)
{
block_size = PAL::minimum_alloc_size;
block = static_cast<PAL*>(this)->template reserve_aligned<false>(
block_size);
block = PAL::template reserve_aligned<false>(block_size);
}
else
{
// Need at least 2 times the space to guarantee alignment.
// Hold lock here as a race could cause additional requests to
// the PAL, and this could lead to suprious OOM. This is
// particularly bad if the PAL gives all the memory on first call.
auto block_and_size =
static_cast<PAL*>(this)->reserve_at_least(size * 2);
auto block_and_size = PAL::reserve_at_least(size * 2);
block = block_and_size.first;
block_size = block_and_size.second;

Expand Down

0 comments on commit d79a818

Please sign in to comment.