From 8a506457d714a33ee8146164a0f5a86b3f2910aa Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Fri, 6 Aug 2021 12:57:10 +0000 Subject: [PATCH] Add debug flag to skip freeing resources. Signed-off-by: Michal Mrozek --- .../os_interface/linux/drm_memory_manager_tests.cpp | 10 ++++++++++ opencl/test/unit_test/test_files/igdrcl.config | 3 ++- shared/source/debug_settings/debug_variables_base.inl | 1 + .../source/os_interface/linux/drm_memory_manager.cpp | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 4a63e42995..e79fe765a2 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -4468,6 +4468,16 @@ TEST_F(DrmMemoryManagerTest, whenWddmMemoryManagerIsCreatedThenAlignmentSelector EXPECT_EQ(expectedAlignments, memoryManager.alignmentSelector.peekCandidateAlignments()); } +TEST_F(DrmMemoryManagerTest, whenDebugFlagToNotFreeResourcesIsSpecifiedThenFreeIsNotDoingAnything) { + DebugManagerStateRestore restorer; + DebugManager.flags.DoNotFreeResources.set(true); + TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment); + size_t sizeIn = 1024llu; + uint64_t gpuAddress = 0x1337llu; + DrmAllocation stackDrmAllocation(0u, GraphicsAllocation::AllocationType::BUFFER, nullptr, nullptr, gpuAddress, sizeIn, MemoryPool::System64KBPages); + memoryManager.freeGraphicsMemoryImpl(&stackDrmAllocation); +} + TEST_F(DrmMemoryManagerTest, given2MbPagesDisabledWhenWddmMemoryManagerIsCreatedThenAlignmentSelectorHasExpectedAlignments) { DebugManagerStateRestore restore{}; DebugManager.flags.AlignLocalMemoryVaTo2MB.set(0); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 5b73cedbf4..b09789e7b0 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -316,4 +316,5 @@ OverrideSystolicPipelineSelect = -1 OverrideSystolicInComputeWalker = -1 OverrideKernelSizeLimitForSmallDispatch = -1 SkipFlushingEventsOnGetStatusCalls = 0 -AllowUnrestrictedSize = 0 \ No newline at end of file +AllowUnrestrictedSize = 0 +DoNotFreeResources = 0 diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index b16c5a6d42..4f807ab33b 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -70,6 +70,7 @@ DECLARE_DEBUG_VARIABLE(bool, UseImmDataWriteModeOnPostSyncOperation, false, "Use DECLARE_DEBUG_VARIABLE(bool, DisableTimestampEvents, false, "Timestamp info will not be reported and events will only perform regular synchronization functions") DECLARE_DEBUG_VARIABLE(bool, EnableResourceTags, false, "Enable resource tagging in GMM") DECLARE_DEBUG_VARIABLE(bool, EnableFlushTaskSubmission, false, "true: driver uses csr flushTask for immediate submissions, false: driver uses legacy executeCommandList path") +DECLARE_DEBUG_VARIABLE(bool, DoNotFreeResources, false, "true: driver stops freeing resources") DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "DeviceId selected for testing") DECLARE_DEBUG_VARIABLE(std::string, LoadBinarySipFromFile, std::string("unk"), "Select binary file to load SIP kernel raw binary") DECLARE_DEBUG_VARIABLE(int64_t, OverrideMultiStoragePlacement, -1, "-1: disable, 0+: tile mask, each bit corresponds to tile") diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index e80d368f72..5296f6ea8b 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -728,6 +728,9 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf } void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) { + if (DebugManager.flags.DoNotFreeResources.get()) { + return; + } DrmAllocation *drmAlloc = static_cast(gfxAllocation); this->unregisterAllocation(gfxAllocation);