Fix for absence of busy node for clients

Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
Mayank Raghuwanshi 2021-03-21 23:25:46 +05:30 committed by Compute-Runtime-Automation
parent 0f6f92b704
commit a9ab9f0789
3 changed files with 36 additions and 18 deletions

View File

@ -302,7 +302,8 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
}
}
// Traverse the clients/<clientId>/busy directory to get accelerator engines used by process
std::vector<std::string> engineNums;
std::vector<std::string> engineNums = {};
int64_t engineType = 0;
std::string busyDirForEngines = clientsDir + "/" + clientId + "/" + "busy";
result = pSysfsAccess->scanDirEntries(busyDirForEngines, engineNums);
if (ZE_RESULT_SUCCESS != result) {
@ -311,13 +312,11 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
//this condition(when encountered) must not prevent the information accumulated for other clientIds
//this situation occurs when there is no call modifying result,
//Here its seen when the last element of clientIds returns ZE_RESULT_ERROR_NOT_AVAILABLE for some reason.
result = ZE_RESULT_SUCCESS;
continue;
engineType = ZES_ENGINE_TYPE_FLAG_OTHER; // When busy node is absent assign engine type with ZES_ENGINE_TYPE_FLAG_OTHER
} else {
return result;
}
}
int64_t engineType = 0;
// Scan all engine files present in /sys/class/drm/card0/clients/<ClientId>/busy and check
// whether that engine is used by process
for (const auto &engineNum : engineNums) {
@ -348,10 +347,7 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
std::string realClientTotalMemoryPath = clientsDir + "/" + clientId + "/" + "total_device_memory_buffer_objects" + "/" + "created_bytes";
result = pSysfsAccess->read(realClientTotalMemoryPath, memSize);
if (ZE_RESULT_SUCCESS != result) {
if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) {
result = ZE_RESULT_SUCCESS;
continue;
} else {
if (ZE_RESULT_ERROR_NOT_AVAILABLE != result) {
return result;
}
}
@ -360,10 +356,7 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
std::string realClientTotalSharedMemoryPath = clientsDir + "/" + clientId + "/" + "total_device_memory_buffer_objects" + "/" + "imported_bytes";
result = pSysfsAccess->read(realClientTotalSharedMemoryPath, sharedMemSize);
if (ZE_RESULT_SUCCESS != result) {
if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) {
result = ZE_RESULT_SUCCESS;
continue;
} else {
if (ZE_RESULT_ERROR_NOT_AVAILABLE != result) {
return result;
}
}
@ -383,6 +376,7 @@ ze_result_t LinuxGlobalOperationsImp::scanProcessesState(std::vector<zes_process
updateEngineMemoryPair.deviceMemStructField.deviceSharedMemorySize = existingdeviceSharedMemorySize + engineMemoryPair.deviceMemStructField.deviceSharedMemorySize;
pidClientMap[pid] = updateEngineMemoryPair;
}
result = ZE_RESULT_SUCCESS;
}
// iterate through all elements of pidClientMap

View File

