From 9fd80bdbac3235ee90326216b16c9848dda5ca2a Mon Sep 17 00:00:00 2001 From: echodo <2220386943@qq.com> Date: Fri, 27 Jun 2025 11:07:43 +0800 Subject: [PATCH] error work --- pmu/evt_list.cpp | 21 ++++++++++++++++----- pmu/evt_list.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pmu/evt_list.cpp b/pmu/evt_list.cpp index 29bcf1d..46ac3a6 100644 --- a/pmu/evt_list.cpp +++ b/pmu/evt_list.cpp @@ -100,6 +100,9 @@ int KUNPENG_PMU::EvtList::Init(const bool groupEnable, const std::shared_ptrIsMainPid()) { + if (err == LIBPERF_ERR_NO_PROC) { + noProcList.emplace(this->pidList[col]->tid); + } continue; } @@ -113,7 +116,7 @@ int KUNPENG_PMU::EvtList::Init(const bool groupEnable, const std::shared_ptr /proc/sys/kernel/perf_event_paranoid'"); + "Switch to the root user and run the 'echo -1 > /proc/sys/kernel/perf_event_paranoid'"); } if (err == UNKNOWN_ERROR) { @@ -323,19 +326,25 @@ void KUNPENG_PMU::EvtList::ClearExitFd() return; } - std::set exitPidVet; for (const auto& it: this->pidList) { + if (it->isMain) { + continue; + } std::string path = "/proc/" + std::to_string(it->tid); if (!ExistPath(path)) { - exitPidVet.insert(it->tid); + noProcList.insert(it->tid); } } + + if (noProcList.empty()) { + return; + } // erase the exit perfVet for (int row = 0; row < numCpu; row++) { auto& perfVet = xyCounterArray[row]; for (auto it = perfVet.begin(); it != perfVet.end();) { int pid = it->get()->GetPid(); - if (exitPidVet.find(pid) != exitPidVet.end()) { + if (noProcList.find(pid) != noProcList.end()) { int fd = it->get()->GetFd(); this->fdList.erase(this->fdList.find(fd)); close(fd); @@ -346,7 +355,7 @@ void KUNPENG_PMU::EvtList::ClearExitFd() } } - for (const auto& exitPid: exitPidVet) { + for (const auto& exitPid: noProcList) { for (auto it = this->pidList.begin(); it != this->pidList.end();) { if (it->get()->tid == exitPid) { this->unUsedPidList.push_back(it.operator*()); @@ -358,6 +367,8 @@ void KUNPENG_PMU::EvtList::ClearExitFd() procMap.erase(exitPid); numPid--; } + + noProcList.clear(); } void KUNPENG_PMU::EvtList::SetGroupInfo(const EventGroupInfo &grpInfo) diff --git a/pmu/evt_list.h b/pmu/evt_list.h index d064143..01f2291 100644 --- a/pmu/evt_list.h +++ b/pmu/evt_list.h @@ -123,6 +123,7 @@ private: std::vector cpuList; std::vector pidList; std::vector unUsedPidList; + std::set noProcList; std::shared_ptr pmuEvt; int groupId; // event group id std::vector>> xyCounterArray; -- Gitee