From 2b1cc98693900550d315e3ea340a3dfc6f9b211e Mon Sep 17 00:00:00 2001 From: Sarbojit Sarkar Date: Tue, 19 Aug 2025 09:15:28 +0000 Subject: [PATCH] fix: Add move instead of copy in sysman module Related-To: NEO-15795 Signed-off-by: Sarbojit Sarkar --- .../firmware/linux/sysman_os_firmware_imp_helper.cpp | 4 ++-- .../api/frequency/linux/sysman_os_frequency_imp.cpp | 2 +- .../linux/sysman_os_global_operations_imp.cpp | 10 +++++----- .../sysman/source/api/pci/linux/sysman_os_pci_imp.cpp | 6 +++--- .../linux/kmd_interface/sysman_kmd_interface.cpp | 4 ++-- .../linux/product_helper/sysman_product_helper_hw.inl | 10 +++++----- .../xe_hpc_core/pvc/sysman_product_helper_pvc.cpp | 4 ++-- .../xe_hpg_core/dg2/sysman_product_helper_dg2.cpp | 6 +++--- .../source/shared/linux/sysman_fs_access_interface.cpp | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp_helper.cpp b/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp_helper.cpp index 71d90815ab..805e501bec 100644 --- a/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp_helper.cpp +++ b/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp_helper.cpp @@ -54,13 +54,13 @@ ze_result_t LinuxFirmwareImp::getFirmwareVersion(std::string fwType, zes_firmwar return result; } if (std::find(lateBindingFirmwareTypes.begin(), lateBindingFirmwareTypes.end(), fwType) != lateBindingFirmwareTypes.end()) { - if (pLinuxSysmanImp->getSysmanKmdInterface()->isLateBindingVersionAvailable(fwType, fwVersion)) { + if (pLinuxSysmanImp->getSysmanKmdInterface()->isLateBindingVersionAvailable(std::move(fwType), fwVersion)) { strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE - 1); return ZE_RESULT_SUCCESS; } return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ze_result_t result = pFwInterface->getFwVersion(fwType, fwVersion); + ze_result_t result = pFwInterface->getFwVersion(std::move(fwType), fwVersion); if (result == ZE_RESULT_SUCCESS) { strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, fwVersion.c_str(), ZES_STRING_PROPERTY_SIZE - 1); } diff --git a/level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.cpp b/level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.cpp index d2be7d5fc6..cd9b651855 100644 --- a/level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.cpp +++ b/level_zero/sysman/source/api/frequency/linux/sysman_os_frequency_imp.cpp @@ -426,7 +426,7 @@ std::vector OsFrequency::getNumberOfFreqDomainsSupported(OsSy auto pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess(); auto pSysmanKmdInterface = pLinuxSysmanImp->getSysmanKmdInterface(); auto baseDir = pSysmanKmdInterface->getFreqMediaDomainBasePath(); - if (pSysfsAccess->directoryExists(baseDir)) { + if (pSysfsAccess->directoryExists(std::move(baseDir))) { freqDomains.push_back(ZES_FREQ_DOMAIN_MEDIA); } } diff --git a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp index 40e34055c8..945d03038e 100644 --- a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp +++ b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp @@ -439,11 +439,11 @@ ze_result_t LinuxGlobalOperationsImp::getMemoryStatsUsedByProcess(std::vector(pid)) + "/fdinfo/" + std::to_string(fd); std::vector fdFileContents; - result = pFsAccess->read(fdInfoPath, fdFileContents); + result = pFsAccess->read(std::move(fdInfoPath), fdFileContents); if (ZE_RESULT_SUCCESS != result) { if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) { // update the result as Success as ZE_RESULT_ERROR_NOT_AVAILABLE is expected if process exited by the time we are readig it. @@ -613,7 +613,7 @@ ze_result_t LinuxGlobalOperationsImp::readClientInfoFromSysfs(std::mapread(realClientPidPath, bPidString); + result = pSysfsAccess->read(std::move(realClientPidPath), bPidString); if (result == ZE_RESULT_SUCCESS) { size_t start = bPidString.find("<"); size_t end = bPidString.find(">"); @@ -654,7 +654,7 @@ ze_result_t LinuxGlobalOperationsImp::readClientInfoFromSysfs(std::mapread(engine, timeSpent); + result = pSysfsAccess->read(std::move(engine), timeSpent); if (ZE_RESULT_SUCCESS != result) { if (ZE_RESULT_ERROR_NOT_AVAILABLE == result) { continue; diff --git a/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp b/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp index 6c8f249015..a5c6f8f89f 100644 --- a/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp +++ b/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp @@ -89,7 +89,7 @@ void LinuxPciImp::getMaxLinkCaps(double &maxLinkSpeed, int32_t &maxLinkWidth) { } std::vector configMemory(PCI_CFG_SPACE_SIZE); - if (!getPciConfigMemory(pciConfigNode, configMemory)) { + if (!getPciConfigMemory(std::move(pciConfigNode), configMemory)) { return; } @@ -230,7 +230,7 @@ bool LinuxPciImp::resizableBarSupported() { std::string pciConfigNode = {}; pSysfsAccess->getRealPath("device/config", pciConfigNode); std::vector configMemory(PCI_CFG_SPACE_EXP_SIZE); - if (!getPciConfigMemory(pciConfigNode, configMemory)) { + if (!getPciConfigMemory(std::move(pciConfigNode), configMemory)) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Unable to get pci config space \n", __FUNCTION__); return false; } @@ -245,7 +245,7 @@ bool LinuxPciImp::resizableBarEnabled(uint32_t barIndex) { std::string pciConfigNode = {}; pSysfsAccess->getRealPath("device/config", pciConfigNode); std::vector configMemory(PCI_CFG_SPACE_EXP_SIZE); - if (!getPciConfigMemory(pciConfigNode, configMemory)) { + if (!getPciConfigMemory(std::move(pciConfigNode), configMemory)) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Unable to get pci config space \n", __FUNCTION__); return false; } diff --git a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp index 669485c6f5..7b5e586fcb 100644 --- a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp +++ b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.cpp @@ -65,7 +65,7 @@ ze_result_t SysmanKmdInterface::initFsAccessInterface(const NEO::Drm &drm) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to device name and returning error:0x%x \n", __FUNCTION__, result); return result; } - pSysfsAccess = SysFsAccessInterface::create(deviceName); + pSysfsAccess = SysFsAccessInterface::create(std::move(deviceName)); return result; } @@ -120,7 +120,7 @@ ze_result_t SysmanKmdInterface::getNumEngineTypeAndInstancesForSubDevices(std::m ze_result_t SysmanKmdInterface::getNumEngineTypeAndInstancesForDevice(std::string engineDir, std::map> &mapOfEngines, SysFsAccessInterface *pSysfsAccess) { std::vector localListOfAllEngines = {}; - auto result = pSysfsAccess->scanDirEntries(engineDir, localListOfAllEngines); + auto result = pSysfsAccess->scanDirEntries(std::move(engineDir), localListOfAllEngines); if (ZE_RESULT_SUCCESS != result) { if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) { result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; diff --git a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl index 02df0b81c1..8159cd9fd3 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl +++ b/level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl @@ -104,7 +104,7 @@ ze_result_t SysmanProductHelperHw::getMemoryProperties(zes_mem_prope if (isSubdevice) { std::string memval; std::string physicalSizeFile = pSysmanKmdInterface->getSysfsFilePathForPhysicalMemorySize(subDeviceId); - ze_result_t result = pSysFsAccess->read(physicalSizeFile, memval); + ze_result_t result = pSysFsAccess->read(std::move(physicalSizeFile), memval); uint64_t intval = strtoull(memval.c_str(), nullptr, 16); if (ZE_RESULT_SUCCESS != result) { pProperties->physicalSize = 0u; @@ -176,16 +176,16 @@ zes_freq_throttle_reason_flags_t SysmanProductHelperHw::getThrottleR std::string throttleReasonPL4File = pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameThrottleReasonPL4, subdeviceId, baseDirectoryExists); std::string throttleReasonThermalFile = pSysmanKmdInterface->getSysfsFilePath(SysfsName::sysfsNameThrottleReasonThermal, subdeviceId, baseDirectoryExists); - if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(throttleReasonPL1File, val)) && val) { + if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(std::move(throttleReasonPL1File), val)) && val) { throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_AVE_PWR_CAP; } - if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(throttleReasonPL2File, val)) && val) { + if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(std::move(throttleReasonPL2File), val)) && val) { throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_BURST_PWR_CAP; } - if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(throttleReasonPL4File, val)) && val) { + if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(std::move(throttleReasonPL4File), val)) && val) { throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_CURRENT_LIMIT; } - if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(throttleReasonThermalFile, val)) && val) { + if ((ZE_RESULT_SUCCESS == pSysfsAccess->read(std::move(throttleReasonThermalFile), val)) && val) { throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_THERMAL_LIMIT; } } else { diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp index 27e735e694..6c5ade2587 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe_hpc_core/pvc/sysman_product_helper_pvc.cpp @@ -157,7 +157,7 @@ ze_result_t getVFIDString(std::map keyOffsetMap, std::str uint32_t vf1VfIdVal = 0; key = "VF1_VFID"; - if (!PlatformMonitoringTech::readValue(keyOffsetMap, telemDir, key, telemOffset, vf1VfIdVal)) { + if (!PlatformMonitoringTech::readValue(std::move(keyOffsetMap), telemDir, key, telemOffset, vf1VfIdVal)) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for VF1_VFID is returning error:0x%x \n", __FUNCTION__, ZE_RESULT_ERROR_NOT_AVAILABLE); return ZE_RESULT_ERROR_NOT_AVAILABLE; } @@ -244,7 +244,7 @@ ze_result_t getHBMBandwidth(zes_mem_bandwidth_t *pBandwidth, LinuxSysmanImp *pLi keyOffsetMap = keyOffsetMapEntry->second; if (guid != guid64BitMemoryCounters) { - return getHBMBandwidth(keyOffsetMap, pBandwidth, pLinuxSysmanImp, telemDir, telemOffset, subdeviceId, stepping); + return getHBMBandwidth(std::move(keyOffsetMap), pBandwidth, pLinuxSysmanImp, telemDir, telemOffset, subdeviceId, stepping); } pBandwidth->readCounter = 0; diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp index 3beb99686c..4c88c6075c 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe_hpg_core/dg2/sysman_product_helper_dg2.cpp @@ -184,7 +184,7 @@ ze_result_t SysmanProductHelperHw::getMemoryBandwidth(zes_mem_bandwi } keyOffsetMap = keyOffsetMapEntry->second; - result = readMcChannelCounters(keyOffsetMap, pBandwidth->readCounter, pBandwidth->writeCounter, telemDir, telemOffset); + result = readMcChannelCounters(std::move(keyOffsetMap), pBandwidth->readCounter, pBandwidth->writeCounter, std::move(telemDir), telemOffset); if (result != ZE_RESULT_SUCCESS) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readMcChannelCounters returning error:0x%x \n", __FUNCTION__, result); return result; @@ -214,7 +214,7 @@ ze_result_t SysmanProductHelperHw::getPowerEnergyCounter(zes_power_e } std::map keyOffsetMap; - if (!PlatformMonitoringTech::getKeyOffsetMap(this, guid, keyOffsetMap)) { + if (!PlatformMonitoringTech::getKeyOffsetMap(this, std::move(guid), keyOffsetMap)) { return ZE_RESULT_ERROR_UNKNOWN; } @@ -254,7 +254,7 @@ ze_result_t SysmanProductHelperHw::getVfLocalMemoryQuota(SysFsAccess const std::string pathForLmemQuota = "/gt/lmem_quota"; std::string pathForDeviceMemQuota = "iov/vf" + std::to_string(vfId) + pathForLmemQuota; - auto result = pSysfsAccess->read(pathForDeviceMemQuota, lMemQuota); + auto result = pSysfsAccess->read(std::move(pathForDeviceMemQuota), lMemQuota); if (result != ZE_RESULT_SUCCESS) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read Local Memory Quota with error 0x%x \n", __FUNCTION__, result); return result; diff --git a/level_zero/sysman/source/shared/linux/sysman_fs_access_interface.cpp b/level_zero/sysman/source/shared/linux/sysman_fs_access_interface.cpp index b414404374..cd7b2cd2d1 100644 --- a/level_zero/sysman/source/shared/linux/sysman_fs_access_interface.cpp +++ b/level_zero/sysman/source/shared/linux/sysman_fs_access_interface.cpp @@ -416,7 +416,7 @@ SysFsAccessInterface::SysFsAccessInterface(const std::string dev) { std::string fileName = FsAccessInterface::getBaseName(dev); std::string devicesDir = drmPath + fileName + std::string("/") + devicesPath; - FsAccessInterface::listDirectory(devicesDir, deviceNames); + FsAccessInterface::listDirectory(std::move(devicesDir), deviceNames); for (auto &&next : deviceNames) { if (!next.compare(0, primaryDevName.length(), primaryDevName)) { dirname = drmPath + next + std::string("/");