Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gpgmm/common/BuddyMemoryAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace gpgmm {
std::unique_ptr<MemoryAllocation> subAllocation;
GPGMM_TRY_ASSIGN(TrySubAllocateMemory(
&mBuddyBlockAllocator, allocationSize, request.Alignment,
request.NeverAllocate,
[&](const auto& block) -> MemoryBase* {
const uint64_t memoryIndex = GetMemoryIndex(block->Offset);
std::unique_ptr<MemoryAllocation> memoryAllocation =
Expand Down
12 changes: 8 additions & 4 deletions src/gpgmm/common/MemoryAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,20 @@ namespace gpgmm {
BlockAllocator* allocator,
uint64_t requestSize,
uint64_t alignment,
bool neverAllocate,
GetOrCreateMemoryFn&& GetOrCreateMemory) {
MemoryBlock* block = nullptr;
GPGMM_TRY_ASSIGN(allocator->TryAllocateBlock(requestSize, alignment), block);

MemoryBase* memory = GetOrCreateMemory(block);
if (memory == nullptr) {
DebugLog() << std::string(allocator->GetTypename()) +
" failed to sub-allocate memory range = ["
<< std::to_string(block->Offset) << ", "
<< std::to_string(block->Offset + block->Size) << ").";
// NeverAllocate always fails, so suppress it.
if (!neverAllocate) {
DebugLog() << std::string(allocator->GetTypename()) +
" failed to sub-allocate memory range = ["
<< std::to_string(block->Offset) << ", "
<< std::to_string(block->Offset + block->Size) << ").";
}
allocator->DeallocateBlock(block);
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/common/SlabMemoryAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace gpgmm {
std::unique_ptr<MemoryAllocation> subAllocation;
GPGMM_TRY_ASSIGN(
TrySubAllocateMemory(
&pFreeSlab->Allocator, mBlockSize, request.Alignment,
&pFreeSlab->Allocator, mBlockSize, request.Alignment, request.NeverAllocate,
[&](const auto& block) -> MemoryBase* {
// Re-use memory from the free slab.
if (pFreeSlab->Allocation != nullptr) {
Expand Down