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