refactor: use NEO::SysCalls::close wrapper for close function call

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-07-04 12:25:01 +02:00
committed by Compute-Runtime-Automation
parent d261d49b0e
commit 09e6b3fe75
5 changed files with 16 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,6 +10,7 @@
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/os_interface/linux/engine_info.h"
#include "shared/source/os_interface/linux/i915.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
@@ -82,7 +83,7 @@ ze_result_t LinuxEngineImp::getActivityExt(uint32_t *pCount, zes_engine_stats_t
void LinuxEngineImp::cleanup() {
for (auto &fdPair : fdList) {
DEBUG_BREAK_IF(fdPair.first < 0);
close(static_cast<int>(fdPair.first));
NEO::SysCalls::close(static_cast<int>(fdPair.first));
}
fdList.clear();
}

View File

@@ -79,7 +79,7 @@ static ze_result_t openPmuHandlesForVfs(uint32_t numberOfVfs,
PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (fd[1] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Total Active Ticks PMU Handle \n", __FUNCTION__);
close(static_cast<int>(fd[0]));
NEO::SysCalls::close(static_cast<int>(fd[0]));
fd[0] = -1;
}
}
@@ -111,10 +111,10 @@ ze_result_t LinuxEngineImpPrelim::getActivity(zes_engine_stats_t *pStats) {
void LinuxEngineImpPrelim::cleanup() {
for (auto &fdPair : fdList) {
if (fdPair.first >= 0) {
close(static_cast<int>(fdPair.first));
NEO::SysCalls::close(static_cast<int>(fdPair.first));
}
if (fdPair.second >= 0) {
close(static_cast<int>(fdPair.second));
NEO::SysCalls::close(static_cast<int>(fdPair.second));
}
}
fdList.clear();
@@ -154,8 +154,8 @@ ze_result_t LinuxEngineImpPrelim::getActivityExt(uint32_t *pCount, zes_engine_st
for (size_t i = 1; i < fdList.size(); i++) {
auto &fdPair = fdList[i];
if (fdPair.first >= 0) {
close(static_cast<int32_t>(fdPair.first));
close(static_cast<int32_t>(fdPair.second));
NEO::SysCalls::close(static_cast<int32_t>(fdPair.first));
NEO::SysCalls::close(static_cast<int32_t>(fdPair.second));
}
fdList.resize(1);
}
@@ -242,7 +242,7 @@ void LinuxEngineImpPrelim::init() {
if (fd[1] < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Total Active Ticks Handle \n", __FUNCTION__);
checkErrorNumberAndUpdateStatus();
close(static_cast<int>(fd[0]));
NEO::SysCalls::close(static_cast<int>(fd[0]));
return;
}

View File

@@ -53,7 +53,7 @@ static const std::map<zes_ras_error_category_exp_t, std::vector<std::string>> ca
static void closeFd(int64_t &fd) {
if (fd != -1) {
close(static_cast<int>(fd));
NEO::SysCalls::close(static_cast<int>(fd));
fd = -1;
}
}
@@ -350,4 +350,4 @@ LinuxRasSourceGt::LinuxRasSourceGt(LinuxSysmanImp *pLinuxSysmanImp, zes_ras_erro
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
}
} // namespace L0
} // namespace L0

View File

@@ -132,9 +132,9 @@ LinuxVfImp::LinuxVfImp(
void LinuxVfImp::cleanup() {
for (auto pEngineUtilsData : pEngineUtils) {
DEBUG_BREAK_IF(pEngineUtilsData.busyTicksFd < 0);
close(static_cast<int>(pEngineUtilsData.busyTicksFd));
NEO::SysCalls::close(static_cast<int>(pEngineUtilsData.busyTicksFd));
DEBUG_BREAK_IF(pEngineUtilsData.totalTicksFd < 0);
close(static_cast<int>(pEngineUtilsData.totalTicksFd));
NEO::SysCalls::close(static_cast<int>(pEngineUtilsData.totalTicksFd));
}
pEngineUtils.clear();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -68,7 +68,7 @@ ze_result_t LinuxVfImp::vfEngineDataInit() {
int64_t totalTicksFd = pPmuInterface->pmuInterfaceOpen(totalTicksConfig, static_cast<int32_t>(busyTicksFd), PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
if (totalTicksFd < 0) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Could not open Total Ticks Handle and returning error:0x%x \n", __FUNCTION__, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
close(static_cast<int>(busyTicksFd));
NEO::SysCalls::close(static_cast<int>(busyTicksFd));
cleanup();
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
@@ -127,4 +127,4 @@ ze_result_t LinuxVfImp::getEngineUtilization(uint32_t *pCount, zes_vf_util_engin
return ZE_RESULT_SUCCESS;
}
} // namespace L0
} // namespace L0