From 5b7bf97aa00a5923d66b0de9beded92f5504a752 Mon Sep 17 00:00:00 2001 From: fly_1997 Date: Tue, 17 Dec 2024 02:19:07 +0800 Subject: [PATCH] fix smc type error, fix cpu burst unsubscribe problem, add pmu check (cherry picked from commit 6e38cf4e4de2f304cab2bec313566485877ebb87) --- ...urst-instance-add-unsubscribe-topics.patch | 66 ++++++ 0003-add-pmu-check.patch | 192 ++++++++++++++++++ 0004-fix-smc_tune-type.patch | 32 +++ oeAware-manager.spec | 10 +- 4 files changed, 299 insertions(+), 1 deletion(-) create mode 100644 0002-docker_cpu_burst-instance-add-unsubscribe-topics.patch create mode 100644 0003-add-pmu-check.patch create mode 100644 0004-fix-smc_tune-type.patch diff --git a/0002-docker_cpu_burst-instance-add-unsubscribe-topics.patch b/0002-docker_cpu_burst-instance-add-unsubscribe-topics.patch new file mode 100644 index 0000000..832451b --- /dev/null +++ b/0002-docker_cpu_burst-instance-add-unsubscribe-topics.patch @@ -0,0 +1,66 @@ +From 2f4ac51bd93299e7dd63f2578ac21c87872680c8 Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Mon, 16 Dec 2024 09:53:04 +0800 +Subject: [PATCH 1/3] docker_cpu_burst instance add unsubscribe topics + +--- + src/plugin/tune/docker/cpu_burst_adapt.cpp | 17 ++++++++--------- + src/plugin/tune/docker/cpu_burst_adapt.h | 2 ++ + 2 files changed, 10 insertions(+), 9 deletions(-) + +diff --git a/src/plugin/tune/docker/cpu_burst_adapt.cpp b/src/plugin/tune/docker/cpu_burst_adapt.cpp +index 3fa6254..822e0c5 100644 +--- a/src/plugin/tune/docker/cpu_burst_adapt.cpp ++++ b/src/plugin/tune/docker/cpu_burst_adapt.cpp +@@ -32,6 +32,8 @@ CpuBurstAdapt::CpuBurstAdapt() + topic.instanceName = this->name; + topic.topicName = this->name; + supportTopics.push_back(topic); ++ subscribeTopics.emplace_back(oeaware::Topic{OE_PMU_COUNTING_COLLECTOR, "cycles", ""}); ++ subscribeTopics.emplace_back(oeaware::Topic{OE_DOCKER_COLLECTOR, OE_DOCKER_COLLECTOR, ""}); + } + + oeaware::Result CpuBurstAdapt::OpenTopic(const oeaware::Topic &topic) +@@ -55,20 +57,17 @@ oeaware::Result CpuBurstAdapt::Enable(const std::string ¶m) + (void)param; + if (!CpuBurst::GetInstance().Init()) + return oeaware::Result(FAILED, "CpuBurst init failed!"); +- oeaware::Topic topic; +- topic.instanceName = "pmu_counting_collector"; +- topic.topicName = "cycles"; +- oeaware::Result ret_pmu = Subscribe(topic); +- topic.instanceName = OE_DOCKER_COLLECTOR; +- topic.topicName = OE_DOCKER_COLLECTOR; +- oeaware::Result ret_docker = Subscribe(topic); +- if (ret_pmu.code != OK || ret_docker.code != OK) +- return oeaware::Result(FAILED, "Subscribe failed!"); ++ for (auto &topic : subscribeTopics) { ++ Subscribe(topic); ++ } + return oeaware::Result(OK); + } + + void CpuBurstAdapt::Disable() + { ++ for (auto &topic : subscribeTopics) { ++ Unsubscribe(topic); ++ } + CpuBurst::GetInstance().Exit(); + } + +diff --git a/src/plugin/tune/docker/cpu_burst_adapt.h b/src/plugin/tune/docker/cpu_burst_adapt.h +index 4c583b0..17be704 100644 +--- a/src/plugin/tune/docker/cpu_burst_adapt.h ++++ b/src/plugin/tune/docker/cpu_burst_adapt.h +@@ -24,5 +24,7 @@ public: + oeaware::Result Enable(const std::string ¶m) override; + void Disable() override; + void Run() override; ++private: ++ std::vector subscribeTopics; + }; + #endif // CPU_BURST_ADAPT_H +\ No newline at end of file +-- +2.33.0 + diff --git a/0003-add-pmu-check.patch b/0003-add-pmu-check.patch new file mode 100644 index 0000000..e1c98ae --- /dev/null +++ b/0003-add-pmu-check.patch @@ -0,0 +1,192 @@ +From 8fcb0cd364de2d4957e36d4206058bff7d723f1b Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Mon, 16 Dec 2024 23:34:32 +0800 +Subject: [PATCH 3/3] add pmu check + +--- + src/plugin/collect/pmu/CMakeLists.txt | 1 + + src/plugin/collect/pmu/pmu_common.cpp | 33 +++++++++++++++++++ + src/plugin/collect/pmu/pmu_common.h | 17 ++++++++++ + .../collect/pmu/pmu_counting_collector.cpp | 4 +++ + .../collect/pmu/pmu_sampling_collector.cpp | 4 +++ + src/plugin/collect/pmu/pmu_spe_collector.cpp | 3 ++ + src/plugin/collect/pmu/pmu_spe_collector.h | 1 + + .../collect/pmu/pmu_uncore_collector.cpp | 3 ++ + src/plugin/collect/pmu/pmu_uncore_collector.h | 1 + + 9 files changed, 67 insertions(+) + create mode 100644 src/plugin/collect/pmu/pmu_common.cpp + create mode 100644 src/plugin/collect/pmu/pmu_common.h + +diff --git a/src/plugin/collect/pmu/CMakeLists.txt b/src/plugin/collect/pmu/CMakeLists.txt +index ba3cb6a..000e26e 100644 +--- a/src/plugin/collect/pmu/CMakeLists.txt ++++ b/src/plugin/collect/pmu/CMakeLists.txt +@@ -22,6 +22,7 @@ set(pmu_src + pmu_uncore_collector.cpp + pmu_uncore.cpp + pmu_collector.cpp ++ pmu_common.cpp + ) + + add_library(pmu SHARED ${pmu_src}) +diff --git a/src/plugin/collect/pmu/pmu_common.cpp b/src/plugin/collect/pmu/pmu_common.cpp +new file mode 100644 +index 0000000..caf453a +--- /dev/null ++++ b/src/plugin/collect/pmu/pmu_common.cpp +@@ -0,0 +1,33 @@ ++/****************************************************************************** ++ * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved. ++ * oeAware is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ ******************************************************************************/ ++#include "pmu_common.h" ++#include ++#include ++#include "oeaware/utils.h" ++ ++static const std::string DEVICES_PATH = "/sys/bus/event_source/devices/"; ++ ++bool IsSupportPmu() ++{ ++ DIR *dir = opendir(DEVICES_PATH.data()); ++ if (dir == nullptr) { ++ return false; ++ } ++ struct dirent *dent = nullptr; ++ while (dent = readdir(dir)) { ++ std::string armPmuPath = DEVICES_PATH + dent->d_name + "/cpus"; ++ if (oeaware::FileExist(armPmuPath)) { ++ return true; ++ } ++ } ++ return false; ++} +diff --git a/src/plugin/collect/pmu/pmu_common.h b/src/plugin/collect/pmu/pmu_common.h +new file mode 100644 +index 0000000..3ba5a2d +--- /dev/null ++++ b/src/plugin/collect/pmu/pmu_common.h +@@ -0,0 +1,17 @@ ++/****************************************************************************** ++ * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved. ++ * oeAware is licensed under Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, ++ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, ++ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ ******************************************************************************/ ++#ifndef PMU_COMMON_H ++#define PMU_COMMON_H ++ ++bool IsSupportPmu(); ++ ++#endif +diff --git a/src/plugin/collect/pmu/pmu_counting_collector.cpp b/src/plugin/collect/pmu/pmu_counting_collector.cpp +index 9227d67..281c61d 100644 +--- a/src/plugin/collect/pmu/pmu_counting_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_counting_collector.cpp +@@ -14,6 +14,7 @@ + #include + #include + #include "oeaware/data/pmu_counting_data.h" ++#include "pmu_common.h" + + PmuCountingCollector::PmuCountingCollector(): oeaware::Interface() + { +@@ -119,6 +120,9 @@ void PmuCountingCollector::CloseTopic(const oeaware::Topic &topic) + oeaware::Result PmuCountingCollector::Enable(const std::string ¶m) + { + (void)param; ++ if (!IsSupportPmu()) { ++ return oeaware::Result(FAILED, "the system does not support PMU."); ++ } + return oeaware::Result(OK); + } + +diff --git a/src/plugin/collect/pmu/pmu_sampling_collector.cpp b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +index f1f99eb..b4cf037 100644 +--- a/src/plugin/collect/pmu/pmu_sampling_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +@@ -14,6 +14,7 @@ + #include + #include + #include "oeaware/data/pmu_sampling_data.h" ++#include "pmu_common.h" + + PmuSamplingCollector::PmuSamplingCollector(): oeaware::Interface() + { +@@ -123,6 +124,9 @@ void PmuSamplingCollector::CloseTopic(const oeaware::Topic &topic) + oeaware::Result PmuSamplingCollector::Enable(const std::string ¶m) + { + (void)param; ++ if (!IsSupportPmu()) { ++ return oeaware::Result(FAILED, "the system does not support PMU."); ++ } + return oeaware::Result(OK); + } + +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.cpp b/src/plugin/collect/pmu/pmu_spe_collector.cpp +index 19ad8de..dc7e0fb 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_spe_collector.cpp +@@ -133,6 +133,9 @@ void PmuSpeCollector::CloseTopic(const oeaware::Topic &topic) + oeaware::Result PmuSpeCollector::Enable(const std::string ¶m) + { + (void)param; ++ if (!oeaware::FileExist(spePath)) { ++ return oeaware::Result(FAILED, "the system does not support SPE."); ++ } + return oeaware::Result(OK); + } + +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.h b/src/plugin/collect/pmu/pmu_spe_collector.h +index c913e43..d54a204 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.h ++++ b/src/plugin/collect/pmu/pmu_spe_collector.h +@@ -35,6 +35,7 @@ private: + int attrPeriod = 2048; + std::string topicStr = "spe"; + std::chrono::time_point timestamp; ++ const std::string spePath = "/sys/bus/event_source/devices/arm_spe_0"; + const int timeoutMs = 50; + const int notTimeoutMs = 10; + const int periodThreshold = 2; +diff --git a/src/plugin/collect/pmu/pmu_uncore_collector.cpp b/src/plugin/collect/pmu/pmu_uncore_collector.cpp +index ba00ebc..74c2901 100644 +--- a/src/plugin/collect/pmu/pmu_uncore_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_uncore_collector.cpp +@@ -151,6 +151,9 @@ void PmuUncoreCollector::CloseTopic(const oeaware::Topic &topic) + oeaware::Result PmuUncoreCollector::Enable(const std::string ¶m) + { + (void)param; ++ if (!oeaware::FileExist(uncorePath)) { ++ return oeaware::Result(FAILED, "the system does not support uncore events."); ++ } + return oeaware::Result(OK); + } + +diff --git a/src/plugin/collect/pmu/pmu_uncore_collector.h b/src/plugin/collect/pmu/pmu_uncore_collector.h +index 175026f..a01d138 100644 +--- a/src/plugin/collect/pmu/pmu_uncore_collector.h ++++ b/src/plugin/collect/pmu/pmu_uncore_collector.h +@@ -32,6 +32,7 @@ private: + std::vector eventStr; + std::vector hhaDir; + std::chrono::time_point timestamp; ++ const std::string uncorePath = "/sys/bus/event_source/devices/hisi_sccl1_hha2"; + void InitUncoreAttr(struct PmuAttr &attr); + int OpenUncore(); + }; +-- +2.33.0 + diff --git a/0004-fix-smc_tune-type.patch b/0004-fix-smc_tune-type.patch new file mode 100644 index 0000000..d34fc9d --- /dev/null +++ b/0004-fix-smc_tune-type.patch @@ -0,0 +1,32 @@ +From d8dd0c577bc887e123ab1449b005cc9e534fda09 Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Mon, 16 Dec 2024 15:43:25 +0800 +Subject: [PATCH 2/3] fix smc_tune type + +--- + src/plugin/tune/system/network/smc_tune/smc_tune.cpp | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/plugin/tune/system/network/smc_tune/smc_tune.cpp b/src/plugin/tune/system/network/smc_tune/smc_tune.cpp +index e1c7f6f..2b910e7 100644 +--- a/src/plugin/tune/system/network/smc_tune/smc_tune.cpp ++++ b/src/plugin/tune/system/network/smc_tune/smc_tune.cpp +@@ -19,11 +19,12 @@ int log_level = 0; + SmcTune::SmcTune() + { + name = OE_SMC_TUNE; +- description = "collect information of key thread"; ++ description = "This solution uses Shared Memory Communications - Direct Memory Access(SMC-D) for TCP" ++ " connections to local peers which also support this function."; + version = "1.0.0"; +- period = -1; ++ period = 1000; + priority = 2; +- type = 2; ++ type = TUNE; + } + + oeaware::Result SmcTune::OpenTopic(const oeaware::Topic &topic) +-- +2.33.0 + diff --git a/oeAware-manager.spec b/oeAware-manager.spec index 32c67d1..bcf45b8 100644 --- a/oeAware-manager.spec +++ b/oeAware-manager.spec @@ -1,11 +1,14 @@ Name: oeAware-manager Version: v2.0.1 -Release: 1 +Release: 2 Summary: OeAware is a framework for implementing low-load collection, sensing, and tuning on openEuler. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz Patch1: 0001-change-the-folder-permission-to-755-add-oeaware-grou.patch +Patch2: 0002-docker_cpu_burst-instance-add-unsubscribe-topics.patch +Patch3: 0003-add-pmu-check.patch +Patch4: 0004-fix-smc_tune-type.patch BuildRequires: cmake make gcc-c++ BuildRequires: boost-devel @@ -100,6 +103,11 @@ fi %attr(0644, root, root) %{_includedir}/oeaware/data/*.h %changelog +* Wed Dec 18 2024 fly_1997 -v2.0.1-2 +- fix smc type error +- fix cpu burst unsubscribe problem +- add pmu check + * Wed Dec 11 2024 LHesperus -v2.0.1-1 - add some document - fix bug : spe period dynamic changes -- Gitee