Skip to content

Commit 73b0df3

Browse files
Disable gem close worker in CSR constructor
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
1 parent 8156d5c commit 73b0df3

File tree

8 files changed

+33
-71
lines changed

8 files changed

+33
-71
lines changed

opencl/source/os_interface/linux/device_command_stream.inl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,9 @@ CommandStreamReceiver *createDrmCommandStreamReceiver(bool withAubDump,
2424
rootDeviceIndex,
2525
deviceBitfield);
2626
} else {
27-
auto gemMode = gemCloseWorkerMode::gemCloseWorkerActive;
28-
29-
if (DebugManager.flags.EnableDirectSubmission.get() == 1) {
30-
gemMode = gemCloseWorkerMode::gemCloseWorkerInactive;
31-
}
32-
33-
if (DebugManager.flags.EnableGemCloseWorker.get() != -1) {
34-
gemMode = DebugManager.flags.EnableGemCloseWorker.get() ? gemCloseWorkerMode::gemCloseWorkerActive : gemCloseWorkerMode::gemCloseWorkerInactive;
35-
}
36-
3727
return new DrmCommandStreamReceiver<GfxFamily>(executionEnvironment,
3828
rootDeviceIndex,
39-
deviceBitfield,
40-
gemMode);
29+
deviceBitfield);
4130
}
4231
}
4332
} // namespace NEO

opencl/source/os_interface/linux/drm_command_stream.inl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver(ExecutionEnvironme
4444
residency.reserve(512);
4545
execObjectsStorage.reserve(512);
4646

47+
if (this->drm->isVmBindAvailable()) {
48+
gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive;
49+
}
50+
51+
if (DebugManager.flags.EnableGemCloseWorker.get() != -1) {
52+
gemCloseWorkerOperationMode = DebugManager.flags.EnableGemCloseWorker.get() ? gemCloseWorkerMode::gemCloseWorkerActive : gemCloseWorkerMode::gemCloseWorkerInactive;
53+
}
54+
4755
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
4856
auto localMemoryEnabled = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
4957

opencl/test/unit_test/os_interface/linux/device_command_stream_tests.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,3 @@ HWTEST_F(DeviceCommandStreamSetInternalUsageTests, givenValidDrmCsrThenGemCloseW
103103
drmCsr->initializeDefaultsForInternalEngine();
104104
EXPECT_EQ(drmCsr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive);
105105
}
106-
107-
HWTEST_F(DeviceCommandStreamSetInternalUsageTests, givenEnableDirectSubmissionWhenCreateDrmCommandStreamReceiverThenGemCloseWorkerInactive) {
108-
DebugManagerStateRestore restorer;
109-
DebugManager.flags.EnableDirectSubmission.set(1);
110-
111-
std::unique_ptr<CommandStreamReceiver> ptr(DeviceCommandStreamReceiver<FamilyType>::create(false, *executionEnvironment, 0, 1));
112-
113-
auto drmCsr = (DrmCommandStreamReceiver<FamilyType> *)ptr.get();
114-
EXPECT_EQ(drmCsr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive);
115-
}

opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,6 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableWhenCreatingDrmMemoryManagerThenS
9090
}
9191
}
9292