@ -29,6 +29,8 @@ constexpr uint64_t pid1 = 1711u;
constexpr uint64_t pid2 = 1722u;
constexpr uint64_t pid3 = 1723u;
constexpr uint64_t pid4 = 1733u;
constexpr uint64_t pid6 = 1744u;
constexpr uint64_t pid7 = 1755u;
const std::string bPid4 = "<1733>";
constexpr uint64_t engineTimeSpent = 123456u;
const std::string clientId1("4");
@ -37,6 +39,7 @@ const std::string clientId3("6");
const std::string clientId4("7");
const std::string clientId5("8");
const std::string clientId6("10");
const std::string clientId7("11");
const std::string engine0("0");
const std::string engine1("1");
const std::string engine2("2");
@ -97,6 +100,10 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
val = pid2;
} else if (file.compare("clients/7/pid") == 0) {
val = pid3;
} else if (file.compare("clients/10/pid") == 0) {
val = pid6;
} else if (file.compare("clients/11/pid") == 0) {
val = pid7;
} else if ((file.compare("clients/4/busy/0") == 0) || (file.compare("clients/4/busy/3") == 0) ||
(file.compare("clients/5/busy/1") == 0) || (file.compare("clients/6/busy/0") == 0) ||
(file.compare("clients/8/busy/1") == 0) || (file.compare("clients/8/busy/0") == 0)) {
@ -111,12 +118,14 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
} else if ((file.compare("clients/4/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/5/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/6/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/8/total_device_memory_buffer_objects/created_bytes") == 0)) {
(file.compare("clients/8/total_device_memory_buffer_objects/created_bytes") == 0) ||
(file.compare("clients/10/total_device_memory_buffer_objects/created_bytes") == 0)) {
val = 1024;
} else if ((file.compare("clients/4/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/5/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/6/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/8/total_device_memory_buffer_objects/imported_bytes") == 0)) {
(file.compare("clients/8/total_device_memory_buffer_objects/imported_bytes") == 0) ||
(file.compare("clients/10/total_device_memory_buffer_objects/imported_bytes") == 0)) {
val = 512;
} else if (file.compare("clients/7/total_device_memory_buffer_objects/created_bytes") == 0) {
return ZE_RESULT_ERROR_UNKNOWN;
@ -133,8 +142,6 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
val = pid1;
} else if (file.compare("clients/6/pid") == 0) {
val = pid2;
} else if (file.compare("clients/7/pid") == 0) {
val = pid3;
} else if ((file.compare("clients/4/busy/0") == 0) || (file.compare("clients/4/busy/3") == 0) ||
(file.compare("clients/5/busy/1") == 0) || (file.compare("clients/6/busy/0") == 0) ||
(file.compare("clients/8/busy/1") == 0) || (file.compare("clients/8/busy/0") == 0)) {
@ -192,6 +199,8 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
list.push_back(clientId2);
list.push_back(clientId3);
list.push_back(clientId5);
list.push_back(clientId6);
list.push_back(clientId7);
} else if ((path.compare("clients/4/busy") == 0) || (path.compare("clients/5/busy") == 0) ||
(path.compare("clients/6/busy") == 0) || (path.compare("clients/8/busy") == 0)) {
list.push_back(engine0);

View File

@ -17,9 +17,13 @@ namespace ult {
constexpr uint64_t memSize1 = 2048;
constexpr uint64_t memSize2 = 1024;
constexpr uint64_t memSize4 = 1024;
constexpr uint64_t memSize6 = 1024;
constexpr uint64_t memSize7 = 0;
constexpr uint64_t sharedMemSize1 = 1024;
constexpr uint64_t sharedMemSize2 = 512;
constexpr uint64_t sharedMemSize4 = 512;
constexpr uint64_t sharedMemSize6 = 512;
constexpr uint64_t sharedMemSize7 = 0;
// In mock function getValUnsignedLong, we have set the engines used as 0, 3 and 1.
// Hence, expecting 28 as engine field because 28 in binary would be 00011100
// This indicates bit number 2, 3 and 4 are set, thus this indicates, this process
@ -30,7 +34,10 @@ constexpr int64_t engines1 = 28u;
// Corresponding i915 mapped value in mocked getValUnsignedLong() is 0.
constexpr int64_t engines2 = 4u;
constexpr int64_t engines4 = 20u;
constexpr uint32_t totalProcessStates = 3u; // Three process States for three pids
constexpr int64_t engines6 = 1u;
constexpr int64_t engines7 = 1u;
constexpr uint32_t totalProcessStates = 5u; // Three process States for three pids
constexpr uint32_t totalProcessStatesForFaultyClients = 3u;
const std::string expectedModelName("0x3ea5");
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
protected:
@ -185,6 +192,14 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInfor
EXPECT_EQ(processes[2].engines, engines4);
EXPECT_EQ(processes[2].memSize, memSize4);
EXPECT_EQ(processes[2].sharedSize, sharedMemSize4);
EXPECT_EQ(processes[3].processId, pid6);
EXPECT_EQ(processes[3].engines, engines6);
EXPECT_EQ(processes[3].memSize, memSize6);
EXPECT_EQ(processes[3].sharedSize, sharedMemSize6);
EXPECT_EQ(processes[4].processId, pid7);
EXPECT_EQ(processes[4].engines, engines7);
EXPECT_EQ(processes[4].memSize, memSize7);
EXPECT_EQ(processes[4].sharedSize, sharedMemSize7);
}
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturnedEvenwithFaultyClient) {
@ -195,7 +210,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInfor
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValUnsignedLongCreatedBytesSuccess));
ASSERT_EQ(ZE_RESULT_SUCCESS, zesDeviceProcessesGetState(device, &count, nullptr));
EXPECT_EQ(count, totalProcessStates);
EXPECT_EQ(count, totalProcessStatesForFaultyClients);
std::vector<zes_process_state_t> processes(count);
ASSERT_EQ(ZE_RESULT_SUCCESS, zesDeviceProcessesGetState(device, &count, processes.data()));
EXPECT_EQ(processes[0].processId, pid1);