From 2d8397a36fbf402171812a208086f616a10f8a5b Mon Sep 17 00:00:00 2001 From: Compute-Runtime-Validation Date: Thu, 29 Aug 2024 14:39:38 +0200 Subject: [PATCH] Revert "fix: skip always resident allocations during trim" This reverts commit c9457bb5eb0e3a8fa1d4e3b18a14d8432a053947. Signed-off-by: Compute-Runtime-Validation --- .../os_interface/windows/trim_callback.cpp | 10 ---- .../wddm_residency_controller_tests.cpp | 49 ------------------- 2 files changed, 59 deletions(-) diff --git a/shared/source/os_interface/windows/trim_callback.cpp b/shared/source/os_interface/windows/trim_callback.cpp index cf666d6a08..529063d9ac 100644 --- a/shared/source/os_interface/windows/trim_callback.cpp +++ b/shared/source/os_interface/windows/trim_callback.cpp @@ -74,11 +74,6 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS continue; } - if (wddmAllocation->isAlwaysResident(osContextId)) { - allocationIter = allocations.erase(allocationIter); - continue; - } - if (wddmAllocation->fragmentsStorage.fragmentCount == 0) { for (auto i = 0u; i < wddmAllocation->getNumGmms(); i++) { handlesToEvict.push_back(wddmAllocation->getHandles()[i]); @@ -139,11 +134,6 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes, std::unique_ continue; } - if (wddmAllocation->isAlwaysResident(osContextId)) { - allocationIter = allocations.erase(allocationIter); - continue; - } - uint64_t sizeEvicted = 0; if (lastFence > *monitoredFence.cpuAddress) { diff --git a/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp index 57a5d4e1b0..39a9448f8d 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp @@ -561,55 +561,6 @@ TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenEvictedAlloca EXPECT_TRUE(allocation3.getResidencyData().resident[osContextId]); } -TEST_F(WddmResidencyControllerWithGdiTest, givenAlwaysResidentAllocationWhenTrimResidencyToBudgetCalledThenDontEvict) { - gdi->setNonZeroNumBytesToTrimInEvict(); - - MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper()); - - allocation.getResidencyData().resident[osContextId] = true; - allocation.getResidencyData().updateCompletionData(0, osContextId); - - *residencyController->getMonitoredFence().cpuAddress = 1; - residencyController->getMonitoredFence().lastSubmittedFence = 1; - residencyController->getMonitoredFence().currentFenceValue = 1; - - wddm->evictResult.called = 0; - - csr->getEvictionAllocations().push_back(&allocation); - allocation.updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContextId); - - std::mutex mtx; - std::unique_lock lock(mtx); - residencyController->trimResidencyToBudget(3 * 4096, lock); - - EXPECT_TRUE(allocation.getResidencyData().resident[osContextId]); -} - -TEST_F(WddmResidencyControllerWithGdiTest, givenAlwaysResidentAllocationWhenTrimResidencyCalledThenDontEvict) { - gdi->setNonZeroNumBytesToTrimInEvict(); - - MockWddmAllocation allocation(rootDeviceEnvironment->getGmmHelper()); - - allocation.getResidencyData().resident[osContextId] = true; - allocation.getResidencyData().updateCompletionData(0, osContextId); - - *residencyController->getMonitoredFence().cpuAddress = 1; - residencyController->getMonitoredFence().lastSubmittedFence = 1; - residencyController->getMonitoredFence().currentFenceValue = 1; - - wddm->evictResult.called = 0; - - csr->getEvictionAllocations().push_back(&allocation); - allocation.updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContextId); - - D3DKMT_TRIMNOTIFICATION trimNotification = {0}; - trimNotification.Flags.PeriodicTrim = 1; - trimNotification.NumBytesToTrim = 0; - residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); - - EXPECT_TRUE(allocation.getResidencyData().resident[osContextId]); -} - TEST_F(WddmResidencyControllerWithGdiTest, GivenLastFenceIsGreaterThanMonitoredWhenTrimmingToBudgetThenWaitForCpu) { gdi->setNonZeroNumBytesToTrimInEvict();