93-
TEST_F(DrmMemoryManagerTest, whenNewResidencyModelAvailableThenGemCloseWorkerInactive) {
94-
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
95-
drm->bindAvailable = true;
96-
97-
memoryManager->disableGemCloseWorkerForNewResidencyModel();
98-
99-
for (const auto &engine : memoryManager->getRegisteredEngines()) {
100-
auto engineRootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex();
101-
auto rootDeviceDrm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[engineRootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
102-
103-
auto csr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(engine.commandStreamReceiver);
104-
EXPECT_TRUE(rootDeviceDrm->isVmBindAvailable());
105-
EXPECT_EQ(csr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive);
106-
}
107-
108-
this->dontTestIoctlInTearDown = true;
109-
}
110-
11193
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCheckForKmdMigrationThenCorrectValueIsReturned) {
11294
DebugManagerStateRestore restorer;
11395
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->getDriverModel()->as<Drm>());
@@ -775,14 +757,15 @@ TEST(DrmMemoryManagerTest2, givenDrmMemoryManagerWhengetSystemSharedMemoryIsCall
775757
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
776758
executionEnvironment->prepareRootDeviceEnvironments(4u);
777759
for (auto i = 0u; i < 4u; i++) {
760+
auto mock = new DrmMockCustom();
761+
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
762+
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
778763
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
779764
}
780765
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
781766

782767
for (auto i = 0u; i < 4u; i++) {
783-
auto mock = new DrmMockCustom();
784-
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
785-
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
768+
auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<DrmMockCustom>();
786769

787770
mock->getContextParamRetValue = 16 * MemoryConstants::gigaByte;
788771
uint64_t mem = memoryManager->getSystemSharedMemory(i);
@@ -808,20 +791,24 @@ TEST(DrmMemoryManagerTest2, WhenGetMinimumSystemSharedMemoryThenCorrectValueIsRe
808791
executionEnvironment->prepareRootDeviceEnvironments(4u);
809792
for (auto i = 0u; i < 4u; i++) {
810793
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
811-
}
812-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
813-
for (auto i = 0u; i < 4u; i++) {
814794
auto mock = new DrmMockCustom();
815795
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
816796
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
797+
}
798+
799+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
800+
801+
for (auto i = 0u; i < 4u; i++) {
802+
auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<DrmMockCustom>();
817803

818804
auto hostMemorySize = MemoryConstants::pageSize * (uint64_t)(sysconf(_SC_PHYS_PAGES));
819805
// gpuMemSize < hostMemSize
820806
auto gpuMemorySize = hostMemorySize - 1u;
807+
808+
mock->ioctl_expected.contextGetParam = 1;
821809
mock->getContextParamRetValue = gpuMemorySize;
822810

823811
uint64_t systemSharedMemorySize = memoryManager->getSystemSharedMemory(i);
824-
mock->ioctl_expected.contextGetParam = 1;
825812

826813
EXPECT_EQ(gpuMemorySize, systemSharedMemorySize);
827814
mock->ioctl_expected.contextDestroy = 0;
@@ -3852,12 +3839,13 @@ TEST(DrmMemoryManagerWithExplicitExpectationsTest2, whenObtainFdFromHandleIsCall
38523839
executionEnvironment->prepareRootDeviceEnvironments(4u);
38533840
for (auto i = 0u; i < 4u; i++) {
38543841
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
3855-
}
3856-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
3857-
for (auto i = 0u; i < 4u; i++) {
38583842
auto mock = new DrmMockCustom();
38593843
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
38603844
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
3845+
}
3846+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
3847+
for (auto i = 0u; i < 4u; i++) {
3848+
auto mock = executionEnvironment->rootDeviceEnvironments[i]->osInterface->getDriverModel()->as<DrmMockCustom>();
38613849

38623850
int boHandle = 3;
38633851
mock->outputFd = 1337;
@@ -4128,10 +4116,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhe
41284116
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
41294117
executionEnvironment->prepareRootDeviceEnvironments(1u);
41304118
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
4131-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41324119
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
41334120
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
41344121
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
4122+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41354123

41364124
EXPECT_FALSE(mockDrm->resourceRegistrationEnabled());
41374125

@@ -4149,10 +4137,10 @@ TEST(DrmMemoryManager, givenResourceRegistrationEnabledAndAllocTypeToCaptureWhen
41494137
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
41504138
executionEnvironment->prepareRootDeviceEnvironments(1u);
41514139
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
4152-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41534140
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
41544141
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
41554142
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
4143+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41564144

41574145
// mock resource registration enabling by storing class handles
41584146
mockDrm->classHandles.push_back(1);
@@ -4175,10 +4163,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenAllocatingThenAllocationIsR
41754163
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
41764164
executionEnvironment->prepareRootDeviceEnvironments(1u);
41774165
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
4178-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41794166
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
41804167
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
41814168
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
4169+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
41824170

41834171
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
41844172
mockDrm->classHandles.push_back(i);
@@ -4205,10 +4193,10 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeWhenFreeingThenRegisteredHandle
42054193
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
42064194
executionEnvironment->prepareRootDeviceEnvironments(1u);
42074195
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
4208-
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
42094196
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
42104197
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
42114198
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
4199+
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
42124200

42134201
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(Drm::ResourceClass::MaxSize); i++) {
42144202
mockDrm->classHandles.push_back(i);

shared/source/memory_manager/memory_manager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ class MemoryManager {
210210
virtual void registerSysMemAlloc(GraphicsAllocation *allocation){};
211211
virtual void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex){};
212212

213-
virtual void disableGemCloseWorkerForNewResidencyModel(){};
214213
bool isLocalMemoryUsedForIsa(uint32_t rootDeviceIndex);
215214

216215
protected:

shared/source/os_interface/device_factory.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ std::vector<std::unique_ptr<Device>> DeviceFactory::createDevices(ExecutionEnvir
155155
}
156156
}
157157

158-
executionEnvironment.memoryManager->disableGemCloseWorkerForNewResidencyModel();
159-
160158
return devices;
161159
}
162160

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode,
5353
}
5454

5555
void DrmMemoryManager::initialize(gemCloseWorkerMode mode) {
56+
bool disableGemCloseWorker = true;
57+
5658
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < gfxPartitions.size(); ++rootDeviceIndex) {
5759
auto gpuAddressSpace = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->capabilityTable.gpuAddressSpace;
5860
if (!getGfxPartition(rootDeviceIndex)->init(gpuAddressSpace, getSizeToReserve(), rootDeviceIndex, gfxPartitions.size(), heapAssigner.apiAllowExternalHeapForSshAndDsh)) {
5961
initialized = false;
6062
return;
6163
}
6264
localMemAllocs.emplace_back();
65+
disableGemCloseWorker &= getDrm(rootDeviceIndex).isVmBindAvailable();
6366
}
6467
MemoryManager::virtualPaddingAvailable = true;
6568

66-
if (DebugManager.flags.EnableDirectSubmission.get() == 1) {
69+
if (disableGemCloseWorker) {
6770
mode = gemCloseWorkerMode::gemCloseWorkerInactive;
6871
}
6972

@@ -1008,17 +1011,6 @@ void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) {
10081011
localMemAllocs[allocation->getRootDeviceIndex()].end());
10091012
}
10101013

1011-
void DrmMemoryManager::disableGemCloseWorkerForNewResidencyModel() {
1012-
for (auto &engine : this->registeredEngines) {
1013-
auto rootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex();
1014-
auto &drm = this->getDrm(rootDeviceIndex);
1015-
1016-
if (drm.isVmBindAvailable()) {
1017-
engine.commandStreamReceiver->initializeDefaultsForInternalEngine();
1018-
}
1019-
}
1020-
}
1021-
10221014
void DrmMemoryManager::registerAllocationInOs(GraphicsAllocation *allocation) {
10231015
if (allocation && getDrm(allocation->getRootDeviceIndex()).resourceRegistrationEnabled()) {
10241016
auto drmAllocation = static_cast<DrmAllocation *>(allocation);

shared/source/os_interface/linux/drm_memory_manager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class DrmMemoryManager : public MemoryManager {
7171
void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) override;
7272
void unregisterAllocation(GraphicsAllocation *allocation);
7373

74-
void disableGemCloseWorkerForNewResidencyModel() override;
75-
7674
static std::unique_ptr<MemoryManager> create(ExecutionEnvironment &executionEnvironment);
7775

7876
DrmAllocation *createUSMHostAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool hasMappedPtr);

0 commit comments

Comments
 (0)