From 78217af8bdb7f50e2f988d7b73d31af376872b23 Mon Sep 17 00:00:00 2001 From: wuying39 <921169248@qq.com> Date: Mon, 4 Aug 2025 16:03:00 +0800 Subject: [PATCH] revise path of PCIE bus to Bdf map --- pmu/pmu_metric.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pmu/pmu_metric.cpp b/pmu/pmu_metric.cpp index 2c694fe..7a99acd 100644 --- a/pmu/pmu_metric.cpp +++ b/pmu/pmu_metric.cpp @@ -45,6 +45,7 @@ static vector coreArray; static std::mutex pmuBdfListMtx; static std::mutex pmuDeviceDataMtx; +static const string SYS_DEVICES = "/sys/devices"; static const string SYS_BUS_PCI_DEVICES = "/sys/bus/pci/devices"; static const string SYS_IOMMU_DEVICES = "/sys/class/iommu"; static const string SYS_CPU_INFO_PATH = "/sys/devices/system/cpu/cpu"; @@ -506,15 +507,15 @@ namespace KUNPENG_PMU { // build map: EP bdf number -> bus static int GeneratePcieBusToBdfMap(unordered_map& pcieBdfToBus) { - if (!ExistPath(SYS_DEVICE_PATH) || !IsDirectory(SYS_DEVICE_PATH)) { + if (!ExistPath(SYS_DEVICES) || !IsDirectory(SYS_DEVICES)) { New(LIBPERF_ERR_QUERY_EVENT_LIST_FAILED, "Query uncore evtlist falied!"); return LIBPERF_ERR_QUERY_EVENT_LIST_FAILED; } - vector entries = ListDirectoryEntries(SYS_DEVICE_PATH); + vector entries = ListDirectoryEntries(SYS_DEVICES); for (const auto& entry : entries) { if (entry.find("pci0000:") == 0) { string bus = entry.substr(strlen("pci0000:")); - FindAllSubBdfDevice(SYS_DEVICE_PATH + "/" + entry, bus, pcieBdfToBus); + FindAllSubBdfDevice(SYS_DEVICES + "/" + entry, bus, pcieBdfToBus); } } return SUCCESS; -- Gitee