fix: residency leak

- properly add needsMakeResidentBeforeLock in Wddm Allocation so while
destroying the allocation it is properly removed from wddm residency controller
- add cannot trim further flag after eviction
- fix debug variable

Related-To: NEO-11731
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2024-06-25 14:05:54 +00:00
committed by Compute-Runtime-Automation
parent 1cba900ad9
commit c817d15b59
5 changed files with 18 additions and 6 deletions

View File

@@ -1129,6 +1129,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
EXPECT_EQ(0u, mockTemporaryResources->resourceHandles.size());
EXPECT_EQ(1u, mockWddm.evictResult.called);
EXPECT_EQ(allocation.handle, mockWddm.makeResidentResult.handlePack[0]);
EXPECT_TRUE(mockWddm.makeResidentResult.cantTrimFurther);
EXPECT_EQ(3u, mockWddm.makeResidentResult.called);
}

View File

@@ -1331,13 +1331,19 @@ TEST_F(WddmMemoryManagerSimpleTest, whenAllocationCreatedFromSharedHandleIsDestr
EXPECT_EQ(7u, destroyArg.AllocationCount);
gdi->getDestroyArg().AllocationCount = 0;
}
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationThatDoesntNeedMakeResidentBeforeLockThenDontEvictAllocationFromWddmTemporaryResources) {
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationIfDeviceRequiresMakeResidentPriorToLockThenCallEvictDoNotCallOtherwise) {
DebugManagerStateRestore restorer;
debugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(GfxMemoryAllocationMethod::useUmdSystemPtr));
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
memoryManager->lockResource(allocation);
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock());
auto makeResidentPriorToLockRequired = memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[0u]->getHelper<GfxCoreHelper>().makeResidentBeforeLockNeeded(allocation->needsMakeResidentBeforeLock());
EXPECT_EQ(makeResidentPriorToLockRequired, allocation->needsMakeResidentBeforeLock());
memoryManager->freeGraphicsMemory(allocation);
if (makeResidentPriorToLockRequired) {
EXPECT_EQ(1u, mockTemporaryResources->removeResourceResult.called);
} else {
EXPECT_EQ(0u, mockTemporaryResources->removeResourceResult.called);
}
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
}
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingNotLockedAllocationThatDoesntNeedMakeResidentBeforeLockThenDontEvictAllocationFromWddmTemporaryResources) {