Do not register allocation on fail

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-07-05 13:21:23 +00:00
committed by Compute-Runtime-Automation
parent 83db85cf86
commit 449c0dc856
2 changed files with 13 additions and 1 deletions

View File

@@ -3461,6 +3461,16 @@ TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryFor
EXPECT_FALSE(memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData));
}
TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrFailsThenNullPtrReturnedAndAllocationIsNotRegistered) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
MockAllocationProperties properties(0u, 64 * GB);
auto ptr = reinterpret_cast<const void *>(0x100000000000);
EXPECT_FALSE(memoryManager->allocateGraphicsMemoryInPreferredPool(properties, ptr));
EXPECT_EQ(memoryManager->getSysMemAllocs().size(), 0u);
}
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWithHostPtrIsPassedAndWhenAllocUserptrFailsThenFails) {
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);

View File

@@ -463,7 +463,9 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(const A
}
if (!allocation && status == AllocationStatus::RetryInNonDevicePool) {
allocation = allocateGraphicsMemory(allocationData);
this->registerSysMemAlloc(allocation);
if (allocation) {
this->registerSysMemAlloc(allocation);
}
}
FileLoggerInstance().logAllocation(allocation);
registerAllocationInOs(allocation);