diff --git a/0006-add-one-time-command-collection.patch b/0006-add-one-time-command-collection.patch new file mode 100644 index 0000000..0008869 --- /dev/null +++ b/0006-add-one-time-command-collection.patch @@ -0,0 +1,510 @@ +From 55a03b46318e4c977b7e84508c998775e9db34ba Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Tue, 3 Dec 2024 09:13:09 +0800 +Subject: [PATCH 1/4] add one-time command collection + +--- + src/common/utils.cpp | 29 +++ + src/common/utils.h | 3 + + src/plugin/collect/system/CMakeLists.txt | 2 + + .../collect/system/command/command_base.h | 2 +- + .../system/command/command_collector.cpp | 5 +- + src/plugin/collect/system/kernel_config.cpp | 223 ++++++++++-------- + src/plugin/collect/system/kernel_config.h | 25 +- + tests/CMakeLists.txt | 2 +- + 8 files changed, 175 insertions(+), 116 deletions(-) + +diff --git a/src/common/utils.cpp b/src/common/utils.cpp +index a300a6a..ddd5235 100644 +--- a/src/common/utils.cpp ++++ b/src/common/utils.cpp +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -172,4 +173,32 @@ bool CreateDir(const std::string &path) + } while (pos != std::string::npos); + return true; + } ++ ++bool SetDataListTopic(DataList *dataList, const std::string &instanceName, const std::string &topicName, ++ const std::string ¶ms) ++{ ++ dataList->topic.instanceName = new char[instanceName.size() + 1]; ++ if (dataList->topic.instanceName == nullptr) { ++ return false; ++ } ++ strcpy_s(dataList->topic.instanceName, instanceName.size() + 1, instanceName.data()); ++ dataList->topic.topicName = new char[topicName.size() + 1]; ++ if (dataList->topic.topicName == nullptr) { ++ delete[] dataList->topic.instanceName; ++ dataList->topic.instanceName = nullptr; ++ return false; ++ } ++ strcpy_s(dataList->topic.topicName, topicName.size() + 1, topicName.data()); ++ dataList->topic.params = new char[params.size() + 1]; ++ if (dataList->topic.params == nullptr) { ++ delete[] dataList->topic.instanceName; ++ delete[] dataList->topic.topicName; ++ dataList->topic.instanceName = nullptr; ++ dataList->topic.topicName = nullptr; ++ return false; ++ } ++ strcpy_s(dataList->topic.params, params.size() + 1, params.data()); ++ return true; ++} ++ + } +diff --git a/src/common/utils.h b/src/common/utils.h +index 48b72bd..ceadf36 100644 +--- a/src/common/utils.h ++++ b/src/common/utils.h +@@ -13,6 +13,7 @@ + #define COMMON_UTILS_H + #include + #include ++#include "data_list.h" + + namespace oeaware { + bool Download(const std::string &url, const std::string &path); +@@ -29,6 +30,8 @@ std::string Concat(const std::vector& strings, const std::string &s + // Separate "str" with the separator "split" + std::vector SplitString(const std::string &str, const std::string &split); + bool CreateDir(const std::string &path); ++bool SetDataListTopic(DataList *dataList, const std::string &instanceName, const std::string &topicName, ++ const std::string ¶ms); + } + + #endif // !COMMON_UTILS_H +\ No newline at end of file +diff --git a/src/plugin/collect/system/CMakeLists.txt b/src/plugin/collect/system/CMakeLists.txt +index af4a239..b7d2666 100644 +--- a/src/plugin/collect/system/CMakeLists.txt ++++ b/src/plugin/collect/system/CMakeLists.txt +@@ -10,5 +10,7 @@ add_library(system_collector SHARED + ./command/command_collector.cpp + ./command/command_base.cpp + ) ++target_include_directories(system_collector PRIVATE src/common) ++target_link_libraries(system_collector common) + set_target_properties(system_collector PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_OUTPUT_LIBRARY_DIRECTORY}) +\ No newline at end of file +diff --git a/src/plugin/collect/system/command/command_base.h b/src/plugin/collect/system/command/command_base.h +index ef9bd7c..8653a60 100644 +--- a/src/plugin/collect/system/command/command_base.h ++++ b/src/plugin/collect/system/command/command_base.h +@@ -34,7 +34,7 @@ public: + std::string nowType; + oeaware::Topic topic; + std::unordered_map> attrsFirst; +- std::vector skipLine{"---swap--"}; ++ std::vector skipLine{"---swap--", "Average:"}; + static std::vector command; + static std::vector illegal; + CommandBase(); +diff --git a/src/plugin/collect/system/command/command_collector.cpp b/src/plugin/collect/system/command/command_collector.cpp +index 640a406..1f6ac1e 100644 +--- a/src/plugin/collect/system/command/command_collector.cpp ++++ b/src/plugin/collect/system/command/command_collector.cpp +@@ -9,8 +9,8 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- + #include "command_collector.h" ++#include + + CommandCollector::CommandCollector(): oeaware::Interface() + { +@@ -41,8 +41,9 @@ void CommandCollector::CollectThread(const oeaware::Topic &topic, CommandBase* c + while (collector->isRunning && fgets(buffer, sizeof(buffer), p.stream) != nullptr) { + collector->ParseLine(std::string(buffer)); + } ++ int waitTime = 10 * 1000; ++ usleep(waitTime); + p.Pclose(); +- + collector->Close(); + } + +diff --git a/src/plugin/collect/system/kernel_config.cpp b/src/plugin/collect/system/kernel_config.cpp +index 3d25251..145251c 100644 +--- a/src/plugin/collect/system/kernel_config.cpp ++++ b/src/plugin/collect/system/kernel_config.cpp +@@ -17,7 +17,9 @@ + #include + #include + #include ++#include "utils.h" + #include "command_base.h" ++#include "data_register.h" + + KernelConfig::KernelConfig(): oeaware::Interface() + { +@@ -35,6 +37,31 @@ KernelConfig::KernelConfig(): oeaware::Interface() + } + } + ++bool KernelConfig::InitCmd(std::stringstream &ss, const std::string &topicType) ++{ ++ std::string cmd; ++ std::string word; ++ while (ss >> word) { ++ if (word == cmdSeparator) { ++ if (!CommandBase::ValidateCmd(cmd)) { ++ return false; ++ } ++ getCmds[topicType].emplace_back(cmd); ++ cmd = ""; ++ continue; ++ } ++ if (!cmd.empty()) { ++ cmd += " "; ++ } ++ cmd += word; ++ } ++ if (!CommandBase::ValidateCmd(cmd)) { ++ return false; ++ } ++ getCmds[topicType].emplace_back(cmd); ++ return true; ++} ++ + oeaware::Result KernelConfig::OpenTopic(const oeaware::Topic &topic) + { + if (find(topicStr.begin(), topicStr.end(), topic.topicName) == topicStr.end()) { +@@ -42,9 +69,12 @@ oeaware::Result KernelConfig::OpenTopic(const oeaware::Topic &topic) + } + std::stringstream ss(topic.params); + std::string word; +- while (ss >> word) { +- if (topic.topicName == "get_kernel_config") { +- getTopics[topic.GetType()].insert(word); ++ std::string topicType = topic.GetType(); ++ if (topic.topicName == "get_cmd" && !InitCmd(ss, topicType)) { ++ return oeaware::Result(FAILED, "params invalid."); ++ } else if (topic.topicName == "get_kernel_config") { ++ while (ss >> word) { ++ getTopics[topicType].insert(word); + } + } + return oeaware::Result(OK); +@@ -53,87 +83,11 @@ oeaware::Result KernelConfig::OpenTopic(const oeaware::Topic &topic) + void KernelConfig::CloseTopic(const oeaware::Topic &topic) + { + getTopics.erase(topic.GetType()); ++ getCmds.erase(topic.GetType()); + setSystemParams.clear(); + cmdRun.clear(); + } + +-void KernelConfig::InitFileParam() +-{ +- for (auto &v : kernelParamPath) { +- std::string path = v[1]; +- std::ifstream file(path); +- if (!file.is_open()) { +- continue; +- } +- std::string key = v[0]; +- std::string line; +- std::string value = ""; +- while (std::getline(file, line)) { +- if (line.empty()) { +- continue; +- } +- value += line; +- value += '\n'; +- } +- kernelParams[key] = value; +- file.close(); +- } +-} +- +-void KernelConfig::AddCommandParam(const std::string &cmd) +-{ +- FILE *pipe = popen(cmd.data(), "r"); +- if (!pipe) { +- return; +- } +- char buffer[1024]; +- std::string value; +- while (fgets(buffer, sizeof(buffer), pipe) != nullptr) { +- value += buffer; +- } +- pclose(pipe); +- auto v = oeaware::SplitString(cmd, " "); +- std::vector skipSpace; +- for (auto &word : v) { +- if (word.empty()) continue; +- skipSpace.emplace_back(word); +- } +- if (skipSpace.size() > 1 && v[0] == "ethtool") { +- kernelParams[v[0] + "@" + v[1]] = value; +- return; +- } +- kernelParams[cmd] = value; +-} +- +-static bool IsSymlink(const std::string &path) +-{ +- struct stat st; +- if (lstat(path.c_str(), &st) != 0) { +- perror("lstat failed"); +- return false; +- } +- return S_ISLNK(st.st_mode); +-} +- +-void KernelConfig::GetAllEth() +-{ +- const std::string path = "/sys/class/net"; +- std::vector interfaces; +- DIR* dir = opendir(path.c_str()); +- if (dir == nullptr) { +- WARN(logger, "failed to open directory: " << path << "."); +- return; +- } +- struct dirent* entry; +- while ((entry = readdir(dir)) != nullptr) { +- std::string name(entry->d_name); +- if (name != "." && name != ".." && IsSymlink(path + "/" + name)) { +- allEths.push_back(name); +- } +- } +- closedir(dir); +-} +- + oeaware::Result KernelConfig::Enable(const std::string ¶m) + { + (void)param; +@@ -156,21 +110,12 @@ oeaware::Result KernelConfig::Enable(const std::string ¶m) + sysctlParams[values[0]] = values[1]; + } + pclose(pipe); +- InitFileParam(); +- GetAllEth(); +- AddCommandParam("lscpu"); +- AddCommandParam("ifconfig"); +- for (auto ð : allEths) { +- AddCommandParam("ethtool " + eth); +- } +- + return oeaware::Result(OK); + } + + void KernelConfig::Disable() + { + sysctlParams.clear(); +- kernelParams.clear(); + setSystemParams.clear(); + getTopics.clear(); + cmdRun.clear(); +@@ -196,32 +141,103 @@ void KernelConfig::UpdateData(const DataList &dataList) + return; + } + +-void KernelConfig::PublishKernelConfig() ++std::vector KernelConfig::getCmdGroup{"cat", "grep", "awk", "pgrep", "ls", "ethtool"}; ++ ++static void SetKernelData(KernelData *data, const std::string &ret) + { +- if (getTopics.empty()) { ++ data->kernelData = new KernelDataNode(); ++ if (data->kernelData == nullptr) { ++ return; ++ } ++ data->len = 1; ++ data->kernelData->key = new char[1]; ++ if (data->kernelData->key == nullptr) { ++ delete data->kernelData; ++ data->kernelData = nullptr; ++ return; ++ } ++ data->kernelData->key[0] = 0; ++ data->kernelData->value = new char[ret.size() + 1]; ++ if (data->kernelData->value == nullptr) { ++ delete data->kernelData; ++ delete[] data->kernelData->key; ++ data->kernelData->key = nullptr; ++ data->kernelData = nullptr; + return; + } ++ strcpy_s(data->kernelData->value, ret.size() + 1, ret.data()); ++ data->kernelData->next = nullptr; ++} ++ ++void KernelConfig::PublishCmd() ++{ ++ for (auto &p : getCmds) { ++ oeaware::Topic topic = oeaware::Topic::GetTopicFromType(p.first); ++ DataList dataList; ++ if (!oeaware::SetDataListTopic(&dataList, topic.instanceName, topic.topicName, topic.params)) { ++ continue; ++ } ++ KernelData *data = new KernelData(); ++ if (data == nullptr) { ++ WARN(logger, "KernelData failed to allocate memory."); ++ continue; ++ } ++ std::string cmd = ""; ++ for (auto &cmdPart : p.second) { ++ if (!cmd.empty()) { ++ cmd += " | "; ++ } ++ cmd += cmdPart; ++ } ++ PopenProcess pipe; ++ pipe.Popen(cmd); ++ char buffer[1024]; ++ std::string ret = ""; ++ while (fgets(buffer, sizeof(buffer), pipe.stream) != nullptr) { ++ ret += buffer; ++ } ++ if (pipe.Pclose() < 0) { ++ WARN(logger, "pipe close error."); ++ } ++ SetKernelData(data, ret); ++ dataList.len = 1; ++ dataList.data = new void* [1]; ++ if (dataList.data == nullptr) { ++ oeaware::Register::GetInstance().GetDataFreeFunc("kernel_config")(data); ++ continue; ++ } ++ dataList.data[0] = data; ++ Publish(dataList); ++ } ++} ++ ++void KernelConfig::PublishKernelParams() ++{ + for (auto &p : getTopics) { + oeaware::Topic topic = oeaware::Topic::GetTopicFromType(p.first); + DataList dataList; +- dataList.topic.instanceName = new char[topic.instanceName.size() + 1]; +- strcpy_s(dataList.topic.instanceName, topic.instanceName.size() + 1, topic.instanceName.data()); +- dataList.topic.topicName = new char[topic.topicName.size() + 1]; +- strcpy_s(dataList.topic.topicName, topic.topicName.size() + 1, topic.topicName.data()); +- dataList.topic.params = new char[topic.params.size() + 1]; +- strcpy_s(dataList.topic.params, topic.params.size() + 1, topic.params.data()); ++ if (!oeaware::SetDataListTopic(&dataList, topic.instanceName, topic.topicName, topic.params)) { ++ continue; ++ } + KernelData *data = new KernelData(); ++ if (data == nullptr) { ++ WARN(logger, "KernelData failed to allocate memory."); ++ continue; ++ } + KernelDataNode *tmp = nullptr; + for (auto &name : p.second) { + std::string value = ""; + if (sysctlParams.count(name)) { + value = sysctlParams[name]; +- } else if (kernelParams.count(name)) { +- value = kernelParams[name]; + } else { ++ WARN(logger, "invalid params: " << name << "."); + continue; + } + KernelDataNode *newNode = createNode(name.data(), value.data()); ++ if (newNode == nullptr) { ++ WARN(logger, "KernelDataNode failed to allocate memory."); ++ continue; ++ } + if (data->kernelData == NULL) { + data->kernelData = newNode; + tmp = newNode; +@@ -239,6 +255,15 @@ void KernelConfig::PublishKernelConfig() + } + } + ++void KernelConfig::PublishKernelConfig() ++{ ++ if (getTopics.empty() && getCmds.empty()) { ++ return; ++ } ++ PublishCmd(); ++ PublishKernelParams(); ++} ++ + void KernelConfig::WriteSysParam(const std::string &path, const std::string &value) + { + std::ofstream sysFile(path); +diff --git a/src/plugin/collect/system/kernel_config.h b/src/plugin/collect/system/kernel_config.h +index 32049d4..4c6eb99 100644 +--- a/src/plugin/collect/system/kernel_config.h ++++ b/src/plugin/collect/system/kernel_config.h +@@ -20,10 +20,11 @@ + /* + * topic: get_kernel_config, obtain the kernel parameter information. + * params: kernel params name, including +- * 1. sysctl -a -N +- * 2. kernel_version, os_release, meminfo, zone_reclaim_mode +- * 3. lscpu, ifconfig, ethtool@{name}. +- * params : ++ * 1. sysctl -a -N ++ * ++ * topic: get_cmd, the trustlist command is supported. ++ * params: each command is seqarated by "@@", include "cat", "grep", "awk", "pgrep", "ls", "ethtool". ++ * + * topic: set_kernel_config, modify kernel parameters. + * DataList: + * data: KernelData, [key, value]: +@@ -41,29 +42,27 @@ public: + void Disable() override; + void Run() override; + private: ++ void PublishCmd(); ++ void PublishKernelParams(); + void PublishKernelConfig(); + void SetKernelConfig(); ++ bool InitCmd(std::stringstream &ss, const std::string &topicType); + void InitFileParam(); + void AddCommandParam(const std::string &cmd); + void WriteSysParam(const std::string &path, const std::string &value); + void GetAllEth(); + +- std::vector topicStr = {"get_kernel_config", "set_kernel_config"}; +- +- const std::vector> kernelParamPath{{"kernel_version", "/proc/version"}, +- {"os_release", "/etc/os-release"}, {"meminfo", "/proc/meminfo"}, +- {"zone_reclaim_mode", "/proc/sys/vm/zone_reclaim_mode"}}; ++ std::vector topicStr = {"get_kernel_config", "get_cmd", "set_kernel_config"}; + // key: topic type, value: parameters to be queried. + std::unordered_map> getTopics; ++ std::unordered_map> getCmds; + std::vector> setSystemParams; + + std::unordered_map sysctlParams; +- // Stores system parameters, include lscpu, ifconfig, file path. +- std::unordered_map kernelParams; +- + std::vector cmdRun; ++ static std::vector getCmdGroup; + static std::vector cmdGroup; +- std::vector allEths; ++ const std::string cmdSeparator = "@@"; + }; + + #endif +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index dec13ac..11079f2 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -25,7 +25,7 @@ add_executable(pmu_count_test + pmu_count_test.cpp + ) + +-target_link_libraries(serialize_test PRIVATE curl GTest::gtest_main) ++target_link_libraries(serialize_test PRIVATE common GTest::gtest_main) + target_link_libraries(logger_test PRIVATE GTest::gtest_main log4cplus) + target_link_libraries(safe_queue_test PRIVATE GTest::gtest_main) + target_link_libraries(pmu_count_test PRIVATE GTest::gtest_main) +-- +2.33.0 + diff --git a/0007-fix-bug-free-spe-mem-after-use-data.patch b/0007-fix-bug-free-spe-mem-after-use-data.patch new file mode 100644 index 0000000..5838edf --- /dev/null +++ b/0007-fix-bug-free-spe-mem-after-use-data.patch @@ -0,0 +1,135 @@ +From cf12b73ec44cf0c553319d675b780e6e8c84f0bc Mon Sep 17 00:00:00 2001 +From: LHesperus <2639350497@qq.com> +Date: Tue, 3 Dec 2024 16:10:46 +0800 +Subject: [PATCH 2/4] fix bug : free spe mem after use data + +--- + src/plugin/collect/pmu/pmu_spe_collector.cpp | 66 ++++++++++++-------- + src/plugin/collect/pmu/pmu_spe_collector.h | 5 +- + 2 files changed, 45 insertions(+), 26 deletions(-) + +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.cpp b/src/plugin/collect/pmu/pmu_spe_collector.cpp +index 114c0ee..8d265eb 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_spe_collector.cpp +@@ -63,15 +63,26 @@ int PmuSpeCollector::OpenSpe() + return pd; + } + +-void PmuSpeCollector::DynamicAdjustPeriod(uint64_t interval) ++void PmuSpeCollector::DynamicAdjustPeriod(int interval) + { ++ if (pmuId == -1) { ++ return; ++ } + if (interval > timeout) { + PmuDisable(pmuId); + PmuClose(pmuId); + attrPeriod *= periodThreshold; ++ if (attrPeriod > maxAttrPeriod) { ++ attrPeriod = maxAttrPeriod; ++ } ++ INFO(logger, "PmuSpeCollector dynamic adjust period to " << ++ attrPeriod << ", PmuRead interval is " << interval << " ms."); + pmuId = OpenSpe(); +- PmuEnable(pmuId); ++ if (pmuId != -1) { ++ PmuEnable(pmuId); ++ } + } ++ // later add code to decrease period when interval is too small + } + + oeaware::Result PmuSpeCollector::OpenTopic(const oeaware::Topic &topic) +@@ -79,7 +90,8 @@ oeaware::Result PmuSpeCollector::OpenTopic(const oeaware::Topic &topic) + if (topic.instanceName != this->name || topic.topicName != topicStr) { + return oeaware::Result(FAILED, "OpenTopic failed"); + } +- ++ attrPeriod = minAttrPeriod; ++ readTimeMs = 0; + if (pmuId == -1) { + pmuId = OpenSpe(); + if (pmuId == -1) { +@@ -124,27 +136,31 @@ void PmuSpeCollector::UpdateData(const DataList &dataList) + + void PmuSpeCollector::Run() + { +- if (pmuId != -1) { +- PmuSpeData *data = new PmuSpeData(); +- PmuDisable(pmuId); +- data->len = PmuRead(pmuId, &(data->pmuData)); +- PmuEnable(pmuId); +- +- auto now = std::chrono::high_resolution_clock::now(); +- data->interval = std::chrono::duration_cast(now - timestamp).count(); +- DynamicAdjustPeriod(data->interval); +- timestamp = std::chrono::high_resolution_clock::now(); +- +- DataList dataList; +- dataList.topic.instanceName = new char[name.size() + 1]; +- strcpy_s(dataList.topic.instanceName, name.size() + 1, name.data()); +- dataList.topic.topicName = new char[topicStr.size() + 1]; +- strcpy_s(dataList.topic.topicName, topicStr.size() + 1, topicStr.data()); +- dataList.topic.params = new char[1]; +- dataList.topic.params[0] = 0; +- dataList.len = 1; +- dataList.data = new void* [1]; +- dataList.data[0] = data; +- Publish(dataList); ++ // adjust period will pmuclose and free spe data ++ // so adjust period should be done after other plugins have finished using SPE data ++ DynamicAdjustPeriod(readTimeMs); ++ if (pmuId == -1) { ++ return; + } ++ PmuSpeData *data = new PmuSpeData(); ++ PmuDisable(pmuId); ++ auto readBegin = std::chrono::high_resolution_clock::now(); ++ data->len = PmuRead(pmuId, &(data->pmuData)); ++ readTimeMs = std::chrono::duration_cast( ++ std::chrono::high_resolution_clock::now() - readBegin).count(); ++ PmuEnable(pmuId); ++ auto now = std::chrono::high_resolution_clock::now(); ++ data->interval = std::chrono::duration_cast(now - timestamp).count(); ++ timestamp = std::chrono::high_resolution_clock::now(); ++ DataList dataList; ++ dataList.topic.instanceName = new char[name.size() + 1]; ++ strcpy_s(dataList.topic.instanceName, name.size() + 1, name.data()); ++ dataList.topic.topicName = new char[topicStr.size() + 1]; ++ strcpy_s(dataList.topic.topicName, topicStr.size() + 1, topicStr.data()); ++ dataList.topic.params = new char[1]; ++ dataList.topic.params[0] = 0; ++ dataList.len = 1; ++ dataList.data = new void *[1]; ++ dataList.data[0] = data; ++ Publish(dataList); + } +\ No newline at end of file +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.h b/src/plugin/collect/pmu/pmu_spe_collector.h +index 00f0be7..3323e47 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.h ++++ b/src/plugin/collect/pmu/pmu_spe_collector.h +@@ -28,7 +28,7 @@ public: + void Disable() override; + void Run() override; + private: +- void DynamicAdjustPeriod(uint64_t interval); ++ void DynamicAdjustPeriod(int interval); + void InitSpeAttr(struct PmuAttr &attr); + int OpenSpe(); + +@@ -38,6 +38,9 @@ private: + std::chrono::time_point timestamp; + const int timeout = 50; + const int periodThreshold = 2; ++ const int minAttrPeriod = 2048; ++ const int maxAttrPeriod = 2048000; ++ int readTimeMs = 0; // last period PmuRead() time + }; + + #endif +\ No newline at end of file +-- +2.33.0 + diff --git a/0008-Adjust-the-header-file-structure.patch b/0008-Adjust-the-header-file-structure.patch new file mode 100644 index 0000000..93ad3d3 --- /dev/null +++ b/0008-Adjust-the-header-file-structure.patch @@ -0,0 +1,2007 @@ +From 2b27b629317083abfc1ed82a289c7e75690aa515 Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Tue, 3 Dec 2024 18:46:31 +0800 +Subject: [PATCH 3/4] Adjust the header file structure + +--- + CMakeLists.txt | 24 +++++++++++++++++++ + build.sh | 4 +++- + .../oeaware/data}/adapt_data.h | 4 ++-- + .../oeaware/data}/command_data.h | 4 ++-- + .../oeaware/data}/docker_data.h | 7 ++---- + .../oeaware/data}/kernel_data.h | 8 +++---- + .../oeaware/data}/pmu_counting_data.h | 6 ++--- + .../oeaware/data}/pmu_plugin.h | 0 + .../oeaware/data}/pmu_sampling_data.h | 6 ++--- + .../oeaware/data}/pmu_spe_data.h | 6 ++--- + .../oeaware/data}/pmu_uncore_data.h | 6 ++--- + .../oeaware/data}/thread_info.h | 6 ++--- + {src/common => include/oeaware}/data_list.h | 20 ++++++++++++++-- + .../common => include/oeaware}/default_path.h | 6 ++--- + .../oeaware}/instance_run_message.h | 17 +++---------- + {src/common => include/oeaware}/interface.h | 12 +++++----- + {src/common => include/oeaware}/logger.h | 6 ++--- + {src/common => include/oeaware}/safe_queue.h | 6 ++--- + {src/common => include/oeaware}/serialize.h | 4 ++-- + {src/common => include/oeaware}/topic.h | 8 +++---- + {src/common => include/oeaware}/utils.h | 8 +++---- + install.sh | 4 ++-- + src/client/cmd_handler.cpp | 2 +- + src/client/main.cpp | 2 +- + src/client/tcp_socket.h | 2 +- + src/common/CMakeLists.txt | 19 +-------------- + src/common/data_register.cpp | 21 ++++++++-------- + src/common/data_register.h | 4 ++-- + src/common/domain_socket.cpp | 2 +- + src/common/event.h | 2 +- + src/common/logger.cpp | 2 +- + src/common/message_protocol.h | 2 +- + src/common/utils.cpp | 2 +- + src/plugin/CMakeLists.txt | 17 +------------ + src/plugin/collect/docker/CMakeLists.txt | 1 - + src/plugin/collect/docker/docker_adapt.cpp | 2 +- + src/plugin/collect/docker/docker_adapt.h | 4 ++-- + .../collect/docker/docker_collector.cpp | 2 -- + src/plugin/collect/pmu/CMakeLists.txt | 2 -- + .../collect/pmu/pmu_counting_collector.cpp | 7 +++--- + .../collect/pmu/pmu_counting_collector.h | 3 +-- + .../collect/pmu/pmu_sampling_collector.cpp | 7 +++--- + .../collect/pmu/pmu_sampling_collector.h | 3 +-- + src/plugin/collect/pmu/pmu_spe_collector.cpp | 7 +++--- + src/plugin/collect/pmu/pmu_spe_collector.h | 3 +-- + src/plugin/collect/pmu/pmu_uncore.cpp | 2 +- + .../collect/pmu/pmu_uncore_collector.cpp | 9 ++++--- + src/plugin/collect/pmu/pmu_uncore_collector.h | 3 +-- + src/plugin/collect/system/CMakeLists.txt | 3 ++- + .../collect/system/command/command_base.cpp | 3 ++- + .../collect/system/command/command_base.h | 4 +--- + .../system/command/command_collector.cpp | 2 +- + .../system/command/command_collector.h | 2 +- + src/plugin/collect/system/kernel_config.cpp | 7 +++--- + src/plugin/collect/system/kernel_config.h | 5 ++-- + src/plugin/collect/system/kernel_data.cpp | 4 ++-- + .../collect/system/system_collector.cpp | 1 - + .../collect/system/thread_collector.cpp | 2 +- + src/plugin/collect/system/thread_collector.h | 4 ++-- + src/plugin/scenario/analysis/CMakeLists.txt | 3 --- + .../analysis/adapt/analysis_aware.cpp | 12 ++++------ + .../scenario/analysis/adapt/analysis_aware.h | 4 ++-- + .../scenario/analysis/analysis/analysis.cpp | 2 +- + .../scenario/analysis/analysis/common.h | 2 +- + .../scenario/thread_aware/CMakeLists.txt | 4 ++-- + .../scenario/thread_aware/thread_aware.h | 4 ++-- + src/plugin/tune/docker/CMakeLists.txt | 2 -- + src/plugin/tune/docker/cpu_burst.cpp | 4 ++-- + src/plugin/tune/docker/cpu_burst.h | 4 ++-- + src/plugin/tune/docker/cpu_burst_adapt.cpp | 6 ++--- + src/plugin/tune/docker/cpu_burst_adapt.h | 2 +- + src/plugin/tune/docker/docker_adapt.cpp | 2 -- + .../system/cpu/stealtask_tune/CMakeLists.txt | 2 -- + .../cpu/stealtask_tune/stealtask_tune.cpp | 3 +-- + .../cpu/stealtask_tune/stealtask_tune.h | 2 +- + .../tune/system/network/smc_tune/smc_tune.cpp | 4 ++-- + .../tune/system/network/smc_tune/smc_tune.h | 2 +- + .../system/power/seep_tune/CMakeLists.txt | 1 - + .../tune/system/power/seep_tune/seep_tune.cpp | 3 +-- + .../tune/system/power/seep_tune/seep_tune.h | 2 +- + src/plugin/tune/system/system_tune.cpp | 2 +- + src/plugin/tune/system/xcall/xcall_tune.cpp | 4 ++-- + src/plugin/tune/system/xcall/xcall_tune.h | 4 +--- + src/plugin/tune/unixbench/ub_tune.cpp | 9 ++++--- + src/plugin/tune/unixbench/ub_tune.h | 2 +- + src/plugin_mgr/config.cpp | 2 +- + src/plugin_mgr/event/event_handler.h | 2 +- + src/plugin_mgr/event/list_handler.cpp | 4 ++-- + src/plugin_mgr/event/load_handler.cpp | 3 +-- + src/plugin_mgr/instance_run_handler.h | 5 ++-- + src/plugin_mgr/main.cpp | 4 ++-- + src/plugin_mgr/memory_store.h | 1 - + src/plugin_mgr/message_manager.cpp | 4 ++-- + src/plugin_mgr/message_manager.h | 3 +-- + src/plugin_mgr/plugin.h | 2 +- + src/plugin_mgr/plugin_manager.cpp | 2 +- + src/plugin_mgr/plugin_manager.h | 2 +- + src/sdk/CMakeLists.txt | 8 +++---- + src/sdk/oe_client.cpp | 6 ++--- + src/sdk/oe_client.h | 2 +- + tests/CMakeLists.txt | 2 +- + tests/logger_test.cpp | 2 +- + tests/safe_queue_test.cpp | 2 +- + tests/serialize_test.cpp | 2 +- + tests/utils_test.cpp | 2 +- + tests/xcall_tune_test.cpp | 1 - + 106 files changed, 225 insertions(+), 268 deletions(-) + rename {src/plugin/scenario/include => include/oeaware/data}/adapt_data.h (92%) + rename {src/plugin/collect/include => include/oeaware/data}/command_data.h (93%) + rename {src/plugin/collect/include => include/oeaware/data}/docker_data.h (66%) + rename {src/plugin/collect/include => include/oeaware/data}/kernel_data.h (85%) + rename {src/plugin/collect/include => include/oeaware/data}/pmu_counting_data.h (89%) + rename {src/plugin/collect/include => include/oeaware/data}/pmu_plugin.h (100%) + rename {src/plugin/collect/include => include/oeaware/data}/pmu_sampling_data.h (89%) + rename {src/plugin/collect/include => include/oeaware/data}/pmu_spe_data.h (90%) + rename {src/plugin/collect/include => include/oeaware/data}/pmu_uncore_data.h (89%) + rename {src/plugin/collect/include => include/oeaware/data}/thread_info.h (91%) + rename {src/common => include/oeaware}/data_list.h (55%) + rename {src/common => include/oeaware}/default_path.h (92%) + rename {src/common => include/oeaware}/instance_run_message.h (81%) + rename {src/common => include/oeaware}/interface.h (94%) + rename {src/common => include/oeaware}/logger.h (96%) + rename {src/common => include/oeaware}/safe_queue.h (96%) + rename {src/common => include/oeaware}/serialize.h (99%) + rename {src/common => include/oeaware}/topic.h (95%) + rename {src/common => include/oeaware}/utils.h (94%) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 02ba4df..c0ba108 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,3 +8,27 @@ add_subdirectory(src/plugin_mgr) + add_subdirectory(src/client) + add_subdirectory(src/sdk) + add_subdirectory(tests) ++ ++if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") ++file(COPY "${CMAKE_SOURCE_DIR}/include/oeaware/data/pmu_counting_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/pmu_sampling_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/pmu_spe_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/pmu_uncore_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/docker_data.h" ++ DESTINATION "${CMAKE_BINARY_DIR}/output/include/oeaware/data") ++endif() ++file(COPY "${CMAKE_SOURCE_DIR}/include/oeaware/data/kernel_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/command_data.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/data/thread_info.h" ++ DESTINATION "${CMAKE_BINARY_DIR}/output/include/oeaware/data") ++ ++file(COPY "${CMAKE_SOURCE_DIR}/include/oeaware/data_list.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/default_path.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/instance_run_message.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/interface.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/logger.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/safe_queue.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/serialize.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/topic.h" ++ "${CMAKE_SOURCE_DIR}/include/oeaware/utils.h" ++ DESTINATION "${CMAKE_BINARY_DIR}/output/include/oeaware/") +\ No newline at end of file +diff --git a/build.sh b/build.sh +index cfee1c8..fe4c676 100644 +--- a/build.sh ++++ b/build.sh +@@ -53,6 +53,8 @@ elif [[ "$os_arch" == "aarch64" && "$build_kperf_by_src" == "ON" ]]; then + git checkout $libkperf_version + sh build.sh + cd .. ++ mkdir ${script_dir}/include/oeaware/data/libkperf ++ cp ${libkperf_inc}/* ${script_dir}/include/oeaware/data/libkperf + elif [[ "$os_arch" == "aarch64" && "$build_kperf_by_src" == "OFF" ]]; then + echo "[NOTE] use libkperf by rpm" + libkperf_inc=/usr/include/libkperf +@@ -60,5 +62,5 @@ elif [[ "$os_arch" == "aarch64" && "$build_kperf_by_src" == "OFF" ]]; then + fi + + +-cmake .. -DLIB_KPERF_LIBPATH=${libkperf_lib} -DLIB_KPERF_INCPATH=${libkperf_inc} ++cmake .. -DLIB_KPERF_LIBPATH=${libkperf_lib} -DLIB_KPERF_INCPATH=${script_dir}/include/oeaware/data + make -j$(nproc) +\ No newline at end of file +diff --git a/src/plugin/scenario/include/adapt_data.h b/include/oeaware/data/adapt_data.h +similarity index 92% +rename from src/plugin/scenario/include/adapt_data.h +rename to include/oeaware/data/adapt_data.h +index 65423ee..e3e2878 100644 +--- a/src/plugin/scenario/include/adapt_data.h ++++ b/include/oeaware/data/adapt_data.h +@@ -10,8 +10,8 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef ADAPT_DATA_H +-#define ADAPT_DATA_H ++#ifndef OEAWARE_DATA_ADAPT_DATA_H ++#define OEAWARE_DATA_ADAPT_DATA_H + + #ifdef __cplusplus + extern "C" { +diff --git a/src/plugin/collect/include/command_data.h b/include/oeaware/data/command_data.h +similarity index 93% +rename from src/plugin/collect/include/command_data.h +rename to include/oeaware/data/command_data.h +index e7a8540..13aef4a 100644 +--- a/src/plugin/collect/include/command_data.h ++++ b/include/oeaware/data/command_data.h +@@ -10,8 +10,8 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef COMMAND_DATA_H +-#define COMMAND_DATA_H ++#ifndef OEAWARE_DATA_COMMAND_DATA_H ++#define OEAWARE_DATA_COMMAND_DATA_H + + #define ATTR_MAX_LENGTH 20 + #ifdef __cplusplus +diff --git a/src/plugin/collect/include/docker_data.h b/include/oeaware/data/docker_data.h +similarity index 66% +rename from src/plugin/collect/include/docker_data.h +rename to include/oeaware/data/docker_data.h +index acd917d..b8d94b9 100644 +--- a/src/plugin/collect/include/docker_data.h ++++ b/include/oeaware/data/docker_data.h +@@ -1,15 +1,12 @@ + +-#ifndef __DOCKER_COLLECTOR_H__ +-#define __DOCKER_COLLECTOR_H__ ++#ifndef OEAWARE_DATA_DOCKER_COLLECTOR_H ++#define OEAWARE_DATA_DOCKER_COLLECTOR_H + #include + #include + + #ifdef __cplusplus + extern "C" { + #endif +- +-#define DOCKER_COLLECTOR "docker_collector" +- + struct Container { + std::string id; + int64_t cfs_period_us; +diff --git a/src/plugin/collect/include/kernel_data.h b/include/oeaware/data/kernel_data.h +similarity index 85% +rename from src/plugin/collect/include/kernel_data.h +rename to include/oeaware/data/kernel_data.h +index c796513..258c9de 100644 +--- a/src/plugin/collect/include/kernel_data.h ++++ b/include/oeaware/data/kernel_data.h +@@ -10,14 +10,14 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef KERNEL_DATA_H +-#define KERNEL_DATA_H ++#ifndef OEAWARE_DATA_KERNEL_DATA_H ++#define OEAWARE_DATA_KERNEL_DATA_H + + #ifdef __cplusplus + extern "C" { + #endif + +-typedef struct KernelDataNode{ ++typedef struct KernelDataNode { + char *key; + char *value; + struct KernelDataNode *next; +@@ -28,7 +28,7 @@ typedef struct { + KernelDataNode *kernelData; + } KernelData; + +-KernelDataNode* createNode(const char *key, const char *value); ++KernelDataNode* CreateNode(const char *key, const char *value); + #ifdef __cplusplus + } + #endif +diff --git a/src/plugin/collect/include/pmu_counting_data.h b/include/oeaware/data/pmu_counting_data.h +similarity index 89% +rename from src/plugin/collect/include/pmu_counting_data.h +rename to include/oeaware/data/pmu_counting_data.h +index fd07496..032dfff 100644 +--- a/src/plugin/collect/include/pmu_counting_data.h ++++ b/include/oeaware/data/pmu_counting_data.h +@@ -10,9 +10,9 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef PMU_COUNTING_DATA_H +-#define PMU_COUNTING_DATA_H +-#include "pmu.h" ++#ifndef OEAWARE_DATA_PMU_COUNTING_DATA_H ++#define OEAWARE_DATA_PMU_COUNTING_DATA_H ++#include + + #ifdef __cplusplus + extern "C" { +diff --git a/src/plugin/collect/include/pmu_plugin.h b/include/oeaware/data/pmu_plugin.h +similarity index 100% +rename from src/plugin/collect/include/pmu_plugin.h +rename to include/oeaware/data/pmu_plugin.h +diff --git a/src/plugin/collect/include/pmu_sampling_data.h b/include/oeaware/data/pmu_sampling_data.h +similarity index 89% +rename from src/plugin/collect/include/pmu_sampling_data.h +rename to include/oeaware/data/pmu_sampling_data.h +index 517d9ab..f683c4e 100644 +--- a/src/plugin/collect/include/pmu_sampling_data.h ++++ b/include/oeaware/data/pmu_sampling_data.h +@@ -10,9 +10,9 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef PMU_SAMPLING_DATA_H +-#define PMU_SAMPLING_DATA_H +-#include "pmu.h" ++#ifndef OEAWARE_DATA_PMU_SAMPLING_DATA_H ++#define OEAWARE_DATA_PMU_SAMPLING_DATA_H ++#include + + #ifdef __cplusplus + extern "C" { +diff --git a/src/plugin/collect/include/pmu_spe_data.h b/include/oeaware/data/pmu_spe_data.h +similarity index 90% +rename from src/plugin/collect/include/pmu_spe_data.h +rename to include/oeaware/data/pmu_spe_data.h +index 90991e2..c45e72d 100644 +--- a/src/plugin/collect/include/pmu_spe_data.h ++++ b/include/oeaware/data/pmu_spe_data.h +@@ -10,9 +10,9 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef PMU_SPE_DATA_H +-#define PMU_SPE_DATA_H +-#include "pmu.h" ++#ifndef OEAWARE_DATA_PMU_SPE_DATA_H ++#define OEAWARE_DATA_PMU_SPE_DATA_H ++#include + + #ifdef __cplusplus + extern "C" { +diff --git a/src/plugin/collect/include/pmu_uncore_data.h b/include/oeaware/data/pmu_uncore_data.h +similarity index 89% +rename from src/plugin/collect/include/pmu_uncore_data.h +rename to include/oeaware/data/pmu_uncore_data.h +index b33fe41..8afa47f 100644 +--- a/src/plugin/collect/include/pmu_uncore_data.h ++++ b/include/oeaware/data/pmu_uncore_data.h +@@ -10,9 +10,9 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#ifndef PMU_UNCORE_DATA_H +-#define PMU_UNCORE_DATA_H +-#include "pmu.h" ++#ifndef OEAWARE_DATA_PMU_UNCORE_DATA_H ++#define OEAWARE_DATA_PMU_UNCORE_DATA_H ++#include + + #ifdef __cplusplus + extern "C" { +diff --git a/src/plugin/collect/include/thread_info.h b/include/oeaware/data/thread_info.h +similarity index 91% +rename from src/plugin/collect/include/thread_info.h +rename to include/oeaware/data/thread_info.h +index 3838927..d24a480 100644 +--- a/src/plugin/collect/include/thread_info.h ++++ b/include/oeaware/data/thread_info.h +@@ -9,8 +9,8 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef THREAD_INFO_H +-#define THREAD_INFO_H ++#ifndef OEAWARE_DATA_THREAD_INFO_H ++#define OEAWARE_DATA_THREAD_INFO_H + #ifdef __cplusplus + extern "C" { + #endif +@@ -23,4 +23,4 @@ typedef struct { + } + #endif + +-#endif // !THREAD_INFO_H ++#endif +diff --git a/src/common/data_list.h b/include/oeaware/data_list.h +similarity index 55% +rename from src/common/data_list.h +rename to include/oeaware/data_list.h +index 78fa0c9..11962c0 100644 +--- a/src/common/data_list.h ++++ b/include/oeaware/data_list.h +@@ -9,8 +9,24 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_DATA_LIST_H +-#define COMMON_DATA_LIST_H ++#ifndef OEAWARE_DATA_LIST_H ++#define OEAWARE_DATA_LIST_H ++// Names of all instances. ++#define OE_PMU_COUNTING_COLLECTOR "pmu_counting_collector" ++#define OE_PMU_SAMPLING_COLLECTOR "pmu_sampling_collector" ++#define OE_PMU_SPE_COLLECTOR "pmu_spe_collector" ++#define OE_PMU_UNCORE_COLLECTOR "pmu_uncore_collector" ++#define OE_DOCKER_COLLECTOR "docker_collector" ++#define OE_KERNEL_CONFIG_COLLECTOR "kernel_config" ++#define OE_THREAD_COLLECTOR "thread_collector" ++#define OE_COMMAND_COLLECTOR "command_collector" ++#define OE_UNIXBENCH_TUNE "unixbench_tune" ++#define OE_DOCKER_CPU_BURST_TUNE "docker_cpu_burst" ++#define OE_STEALTASK_TUNE "stealtask_tune" ++#define OE_SMC_TUNE "smc_tune" ++#define OE_SEEP_TUNE "seep_tune" ++#define OE_XCALL_TUNE "xcall_tune" ++ + #ifdef __cplusplus + extern "C" { + #endif +diff --git a/src/common/default_path.h b/include/oeaware/default_path.h +similarity index 92% +rename from src/common/default_path.h +rename to include/oeaware/default_path.h +index 091400c..99042c4 100644 +--- a/src/common/default_path.h ++++ b/include/oeaware/default_path.h +@@ -9,8 +9,8 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_DEFAULT_PATH_H +-#define COMMON_DEFAULT_PATH_H ++#ifndef OEAWARE_DEFAULT_PATH_H ++#define OEAWARE_DEFAULT_PATH_H + #include + + namespace oeaware { +@@ -21,4 +21,4 @@ const std::string DEFAULT_SERVER_LISTEN_PATH = "/var/run/oeAware/oeAware-server" + const std::string DEFAULT_SDK_CONN_PATH = "/var/run/oeAware/oeAware-sdk"; + } + +-#endif // !COMMON_DEFAULT_PATH_H +\ No newline at end of file ++#endif +\ No newline at end of file +diff --git a/src/common/instance_run_message.h b/include/oeaware/instance_run_message.h +similarity index 81% +rename from src/common/instance_run_message.h +rename to include/oeaware/instance_run_message.h +index 647a004..5f6c147 100644 +--- a/src/common/instance_run_message.h ++++ b/include/oeaware/instance_run_message.h +@@ -10,11 +10,11 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef INSTANCE_RUN_MESSAGE_H +-#define INSTANCE_RUN_MESSAGE_H ++#ifndef OEAWARE_INSTANCE_RUN_MESSAGE_H ++#define OEAWARE_INSTANCE_RUN_MESSAGE_H + #include + #include +-#include "topic.h" ++#include + + namespace oeaware { + enum class RunType { +@@ -70,16 +70,5 @@ enum class InstanceMessageType { + UNSUBSCRIBE, + PUBLISH_DATA, + }; +- +-class InstanceMessage { +- // InstanceMessage() {} +- // explicit InstanceMessage(RunType type) : type(type) { } +- // InstanceMessage(RunType type, const std::vector &payload) : payload(payload), type(type) { } +- InstanceMessageType type; +- std::vector payload; +- Result result; +- const DataList *dataList; +-}; +- + } + #endif +\ No newline at end of file +diff --git a/src/common/interface.h b/include/oeaware/interface.h +similarity index 94% +rename from src/common/interface.h +rename to include/oeaware/interface.h +index 83323cd..5f915a4 100644 +--- a/src/common/interface.h ++++ b/include/oeaware/interface.h +@@ -9,12 +9,12 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_INTERFACE_H +-#define COMMON_INTERFACE_H +-#include "data_list.h" +-#include "logger.h" +-#include "safe_queue.h" +-#include "instance_run_message.h" ++#ifndef OEAWARE_INTERFACE_H ++#define OEAWARE_INTERFACE_H ++#include ++#include ++#include ++#include + + namespace oeaware { + // Instance type. +diff --git a/src/common/logger.h b/include/oeaware/logger.h +similarity index 96% +rename from src/common/logger.h +rename to include/oeaware/logger.h +index 1c3ee18..1a8745e 100644 +--- a/src/common/logger.h ++++ b/include/oeaware/logger.h +@@ -9,13 +9,13 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_LOGGER_H +-#define COMMON_LOGGER_H ++#ifndef OEAWARE_LOGGER_H ++#define OEAWARE_LOGGER_H + #include + #include + #include + #include +-#include "default_path.h" ++#include + + namespace oeaware { + #define INFO(logger, fmt) LOG4CPLUS_INFO(logger, fmt) +diff --git a/src/common/safe_queue.h b/include/oeaware/safe_queue.h +similarity index 96% +rename from src/common/safe_queue.h +rename to include/oeaware/safe_queue.h +index 47cf75f..f0f9f07 100644 +--- a/src/common/safe_queue.h ++++ b/include/oeaware/safe_queue.h +@@ -9,8 +9,8 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_SAFE_QUEUE_H +-#define COMMON_SAFE_QUEUE_H ++#ifndef OEAWARE_SAFE_QUEUE_H ++#define OEAWARE_SAFE_QUEUE_H + #include + #include + #include +@@ -70,4 +70,4 @@ private: + }; + } + +-#endif // !COMMON_QUEUE_H ++#endif +diff --git a/src/common/serialize.h b/include/oeaware/serialize.h +similarity index 99% +rename from src/common/serialize.h +rename to include/oeaware/serialize.h +index 4eef8b7..c3240b0 100644 +--- a/src/common/serialize.h ++++ b/include/oeaware/serialize.h +@@ -9,8 +9,8 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_SERIALIZE_H +-#define COMMON_SERIALIZE_H ++#ifndef OEAWARE_SERIALIZE_H ++#define OEAWARE_SERIALIZE_H + #include + #include + #include +diff --git a/src/common/topic.h b/include/oeaware/topic.h +similarity index 95% +rename from src/common/topic.h +rename to include/oeaware/topic.h +index ce9977c..f298ceb 100644 +--- a/src/common/topic.h ++++ b/include/oeaware/topic.h +@@ -9,10 +9,10 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_TOPIC_H +-#define COMMON_TOPIC_H +-#include "utils.h" +-#include "serialize.h" ++#ifndef OEAWARE_TOPIC_H ++#define OEAWARE_TOPIC_H ++#include ++#include + + namespace oeaware { + struct Topic { +diff --git a/src/common/utils.h b/include/oeaware/utils.h +similarity index 94% +rename from src/common/utils.h +rename to include/oeaware/utils.h +index ceadf36..98e9c5c 100644 +--- a/src/common/utils.h ++++ b/include/oeaware/utils.h +@@ -9,11 +9,11 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#ifndef COMMON_UTILS_H +-#define COMMON_UTILS_H ++#ifndef OEAWARE_UTILS_H ++#define OEAWARE_UTILS_H + #include + #include +-#include "data_list.h" ++#include + + namespace oeaware { + bool Download(const std::string &url, const std::string &path); +@@ -34,4 +34,4 @@ bool SetDataListTopic(DataList *dataList, const std::string &instanceName, const + const std::string ¶ms); + } + +-#endif // !COMMON_UTILS_H +\ No newline at end of file ++#endif +\ No newline at end of file +diff --git a/install.sh b/install.sh +index c544c78..909595b 100644 +--- a/install.sh ++++ b/install.sh +@@ -1,5 +1,5 @@ + mkdir -p /usr/include/oeaware +-cp -r build/output/include/* /usr/include/oeaware ++cp -r build/output/bin/include/* /usr/include/ + cp -r build/output/bin/* /bin/ + mkdir -p /etc/oeaware + cp config.yaml /etc/oeaware +@@ -11,4 +11,4 @@ chmod 640 build/output/plugin/lib/*.conf + cp build/output/plugin/lib/*.conf /lib64/oeAware-plugin + chmod 400 build/output/plugin/ko/*.ko + cp build/output/plugin/ko/smc_acc.ko /usr/lib/smc/smc_acc.ko +-insmod /usr/lib/smc/smc_acc.ko +\ No newline at end of file ++insmod /usr/lib/smc/smc_acc.ko +diff --git a/src/client/cmd_handler.cpp b/src/client/cmd_handler.cpp +index 289461b..01719b2 100644 +--- a/src/client/cmd_handler.cpp ++++ b/src/client/cmd_handler.cpp +@@ -11,7 +11,7 @@ + ******************************************************************************/ + #include "cmd_handler.h" + #include +-#include "utils.h" ++#include "oeaware/utils.h" + + namespace oeaware { + std::unordered_set LoadHandler::types = {"collector", "scenario", "tune"}; +diff --git a/src/client/main.cpp b/src/client/main.cpp +index 1c50f1a..26d0ae1 100644 +--- a/src/client/main.cpp ++++ b/src/client/main.cpp +@@ -14,7 +14,7 @@ + #include + #include "client.h" + #include "oe_client.h" +-#include "adapt_data.h" ++#include "oeaware/data/adapt_data.h" + + std::condition_variable g_cv; + std::mutex g_mutex; +diff --git a/src/client/tcp_socket.h b/src/client/tcp_socket.h +index 36dc89b..dbd8f17 100644 +--- a/src/client/tcp_socket.h ++++ b/src/client/tcp_socket.h +@@ -13,7 +13,7 @@ + #define CLIENT_TCP_SOCKET_H + #include + #include "message_protocol.h" +-#include "default_path.h" ++#include "oeaware/default_path.h" + + namespace oeaware { + class TcpSocket { +diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt +index 46084e5..d6bbd58 100644 +--- a/src/common/CMakeLists.txt ++++ b/src/common/CMakeLists.txt +@@ -29,21 +29,4 @@ target_link_directories(${PROJECT_NAME} PUBLIC + target_link_libraries(${PROJECT_NAME} kperf) + endif() + +-file(COPY +- "${CMAKE_CURRENT_SOURCE_DIR}/data_list.h" +-DESTINATION "${CMAKE_BINARY_DIR}/output/include") +- +-# for external plugin development +-file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/interface.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/data_register.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/default_path.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/domain_socket.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/event.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/interface.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/logger.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/message_protocol.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/safe_queue.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/serialize.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/topic.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/utils.h" +- DESTINATION "${CMAKE_BINARY_DIR}/output/include/interface") +\ No newline at end of file ++target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include) +diff --git a/src/common/data_register.cpp b/src/common/data_register.cpp +index cdf6d97..1d8350b 100644 +--- a/src/common/data_register.cpp ++++ b/src/common/data_register.cpp +@@ -1,18 +1,17 @@ + #include "data_register.h" + #include +-#include "data_list.h" +-#include "utils.h" ++#include "oeaware/utils.h" + #if defined(__arm__) || defined(__aarch64__) +-#include "pmu_counting_data.h" +-#include "pmu_sampling_data.h" +-#include "pmu_spe_data.h" +-#include "pmu_uncore_data.h" +-#include "symbol.h" ++#include "oeaware/data/pmu_counting_data.h" ++#include "oeaware/data/pmu_sampling_data.h" ++#include "oeaware/data/pmu_spe_data.h" ++#include "oeaware/data/pmu_uncore_data.h" ++#include "libkperf/symbol.h" + #endif +-#include "thread_info.h" +-#include "kernel_data.h" +-#include "command_data.h" +-#include "adapt_data.h" ++#include "oeaware/data/thread_info.h" ++#include "oeaware/data/kernel_data.h" ++#include "oeaware/data/command_data.h" ++#include "oeaware/data/adapt_data.h" + + namespace oeaware { + +diff --git a/src/common/data_register.h b/src/common/data_register.h +index b72cd97..5ec5fb4 100644 +--- a/src/common/data_register.h ++++ b/src/common/data_register.h +@@ -12,8 +12,8 @@ + #ifndef COMMON_DATA_REGISTER_H + #define COMMON_DATA_REGISTER_H + #include +-#include "serialize.h" +-#include "data_list.h" ++#include "oeaware/serialize.h" ++#include "oeaware/data_list.h" + + namespace oeaware { + using DeserializeFunc = int(*)(void**, InStream &in); +diff --git a/src/common/domain_socket.cpp b/src/common/domain_socket.cpp +index 4bcf840..57d8a55 100644 +--- a/src/common/domain_socket.cpp ++++ b/src/common/domain_socket.cpp +@@ -12,7 +12,7 @@ + #include "domain_socket.h" + #include + #include +-#include "default_path.h" ++#include "oeaware/default_path.h" + + namespace oeaware { + int DomainSocket::CreateSockAddrUn(struct sockaddr_un &un, const std::string &sunPath) +diff --git a/src/common/event.h b/src/common/event.h +index 1e5b87a..baba985 100644 +--- a/src/common/event.h ++++ b/src/common/event.h +@@ -12,7 +12,7 @@ + #ifndef PLUGIN_MGR_EVENT_EVENT_H + #define PLUGIN_MGR_EVENT_EVENT_H + #include "message_protocol.h" +-#include "safe_queue.h" ++#include "oeaware/safe_queue.h" + + namespace oeaware { + enum class EventType { +diff --git a/src/common/logger.cpp b/src/common/logger.cpp +index 53b9cb0..f28750d 100644 +--- a/src/common/logger.cpp ++++ b/src/common/logger.cpp +@@ -9,7 +9,7 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#include "logger.h" ++#include "oeaware/logger.h" + #include + + namespace oeaware { +diff --git a/src/common/message_protocol.h b/src/common/message_protocol.h +index d353ee0..ffda7bc 100644 +--- a/src/common/message_protocol.h ++++ b/src/common/message_protocol.h +@@ -15,7 +15,7 @@ + #include + #include + #include +-#include "serialize.h" ++#include "oeaware/serialize.h" + + namespace oeaware { + const int MAX_RECV_BUFF_SIZE = 16384; +diff --git a/src/common/utils.cpp b/src/common/utils.cpp +index ddd5235..8f63a70 100644 +--- a/src/common/utils.cpp ++++ b/src/common/utils.cpp +@@ -9,7 +9,7 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#include "utils.h" ++#include "oeaware/utils.h" + #include + #include + #include +diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt +index 8b643a9..4aeefcb 100644 +--- a/src/plugin/CMakeLists.txt ++++ b/src/plugin/CMakeLists.txt +@@ -1,9 +1,6 @@ + + include_directories( +- ${CMAKE_CURRENT_SOURCE_DIR}/../common +- ${CMAKE_CURRENT_SOURCE_DIR}/collect/include +- ${CMAKE_CURRENT_SOURCE_DIR}/scenario/include +- ${CMAKE_CURRENT_SOURCE_DIR}/tune/include ++ ${CMAKE_SOURCE_DIR}/include + ) + + set(PLUGIN_OUTPUT_LIBRARY_DIRECTORY ${CMAKE_BINARY_DIR}/output/plugin/lib) +@@ -25,15 +22,3 @@ add_subdirectory(scenario/thread_aware) + + add_subdirectory(tune/system) + add_subdirectory(tune/unixbench) +-if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") +-file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/pmu_counting_data.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/pmu_sampling_data.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/pmu_spe_data.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/pmu_uncore_data.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/docker_data.h" +- DESTINATION "${CMAKE_BINARY_DIR}/output/include") +-endif() +-file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/kernel_data.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/thread_info.h" +- "${CMAKE_CURRENT_SOURCE_DIR}/collect/include/command_data.h" +- DESTINATION "${CMAKE_BINARY_DIR}/output/include") +diff --git a/src/plugin/collect/docker/CMakeLists.txt b/src/plugin/collect/docker/CMakeLists.txt +index 02b1bf0..cdde00f 100644 +--- a/src/plugin/collect/docker/CMakeLists.txt ++++ b/src/plugin/collect/docker/CMakeLists.txt +@@ -1,6 +1,5 @@ + cmake_minimum_required(VERSION 3.11) + project(docker_collector) +-include_directories(../include) + add_compile_options(-O2 -fPIC -Wall -Wextra) + add_library(docker_collector SHARED + docker_adapt.cpp +diff --git a/src/plugin/collect/docker/docker_adapt.cpp b/src/plugin/collect/docker/docker_adapt.cpp +index 97fa596..eab3270 100644 +--- a/src/plugin/collect/docker/docker_adapt.cpp ++++ b/src/plugin/collect/docker/docker_adapt.cpp +@@ -40,7 +40,7 @@ static bool GetContainersInfo(int64_t &val, const std::string &container_id, con + + DockerAdapt::DockerAdapt() + { +- name = DOCKER_COLLECTOR; ++ name = OE_DOCKER_COLLECTOR; + description = "collect information of docker"; + version = "1.0.0"; + period = PERIOD; +diff --git a/src/plugin/collect/docker/docker_adapt.h b/src/plugin/collect/docker/docker_adapt.h +index 0b639b6..570a2a7 100644 +--- a/src/plugin/collect/docker/docker_adapt.h ++++ b/src/plugin/collect/docker/docker_adapt.h +@@ -15,8 +15,8 @@ + #include + #include + #include +-#include "interface.h" +-#include "docker_data.h" ++#include "oeaware/interface.h" ++#include "oeaware/data/docker_data.h" + + class DockerAdapt : public oeaware::Interface { + public: +diff --git a/src/plugin/collect/docker/docker_collector.cpp b/src/plugin/collect/docker/docker_collector.cpp +index 0c70bc6..7e9166b 100644 +--- a/src/plugin/collect/docker/docker_collector.cpp ++++ b/src/plugin/collect/docker/docker_collector.cpp +@@ -9,8 +9,6 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- +-#include "interface.h" + #include "docker_adapt.h" + + extern "C" void GetInstance(std::vector> &interface) +diff --git a/src/plugin/collect/pmu/CMakeLists.txt b/src/plugin/collect/pmu/CMakeLists.txt +index c2ea6da..bcd83eb 100644 +--- a/src/plugin/collect/pmu/CMakeLists.txt ++++ b/src/plugin/collect/pmu/CMakeLists.txt +@@ -27,8 +27,6 @@ set(pmu_src + add_library(pmu SHARED ${pmu_src}) + + include_directories(pmu PRIVATE +- ${CMAKE_CURRENT_SOURCE_DIR}/../include +- ${CMAKE_CURRENT_SOURCE_DIR}/plugin + ${LIB_KPERF_INCPATH} + ) + +diff --git a/src/plugin/collect/pmu/pmu_counting_collector.cpp b/src/plugin/collect/pmu/pmu_counting_collector.cpp +index d4de3c8..2d1a86b 100644 +--- a/src/plugin/collect/pmu/pmu_counting_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_counting_collector.cpp +@@ -9,16 +9,15 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- ++#include "pmu_counting_collector.h" + #include + #include + #include +-#include "pmu_counting_collector.h" +-#include "pmu_counting_data.h" ++#include "oeaware/data/pmu_counting_data.h" + + PmuCountingCollector::PmuCountingCollector(): oeaware::Interface() + { +- this->name = "pmu_counting_collector"; ++ this->name = OE_PMU_COUNTING_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect counting information of pmu"; + this->priority = 0; +diff --git a/src/plugin/collect/pmu/pmu_counting_collector.h b/src/plugin/collect/pmu/pmu_counting_collector.h +index 966040c..06878c3 100644 +--- a/src/plugin/collect/pmu/pmu_counting_collector.h ++++ b/src/plugin/collect/pmu/pmu_counting_collector.h +@@ -14,8 +14,7 @@ + #define PMU_COUNTING_COLLECTOR_H + #include + #include +-#include "data_list.h" +-#include "interface.h" ++#include "oeaware/interface.h" + + class PmuCountingCollector : public oeaware::Interface { + public: +diff --git a/src/plugin/collect/pmu/pmu_sampling_collector.cpp b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +index 8f8576f..4d1a4ec 100644 +--- a/src/plugin/collect/pmu/pmu_sampling_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +@@ -9,16 +9,15 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- ++#include "pmu_sampling_collector.h" + #include + #include + #include +-#include "pmu_sampling_collector.h" +-#include "pmu_sampling_data.h" ++#include "oeaware/data/pmu_sampling_data.h" + + PmuSamplingCollector::PmuSamplingCollector(): oeaware::Interface() + { +- this->name = "pmu_sampling_collector"; ++ this->name = OE_PMU_SAMPLING_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect sampling information of pmu"; + this->priority = 0; +diff --git a/src/plugin/collect/pmu/pmu_sampling_collector.h b/src/plugin/collect/pmu/pmu_sampling_collector.h +index 75b8476..5a73f34 100644 +--- a/src/plugin/collect/pmu/pmu_sampling_collector.h ++++ b/src/plugin/collect/pmu/pmu_sampling_collector.h +@@ -14,8 +14,7 @@ + #define PMU_SAMPLING_COLLECTOR_H + #include + #include +-#include "data_list.h" +-#include "interface.h" ++#include "oeaware/interface.h" + + constexpr int NET_RECEIVE_TRACE_SAMPLE_PERIOD = 10; + constexpr int CYCLES_FREQ = 100; +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.cpp b/src/plugin/collect/pmu/pmu_spe_collector.cpp +index 8d265eb..42be95b 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_spe_collector.cpp +@@ -9,15 +9,14 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- ++#include "pmu_spe_collector.h" + #include + #include +-#include "pmu_spe_collector.h" +-#include "pmu_spe_data.h" ++#include "oeaware/data/pmu_spe_data.h" + + PmuSpeCollector::PmuSpeCollector(): oeaware::Interface() + { +- this->name = "pmu_spe_collector"; ++ this->name = OE_PMU_SPE_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect spe information of pmu"; + this->priority = 0; +diff --git a/src/plugin/collect/pmu/pmu_spe_collector.h b/src/plugin/collect/pmu/pmu_spe_collector.h +index 3323e47..ec2a8cf 100644 +--- a/src/plugin/collect/pmu/pmu_spe_collector.h ++++ b/src/plugin/collect/pmu/pmu_spe_collector.h +@@ -14,8 +14,7 @@ + #define PMU_SPE_COLLECTOR_H + #include + #include +-#include "data_list.h" +-#include "interface.h" ++#include "oeaware/interface.h" + + class PmuSpeCollector : public oeaware::Interface { + public: +diff --git a/src/plugin/collect/pmu/pmu_uncore.cpp b/src/plugin/collect/pmu/pmu_uncore.cpp +index 2bca6bb..cf46121 100644 +--- a/src/plugin/collect/pmu/pmu_uncore.cpp ++++ b/src/plugin/collect/pmu/pmu_uncore.cpp +@@ -9,12 +9,12 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ ++#include "pmu_uncore.h" + #include + #include + #include + #include + #include +-#include "pmu_uncore.h" + + static int hhaNum = 0; + static struct UncoreConfig *uncoreRxOuter = nullptr; +diff --git a/src/plugin/collect/pmu/pmu_uncore_collector.cpp b/src/plugin/collect/pmu/pmu_uncore_collector.cpp +index c57f420..e9bd87c 100644 +--- a/src/plugin/collect/pmu/pmu_uncore_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_uncore_collector.cpp +@@ -9,19 +9,18 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- ++#include "pmu_uncore_collector.h" + #include + #include + #include + #include +-#include "pmu_uncore_collector.h" +-#include "pmu_uncore_data.h" ++#include "oeaware/data/pmu_uncore_data.h" + #include "pmu_uncore.h" +-#include "pcerrc.h" ++#include "libkperf/pcerrc.h" + + PmuUncoreCollector::PmuUncoreCollector(): oeaware::Interface() + { +- this->name = "pmu_uncore_collector"; ++ this->name = OE_PMU_UNCORE_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect uncore information of pmu"; + this->priority = 0; +diff --git a/src/plugin/collect/pmu/pmu_uncore_collector.h b/src/plugin/collect/pmu/pmu_uncore_collector.h +index d623adf..175026f 100644 +--- a/src/plugin/collect/pmu/pmu_uncore_collector.h ++++ b/src/plugin/collect/pmu/pmu_uncore_collector.h +@@ -14,8 +14,7 @@ + #define PMU_UNCORE_COLLECTOR_H + #include + #include +-#include "data_list.h" +-#include "interface.h" ++#include "oeaware/interface.h" + + class PmuUncoreCollector : public oeaware::Interface { + public: +diff --git a/src/plugin/collect/system/CMakeLists.txt b/src/plugin/collect/system/CMakeLists.txt +index b7d2666..3ec2358 100644 +--- a/src/plugin/collect/system/CMakeLists.txt ++++ b/src/plugin/collect/system/CMakeLists.txt +@@ -10,7 +10,8 @@ add_library(system_collector SHARED + ./command/command_collector.cpp + ./command/command_base.cpp + ) +-target_include_directories(system_collector PRIVATE src/common) ++target_include_directories(system_collector PUBLIC ${CMAKE_SOURCE_DIR}/include) ++target_include_directories(system_collector PRIVATE ${CMAKE_SOURCE_DIR}/src/common) + target_link_libraries(system_collector common) + set_target_properties(system_collector PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_OUTPUT_LIBRARY_DIRECTORY}) +\ No newline at end of file +diff --git a/src/plugin/collect/system/command/command_base.cpp b/src/plugin/collect/system/command/command_base.cpp +index e6c0a83..863d339 100644 +--- a/src/plugin/collect/system/command/command_base.cpp ++++ b/src/plugin/collect/system/command/command_base.cpp +@@ -13,7 +13,8 @@ + #include + #include + #include +- ++#include "oeaware/data/command_data.h" ++#include "oeaware/data_list.h" + int PopenProcess::Pclose() + { + if (fclose(stream) == EOF) { +diff --git a/src/plugin/collect/system/command/command_base.h b/src/plugin/collect/system/command/command_base.h +index 8653a60..295d503 100644 +--- a/src/plugin/collect/system/command/command_base.h ++++ b/src/plugin/collect/system/command/command_base.h +@@ -17,9 +17,7 @@ + #include + #include + #include +-#include "data_list.h" +-#include "topic.h" +-#include "command_data.h" ++#include "oeaware/topic.h" + + class CommandBase { + public: +diff --git a/src/plugin/collect/system/command/command_collector.cpp b/src/plugin/collect/system/command/command_collector.cpp +index 1f6ac1e..aeb9205 100644 +--- a/src/plugin/collect/system/command/command_collector.cpp ++++ b/src/plugin/collect/system/command/command_collector.cpp +@@ -14,7 +14,7 @@ + + CommandCollector::CommandCollector(): oeaware::Interface() + { +- this->name = "command_collector"; ++ this->name = OE_COMMAND_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect information of command"; + this->priority = 0; +diff --git a/src/plugin/collect/system/command/command_collector.h b/src/plugin/collect/system/command/command_collector.h +index 72553e3..ccbdea7 100644 +--- a/src/plugin/collect/system/command/command_collector.h ++++ b/src/plugin/collect/system/command/command_collector.h +@@ -14,7 +14,7 @@ + #define COMMAND_COLLECTOR_H + + #include "command_base.h" +-#include "interface.h" ++#include "oeaware/interface.h" + + class CommandCollector : public oeaware::Interface { + public: +diff --git a/src/plugin/collect/system/kernel_config.cpp b/src/plugin/collect/system/kernel_config.cpp +index 145251c..9ac295b 100644 +--- a/src/plugin/collect/system/kernel_config.cpp ++++ b/src/plugin/collect/system/kernel_config.cpp +@@ -17,13 +17,14 @@ + #include + #include + #include +-#include "utils.h" ++#include "oeaware/utils.h" + #include "command_base.h" ++#include "oeaware/data/kernel_data.h" + #include "data_register.h" + + KernelConfig::KernelConfig(): oeaware::Interface() + { +- this->name = "kernel_config"; ++ this->name = OE_KERNEL_CONFIG_COLLECTOR; + this->version = "1.0.0"; + this->description = "collect or set kernel config"; + this->priority = 0; +@@ -233,7 +234,7 @@ void KernelConfig::PublishKernelParams() + WARN(logger, "invalid params: " << name << "."); + continue; + } +- KernelDataNode *newNode = createNode(name.data(), value.data()); ++ KernelDataNode *newNode = CreateNode(name.data(), value.data()); + if (newNode == nullptr) { + WARN(logger, "KernelDataNode failed to allocate memory."); + continue; +diff --git a/src/plugin/collect/system/kernel_config.h b/src/plugin/collect/system/kernel_config.h +index 4c6eb99..ce99d67 100644 +--- a/src/plugin/collect/system/kernel_config.h ++++ b/src/plugin/collect/system/kernel_config.h +@@ -14,9 +14,8 @@ + #include + #include + #include +-#include "data_list.h" +-#include "interface.h" +-#include "kernel_data.h" ++#include "oeaware/interface.h" ++ + /* + * topic: get_kernel_config, obtain the kernel parameter information. + * params: kernel params name, including +diff --git a/src/plugin/collect/system/kernel_data.cpp b/src/plugin/collect/system/kernel_data.cpp +index c9c001e..49fb5f6 100644 +--- a/src/plugin/collect/system/kernel_data.cpp ++++ b/src/plugin/collect/system/kernel_data.cpp +@@ -11,10 +11,10 @@ + ******************************************************************************/ + #include + #include +-#include "kernel_data.h" ++#include "oeaware/data/kernel_data.h" + + +-KernelDataNode* createNode(const char *key, const char *value) ++KernelDataNode* CreateNode(const char *key, const char *value) + { + KernelDataNode *node = new KernelDataNode; + if (node == NULL) { +diff --git a/src/plugin/collect/system/system_collector.cpp b/src/plugin/collect/system/system_collector.cpp +index e321ed7..4d2c078 100644 +--- a/src/plugin/collect/system/system_collector.cpp ++++ b/src/plugin/collect/system/system_collector.cpp +@@ -9,7 +9,6 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +-#include "interface.h" + #include "thread_collector.h" + #include "kernel_config.h" + #include "command/command_collector.h" +diff --git a/src/plugin/collect/system/thread_collector.cpp b/src/plugin/collect/system/thread_collector.cpp +index 67b8432..91db97c 100644 +--- a/src/plugin/collect/system/thread_collector.cpp ++++ b/src/plugin/collect/system/thread_collector.cpp +@@ -23,7 +23,7 @@ + + ThreadCollector::ThreadCollector() + { +- name = "thread_collector"; ++ name = OE_THREAD_COLLECTOR; + description = "collect information of thread"; + version = "1.0.0"; + period = 500; +diff --git a/src/plugin/collect/system/thread_collector.h b/src/plugin/collect/system/thread_collector.h +index 2f16fa2..7ee0ed3 100644 +--- a/src/plugin/collect/system/thread_collector.h ++++ b/src/plugin/collect/system/thread_collector.h +@@ -14,8 +14,8 @@ + #include + #include + #include +-#include "interface.h" +-#include "thread_info.h" ++#include "oeaware/interface.h" ++#include "oeaware/data/thread_info.h" + + class ThreadCollector: public oeaware::Interface { + public: +diff --git a/src/plugin/scenario/analysis/CMakeLists.txt b/src/plugin/scenario/analysis/CMakeLists.txt +index 85d34dd..068f1ef 100644 +--- a/src/plugin/scenario/analysis/CMakeLists.txt ++++ b/src/plugin/scenario/analysis/CMakeLists.txt +@@ -23,9 +23,6 @@ target_include_directories(analysis_base PUBLIC + target_link_libraries(analysis_base numa boundscheck) + + add_library(analysis_oeaware SHARED ${oeaware_src}) +-target_include_directories(analysis_oeaware PUBLIC +- ${CMAKE_CURRENT_SOURCE_DIR}/../include +-) + + target_link_libraries(analysis_oeaware analysis_base) + set_target_properties(analysis_oeaware PROPERTIES +diff --git a/src/plugin/scenario/analysis/adapt/analysis_aware.cpp b/src/plugin/scenario/analysis/adapt/analysis_aware.cpp +index 3c4c65f..a04ee30 100644 +--- a/src/plugin/scenario/analysis/adapt/analysis_aware.cpp ++++ b/src/plugin/scenario/analysis/adapt/analysis_aware.cpp +@@ -12,14 +12,12 @@ + #include "analysis_aware.h" + #include + #include +-#include "adapt_data.h" +- /* oeaware manager interface */ +-#include "interface.h" ++#include "oeaware/data/adapt_data.h" + /* dependent external plugin interfaces */ +-#include "pmu_plugin.h" +-#include "pmu_counting_data.h" +-#include "pmu_sampling_data.h" +-#include "pmu_spe_data.h" ++#include "oeaware/data/pmu_plugin.h" ++#include "oeaware/data/pmu_counting_data.h" ++#include "oeaware/data/pmu_sampling_data.h" ++#include "oeaware/data/pmu_spe_data.h" + /* external plugin dependent interfaces */ + + /* internal data processing interface */ +diff --git a/src/plugin/scenario/analysis/adapt/analysis_aware.h b/src/plugin/scenario/analysis/adapt/analysis_aware.h +index 511566f..e029e31 100644 +--- a/src/plugin/scenario/analysis/adapt/analysis_aware.h ++++ b/src/plugin/scenario/analysis/adapt/analysis_aware.h +@@ -11,9 +11,9 @@ + ******************************************************************************/ + #ifndef ANALYSIS_AWARE_H + #define ANALYSIS_AWARE_H +-#include "interface.h" ++#include "oeaware/interface.h" + #include "analysis.h" +-#include "pmu.h" ++#include "libkperf/pmu.h" + + namespace oeaware { + class AnalysisAware : public Interface { +diff --git a/src/plugin/scenario/analysis/analysis/analysis.cpp b/src/plugin/scenario/analysis/analysis/analysis.cpp +index eef6209..6abe44b 100644 +--- a/src/plugin/scenario/analysis/analysis/analysis.cpp ++++ b/src/plugin/scenario/analysis/analysis/analysis.cpp +@@ -16,7 +16,7 @@ + #include + #include + #include +-#include "pmu_plugin.h" ++#include "oeaware/data/pmu_plugin.h" + + const int TUNE_PID_LOW_BOUND = 1000; + const uint64_t ACCESS_THRESHOLD = 200; +diff --git a/src/plugin/scenario/analysis/analysis/common.h b/src/plugin/scenario/analysis/analysis/common.h +index 797d53e..4e9546d 100644 +--- a/src/plugin/scenario/analysis/analysis/common.h ++++ b/src/plugin/scenario/analysis/analysis/common.h +@@ -12,7 +12,7 @@ + #ifndef COMMON_H + #define COMMON_H + +-#include "pmu.h" ++#include "libkperf/pmu.h" + #include + #include + #include "env.h" +diff --git a/src/plugin/scenario/thread_aware/CMakeLists.txt b/src/plugin/scenario/thread_aware/CMakeLists.txt +index eeb3b72..01395e5 100644 +--- a/src/plugin/scenario/thread_aware/CMakeLists.txt ++++ b/src/plugin/scenario/thread_aware/CMakeLists.txt +@@ -1,10 +1,10 @@ + cmake_minimum_required(VERSION 3.11) +-project(thread_aware) ++project(thread_scenario) + add_compile_options(-O2 -fPIC -Wall -Wextra) + add_library(thread_scenario SHARED + thread_aware.cpp + ) +- ++target_include_directories(thread_scenario PUBLIC ${CMAKE_SOURCE_DIR}/include) + set_target_properties(thread_scenario PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_OUTPUT_LIBRARY_DIRECTORY}) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/thread_scenario.conf" +diff --git a/src/plugin/scenario/thread_aware/thread_aware.h b/src/plugin/scenario/thread_aware/thread_aware.h +index a07c9c1..b4fac26 100644 +--- a/src/plugin/scenario/thread_aware/thread_aware.h ++++ b/src/plugin/scenario/thread_aware/thread_aware.h +@@ -11,8 +11,8 @@ + ******************************************************************************/ + #ifndef THREAD_AWARE_H + #define THREAD_AWARE_H +-#include "interface.h" +-#include "thread_info.h" ++#include "oeaware/interface.h" ++#include "oeaware/data/thread_info.h" + + namespace oeaware { + class ThreadAware : public Interface { +diff --git a/src/plugin/tune/docker/CMakeLists.txt b/src/plugin/tune/docker/CMakeLists.txt +index 12dd1ea..a41465a 100644 +--- a/src/plugin/tune/docker/CMakeLists.txt ++++ b/src/plugin/tune/docker/CMakeLists.txt +@@ -18,8 +18,6 @@ add_library(docker_tune SHARED + ) + + include_directories(docker_tune PUBLIC +- ${CMAKE_CURRENT_SOURCE_DIR}/../include +- ${CMAKE_CURRENT_SOURCE_DIR}/plugin + ${LIB_KPERF_INCPATH} + ) + +diff --git a/src/plugin/tune/docker/cpu_burst.cpp b/src/plugin/tune/docker/cpu_burst.cpp +index 298228b..58b41dd 100644 +--- a/src/plugin/tune/docker/cpu_burst.cpp ++++ b/src/plugin/tune/docker/cpu_burst.cpp +@@ -13,7 +13,7 @@ + #include + #include + #include +-#include "pmu_counting_data.h" ++#include "oeaware/data/pmu_counting_data.h" + + constexpr double NINETY_PERCENT = 0.9; + constexpr int MILLISECONDS_IN_SECOND = 1000; +@@ -74,7 +74,7 @@ void CpuBurst::Update(const DataList &dataList) + auto topic_name = dataList.topic.topicName; + if (instance_name == std::string("pmu_counting_collector") && topic_name == std::string("cycles")) { + UpdatePmu(dataList); +- } else if (instance_name == std::string(DOCKER_COLLECTOR) && topic_name == std::string(DOCKER_COLLECTOR)) { ++ } else if (instance_name == std::string(OE_DOCKER_COLLECTOR) && topic_name == std::string(OE_DOCKER_COLLECTOR)) { + UpdateDocker(dataList); + } + } +diff --git a/src/plugin/tune/docker/cpu_burst.h b/src/plugin/tune/docker/cpu_burst.h +index 82e5fc8..b485747 100644 +--- a/src/plugin/tune/docker/cpu_burst.h ++++ b/src/plugin/tune/docker/cpu_burst.h +@@ -16,8 +16,8 @@ + #include + #include + #include +-#include "interface.h" +-#include "docker_data.h" ++#include "oeaware/data_list.h" ++#include "oeaware/data/docker_data.h" + + + struct ContainerTune { +diff --git a/src/plugin/tune/docker/cpu_burst_adapt.cpp b/src/plugin/tune/docker/cpu_burst_adapt.cpp +index 63d2dcb..3fa6254 100644 +--- a/src/plugin/tune/docker/cpu_burst_adapt.cpp ++++ b/src/plugin/tune/docker/cpu_burst_adapt.cpp +@@ -22,7 +22,7 @@ constexpr int PRIORITY = 2; + + CpuBurstAdapt::CpuBurstAdapt() + { +- name = "docker_cpu_burst"; ++ name = OE_DOCKER_CPU_BURST_TUNE; + description = ""; + version = "1.0.0"; + period = PERIOD; +@@ -59,8 +59,8 @@ oeaware::Result CpuBurstAdapt::Enable(const std::string ¶m) + topic.instanceName = "pmu_counting_collector"; + topic.topicName = "cycles"; + oeaware::Result ret_pmu = Subscribe(topic); +- topic.instanceName = DOCKER_COLLECTOR; +- topic.topicName = DOCKER_COLLECTOR; ++ 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!"); +diff --git a/src/plugin/tune/docker/cpu_burst_adapt.h b/src/plugin/tune/docker/cpu_burst_adapt.h +index 5174d10..4c583b0 100644 +--- a/src/plugin/tune/docker/cpu_burst_adapt.h ++++ b/src/plugin/tune/docker/cpu_burst_adapt.h +@@ -12,7 +12,7 @@ + + #ifndef CPU_BURST_ADAPT_H + #define CPU_BURST_ADAPT_H +-#include "interface.h" ++#include "oeaware/interface.h" + + class CpuBurstAdapt : public oeaware::Interface { + public: +diff --git a/src/plugin/tune/docker/docker_adapt.cpp b/src/plugin/tune/docker/docker_adapt.cpp +index 2f8c2b0..2691305 100644 +--- a/src/plugin/tune/docker/docker_adapt.cpp ++++ b/src/plugin/tune/docker/docker_adapt.cpp +@@ -9,8 +9,6 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- +-#include "interface.h" + #include "cpu_burst_adapt.h" + using namespace oeaware; + +diff --git a/src/plugin/tune/system/cpu/stealtask_tune/CMakeLists.txt b/src/plugin/tune/system/cpu/stealtask_tune/CMakeLists.txt +index 1529b70..c311a01 100644 +--- a/src/plugin/tune/system/cpu/stealtask_tune/CMakeLists.txt ++++ b/src/plugin/tune/system/cpu/stealtask_tune/CMakeLists.txt +@@ -8,8 +8,6 @@ else() + endif() + add_compile_options(-fPIC -Wall -Wextra) + +-include_directories(../include) +- + add_library(stealtask_tune STATIC + stealtask_tune.cpp + ) +diff --git a/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.cpp b/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.cpp +index ceaec77..2c6e854 100644 +--- a/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.cpp ++++ b/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.cpp +@@ -11,14 +11,13 @@ + ******************************************************************************/ + + #include "stealtask_tune.h" +-#include "interface.h" + #include + + using namespace oeaware; + + StealTask::StealTask() + { +- name = "stealtask_tune"; ++ name = OE_STEALTASK_TUNE; + description = ""; + version = "1.0.0"; + period = -1; +diff --git a/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.h b/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.h +index 622d747..800c9d9 100644 +--- a/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.h ++++ b/src/plugin/tune/system/cpu/stealtask_tune/stealtask_tune.h +@@ -12,7 +12,7 @@ + #ifndef STEALTASK_TUNE_H + #define STEALTASK_TUNE_H + +-#include "interface.h" ++#include "oeaware/interface.h" + + namespace oeaware { + class StealTask : public Interface{ +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 7cd7c36..e1c7f6f 100644 +--- a/src/plugin/tune/system/network/smc_tune/smc_tune.cpp ++++ b/src/plugin/tune/system/network/smc_tune/smc_tune.cpp +@@ -9,16 +9,16 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ ++#include "smc_tune.h" + #include + #include "smc_ueid.h" +-#include "smc_tune.h" + + #define SMC_OP SmcOperator::getInstance() + using namespace oeaware; + int log_level = 0; + SmcTune::SmcTune() + { +- name = "smc_tune"; ++ name = OE_SMC_TUNE; + description = "collect information of key thread"; + version = "1.0.0"; + period = -1; +diff --git a/src/plugin/tune/system/network/smc_tune/smc_tune.h b/src/plugin/tune/system/network/smc_tune/smc_tune.h +index a7754b4..b779201 100644 +--- a/src/plugin/tune/system/network/smc_tune/smc_tune.h ++++ b/src/plugin/tune/system/network/smc_tune/smc_tune.h +@@ -12,7 +12,7 @@ + + #ifndef OEAWARE_MANAGER_SMC_TUNE_H + #define OEAWARE_MANAGER_SMC_TUNE_H +-#include "interface.h" ++#include "oeaware/interface.h" + + namespace oeaware { + class SmcTune : public Interface { +diff --git a/src/plugin/tune/system/power/seep_tune/CMakeLists.txt b/src/plugin/tune/system/power/seep_tune/CMakeLists.txt +index 6aa451f..92fb91b 100644 +--- a/src/plugin/tune/system/power/seep_tune/CMakeLists.txt ++++ b/src/plugin/tune/system/power/seep_tune/CMakeLists.txt +@@ -8,7 +8,6 @@ else() + endif() + add_compile_options(-fPIC -Wall -Wextra) + +-include_directories(../include) + add_library(seep_tune STATIC + seep_tune.cpp + ) +diff --git a/src/plugin/tune/system/power/seep_tune/seep_tune.cpp b/src/plugin/tune/system/power/seep_tune/seep_tune.cpp +index 71dc275..dbd7d20 100644 +--- a/src/plugin/tune/system/power/seep_tune/seep_tune.cpp ++++ b/src/plugin/tune/system/power/seep_tune/seep_tune.cpp +@@ -11,7 +11,6 @@ + ******************************************************************************/ + + #include "seep_tune.h" +-#include "interface.h" + #include + #include + #include +@@ -21,7 +20,7 @@ using namespace oeaware; + + Seep::Seep() + { +- name = "seep_tune"; ++ name = OE_SEEP_TUNE; + description = ""; + version = "1.0.0"; + period = -1; +diff --git a/src/plugin/tune/system/power/seep_tune/seep_tune.h b/src/plugin/tune/system/power/seep_tune/seep_tune.h +index 07f23d7..645b71d 100644 +--- a/src/plugin/tune/system/power/seep_tune/seep_tune.h ++++ b/src/plugin/tune/system/power/seep_tune/seep_tune.h +@@ -12,7 +12,7 @@ + #ifndef SEEP_TUNE_H + #define SEEP_TUNE_H + +-#include "interface.h" ++#include "oeaware/interface.h" + + namespace oeaware + { +diff --git a/src/plugin/tune/system/system_tune.cpp b/src/plugin/tune/system/system_tune.cpp +index 401205c..c0608be 100644 +--- a/src/plugin/tune/system/system_tune.cpp ++++ b/src/plugin/tune/system/system_tune.cpp +@@ -10,7 +10,7 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + +-#include "interface.h" ++#include "oeaware/interface.h" + #include "cpu/stealtask_tune/stealtask_tune.h" + #include "network/smc_tune/smc_tune.h" + #include "xcall/xcall_tune.h" +diff --git a/src/plugin/tune/system/xcall/xcall_tune.cpp b/src/plugin/tune/system/xcall/xcall_tune.cpp +index 629022d..9dee9a7 100644 +--- a/src/plugin/tune/system/xcall/xcall_tune.cpp ++++ b/src/plugin/tune/system/xcall/xcall_tune.cpp +@@ -12,11 +12,11 @@ + #include "xcall_tune.h" + #include + #include +-#include "data_list.h" ++#include "oeaware/data/thread_info.h" + + XcallTune::XcallTune() + { +- name = "xcall_tune"; ++ name = OE_XCALL_TUNE; + description = "collect information of key thread"; + version = "1.0.0"; + period = defaultPeriod; +diff --git a/src/plugin/tune/system/xcall/xcall_tune.h b/src/plugin/tune/system/xcall/xcall_tune.h +index 654cc6e..7e91a40 100644 +--- a/src/plugin/tune/system/xcall/xcall_tune.h ++++ b/src/plugin/tune/system/xcall/xcall_tune.h +@@ -11,11 +11,9 @@ + ******************************************************************************/ + #ifndef XCALL_TUNE_H + #define XCALL_TUNE_H +-#include "interface.h" + #include + #include +-#include "data_list.h" +-#include "thread_info.h" ++#include "oeaware/interface.h" + + class XcallTune : public oeaware::Interface { + public: +diff --git a/src/plugin/tune/unixbench/ub_tune.cpp b/src/plugin/tune/unixbench/ub_tune.cpp +index 3d092c0..9f7673c 100644 +--- a/src/plugin/tune/unixbench/ub_tune.cpp ++++ b/src/plugin/tune/unixbench/ub_tune.cpp +@@ -9,12 +9,11 @@ + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + ******************************************************************************/ +- ++#include "ub_tune.h" + #include + #include +-#include "interface.h" +-#include "thread_info.h" +-#include "ub_tune.h" ++#include "oeaware/interface.h" ++#include "oeaware/data/thread_info.h" + + using namespace oeaware; + +@@ -24,7 +23,7 @@ extern "C" void GetInstance(std::vector> &in + } + + UnixBenchTune::UnixBenchTune() { +- name = "unixbench_tune"; ++ name = OE_UNIXBENCH_TUNE; + description = ""; + version = "1.0.0"; + period = 500; +diff --git a/src/plugin/tune/unixbench/ub_tune.h b/src/plugin/tune/unixbench/ub_tune.h +index 779fedb..99ec723 100644 +--- a/src/plugin/tune/unixbench/ub_tune.h ++++ b/src/plugin/tune/unixbench/ub_tune.h +@@ -15,7 +15,7 @@ + #include + #include + #include +-#include "interface.h" ++#include "oeaware/interface.h" + #define MAX_CPU 4096 + #define MAX_NODE 8 + #define DEFAULT_BIND_NODE 0 +diff --git a/src/plugin_mgr/config.cpp b/src/plugin_mgr/config.cpp +index aee3243..0ac1fb0 100644 +--- a/src/plugin_mgr/config.cpp ++++ b/src/plugin_mgr/config.cpp +@@ -12,7 +12,7 @@ + #include "config.h" + #include + #include +-#include "default_path.h" ++#include "oeaware/default_path.h" + + namespace oeaware { + bool CheckPluginList(YAML::Node pluginListItem) +diff --git a/src/plugin_mgr/event/event_handler.h b/src/plugin_mgr/event/event_handler.h +index db05706..fa636fd 100644 +--- a/src/plugin_mgr/event/event_handler.h ++++ b/src/plugin_mgr/event/event_handler.h +@@ -13,7 +13,7 @@ + #define PLUGIN_MGR_EVENT_EVENT_HANDLER_H + #include "event.h" + #include "memory_store.h" +-#include "logger.h" ++#include "oeaware/logger.h" + #include "error_code.h" + + namespace oeaware { +diff --git a/src/plugin_mgr/event/list_handler.cpp b/src/plugin_mgr/event/list_handler.cpp +index 13e4532..0184753 100644 +--- a/src/plugin_mgr/event/list_handler.cpp ++++ b/src/plugin_mgr/event/list_handler.cpp +@@ -12,8 +12,8 @@ + #include "list_handler.h" + #include + #include +-#include "utils.h" +-#include "default_path.h" ++#include "oeaware/utils.h" ++#include "oeaware/default_path.h" + + namespace oeaware { + std::string ListHandler::GetPluginInDir(const std::string &path) +diff --git a/src/plugin_mgr/event/load_handler.cpp b/src/plugin_mgr/event/load_handler.cpp +index dc862e5..09b7b31 100644 +--- a/src/plugin_mgr/event/load_handler.cpp ++++ b/src/plugin_mgr/event/load_handler.cpp +@@ -11,8 +11,7 @@ + ******************************************************************************/ + #include "load_handler.h" + #include +-#include "utils.h" +-#include "default_path.h" ++#include "oeaware/utils.h" + + namespace oeaware { + ErrorCode LoadHandler::LoadPlugin(const std::string &name) +diff --git a/src/plugin_mgr/instance_run_handler.h b/src/plugin_mgr/instance_run_handler.h +index 285b350..4020dea 100644 +--- a/src/plugin_mgr/instance_run_handler.h ++++ b/src/plugin_mgr/instance_run_handler.h +@@ -14,11 +14,10 @@ + #include + #include + #include "event.h" +-#include "safe_queue.h" +-#include "logger.h" ++#include "oeaware/logger.h" + #include "memory_store.h" + #include "data_register.h" +-#include "instance_run_message.h" ++#include "oeaware/instance_run_message.h" + + namespace oeaware { + class ScheduleInstance { +diff --git a/src/plugin_mgr/main.cpp b/src/plugin_mgr/main.cpp +index 8e410f7..197fe9d 100644 +--- a/src/plugin_mgr/main.cpp ++++ b/src/plugin_mgr/main.cpp +@@ -11,8 +11,8 @@ + ******************************************************************************/ + #include + #include "plugin_manager.h" +-#include "data_register.h" +-#include "utils.h" ++#include "message_manager.h" ++#include "oeaware/utils.h" + + int main(int argc, char **argv) + { +diff --git a/src/plugin_mgr/memory_store.h b/src/plugin_mgr/memory_store.h +index bf5e59c..3c81cb3 100644 +--- a/src/plugin_mgr/memory_store.h ++++ b/src/plugin_mgr/memory_store.h +@@ -12,7 +12,6 @@ + #ifndef PLUGIN_MGR_MEMORY_STORE_H + #define PLUGIN_MGR_MEMORY_STORE_H + #include +-#include "logger.h" + #include "plugin.h" + + namespace oeaware { +diff --git a/src/plugin_mgr/message_manager.cpp b/src/plugin_mgr/message_manager.cpp +index bfa5b0c..e68f801 100644 +--- a/src/plugin_mgr/message_manager.cpp ++++ b/src/plugin_mgr/message_manager.cpp +@@ -13,8 +13,8 @@ + #include + #include + #include +-#include "default_path.h" +-#include "utils.h" ++#include "oeaware/default_path.h" ++#include "oeaware/utils.h" + + namespace oeaware { + static const int CMD_CONN = 1; +diff --git a/src/plugin_mgr/message_manager.h b/src/plugin_mgr/message_manager.h +index 3c67096..ab692e8 100644 +--- a/src/plugin_mgr/message_manager.h ++++ b/src/plugin_mgr/message_manager.h +@@ -16,8 +16,7 @@ + #include + #include + #include +-#include "message_protocol.h" +-#include "logger.h" ++#include "oeaware/logger.h" + #include "config.h" + #include "event.h" + #include "domain_socket.h" +diff --git a/src/plugin_mgr/plugin.h b/src/plugin_mgr/plugin.h +index bf63852..b3ea5af 100644 +--- a/src/plugin_mgr/plugin.h ++++ b/src/plugin_mgr/plugin.h +@@ -15,7 +15,7 @@ + #include + #include + #include +-#include "interface.h" ++#include "oeaware/interface.h" + + namespace oeaware { + struct Instance { +diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp +index 6d87edd..99c5adf 100644 +--- a/src/plugin_mgr/plugin_manager.cpp ++++ b/src/plugin_mgr/plugin_manager.cpp +@@ -12,7 +12,7 @@ + #include "plugin_manager.h" + #include + #include +-#include "utils.h" ++#include "oeaware/utils.h" + #include "event/load_handler.h" + #include "event/remove_handler.h" + #include "event/query_handler.h" +diff --git a/src/plugin_mgr/plugin_manager.h b/src/plugin_mgr/plugin_manager.h +index c742280..9e65ac0 100644 +--- a/src/plugin_mgr/plugin_manager.h ++++ b/src/plugin_mgr/plugin_manager.h +@@ -12,7 +12,7 @@ + #ifndef PLUGIN_MGR_PLUGIN_MANAGER_H + #define PLUGIN_MGR_PLUGIN_MANAGER_H + #include "instance_run_handler.h" +-#include "message_manager.h" ++#include "config.h" + #include "event/event_handler.h" + + namespace oeaware { +diff --git a/src/sdk/CMakeLists.txt b/src/sdk/CMakeLists.txt +index e16fd43..5ff5dea 100644 +--- a/src/sdk/CMakeLists.txt ++++ b/src/sdk/CMakeLists.txt +@@ -4,16 +4,14 @@ project(oeaware-sdk) + aux_source_directory(. SOURCE) + SET(CMAKE_CXX_FLAGS "-rdynamic -std=c++14 -g -Wl,-z,relro,-z,now -Wall -Wextra -fPIC -O2") + +-include_directories(../common +-) +- + add_library(${PROJECT_NAME} SHARED + oe_client.cpp + ) ++target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) ++target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/common) + target_link_libraries(${PROJECT_NAME} common) +- + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/oe_client.h" +-DESTINATION "${CMAKE_BINARY_DIR}/output/include") ++DESTINATION "${CMAKE_BINARY_DIR}/output/include/oeaware") + + set(SDK_OUTPUT_LIBRARY_DIRECTORY ${CMAKE_BINARY_DIR}/output/sdk) + file(MAKE_DIRECTORY ${SDK_OUTPUT_LIBRARY_DIRECTORY}) +diff --git a/src/sdk/oe_client.cpp b/src/sdk/oe_client.cpp +index a9f82ef..68b9d4a 100644 +--- a/src/sdk/oe_client.cpp ++++ b/src/sdk/oe_client.cpp +@@ -13,10 +13,10 @@ + #include + #include + #include "domain_socket.h" +-#include "utils.h" ++#include "oeaware/utils.h" + #include "message_protocol.h" +-#include "safe_queue.h" +-#include "default_path.h" ++#include "oeaware/safe_queue.h" ++#include "oeaware/default_path.h" + #include "data_register.h" + + namespace oeaware { +diff --git a/src/sdk/oe_client.h b/src/sdk/oe_client.h +index 267462c..991feb1 100644 +--- a/src/sdk/oe_client.h ++++ b/src/sdk/oe_client.h +@@ -11,7 +11,7 @@ + ******************************************************************************/ + #ifndef SDK_OE_CLIENT_H + #define SDK_OE_CLIENT_H +-#include "data_list.h" ++#include "oeaware/data_list.h" + #ifdef __cplusplus + extern "C" { + #endif +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 11079f2..dae250b 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -6,7 +6,7 @@ SET(CMAKE_CXX_FLAGS "-rdynamic -std=c++14 -g -Wl,-z,relro,-z,now") + find_package(GTest CONFIG REQUIRED) + + include_directories(../src/common) +- ++include_directories(../include) + add_executable(serialize_test + ${SRC_DIR}/common/utils.cpp + serialize_test.cpp +diff --git a/tests/logger_test.cpp b/tests/logger_test.cpp +index 2d1f058..107bc1b 100644 +--- a/tests/logger_test.cpp ++++ b/tests/logger_test.cpp +@@ -10,7 +10,7 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + #include +-#include "logger.h" ++#include "oeaware/logger.h" + + TEST(Serialize, Logger) + { +diff --git a/tests/safe_queue_test.cpp b/tests/safe_queue_test.cpp +index a0d6aa7..2cc9ba5 100644 +--- a/tests/safe_queue_test.cpp ++++ b/tests/safe_queue_test.cpp +@@ -12,7 +12,7 @@ + #include + #include + #include +-#include "safe_queue.h" ++#include "oeaware/safe_queue.h" + + TEST(SafeQueue, TryPop) + { +diff --git a/tests/serialize_test.cpp b/tests/serialize_test.cpp +index e9f444b..13a1d7e 100644 +--- a/tests/serialize_test.cpp ++++ b/tests/serialize_test.cpp +@@ -11,7 +11,7 @@ + ******************************************************************************/ + #include + #include "data_register.h" +-#include "utils.h" ++#include "oeaware/utils.h" + + struct TestData { + int a; +diff --git a/tests/utils_test.cpp b/tests/utils_test.cpp +index 03c3bee..1130a7d 100644 +--- a/tests/utils_test.cpp ++++ b/tests/utils_test.cpp +@@ -10,7 +10,7 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + #include +-#include "utils.h" ++#include "oeaware/utils.h" + + TEST(SplitString, SplitString) + { +diff --git a/tests/xcall_tune_test.cpp b/tests/xcall_tune_test.cpp +index 0c5333a..fe628a8 100644 +--- a/tests/xcall_tune_test.cpp ++++ b/tests/xcall_tune_test.cpp +@@ -10,7 +10,6 @@ + * See the Mulan PSL v2 for more details. + ******************************************************************************/ + #include +-#include "utils.h" + + TEST(XcallTune, ReadConfig) + { +-- +2.33.0 + diff --git a/0009-cycles-sample-add-elf-resolve-to-support-d-fot.patch b/0009-cycles-sample-add-elf-resolve-to-support-d-fot.patch new file mode 100644 index 0000000..18a6c4a --- /dev/null +++ b/0009-cycles-sample-add-elf-resolve-to-support-d-fot.patch @@ -0,0 +1,24 @@ +From 5315e7712951014a238e98ab1613e41edc0e8cb9 Mon Sep 17 00:00:00 2001 +From: LHesperus <2639350497@qq.com> +Date: Wed, 4 Dec 2024 19:46:04 +0800 +Subject: [PATCH 4/4] cycles sample add elf resolve to support d-fot + +--- + src/plugin/collect/pmu/pmu_sampling_collector.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugin/collect/pmu/pmu_sampling_collector.cpp b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +index 8f8576f..59ba800 100644 +--- a/src/plugin/collect/pmu/pmu_sampling_collector.cpp ++++ b/src/plugin/collect/pmu/pmu_sampling_collector.cpp +@@ -67,6 +67,7 @@ int PmuSamplingCollector::OpenSampling(const oeaware::Topic &topic) + if (topic.topicName == "cycles") { + attr.freq = CYCLES_FREQ; + attr.useFreq = 1; ++ attr.symbolMode = RESOLVE_ELF; + } else { + attr.period = NET_RECEIVE_TRACE_SAMPLE_PERIOD; + } +-- +2.33.0 + diff --git a/oeAware-manager.spec b/oeAware-manager.spec index dbc48fe..5dd9ae2 100644 --- a/oeAware-manager.spec +++ b/oeAware-manager.spec @@ -1,15 +1,19 @@ Name: oeAware-manager Version: v2.0.0 -Release: 2 +Release: 3 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-remove-old-code.patch -Patch2: 0002-add-data-free-and-fix-unsubscribe-error.patch -Patch3: 0003-fix-failed-to-connect-to-the-sdk-and-command-executi.patch -Patch4: 0004-add-command-verification.patch -Patch5: 0005-modify-C-interface-name-add-enable-count-and-fix-bug.patch +Patch1: 0001-remove-old-code.patch +Patch2: 0002-add-data-free-and-fix-unsubscribe-error.patch +Patch3: 0003-fix-failed-to-connect-to-the-sdk-and-command-executi.patch +Patch4: 0004-add-command-verification.patch +Patch5: 0005-modify-C-interface-name-add-enable-count-and-fix-bug.patch +Patch6: 0006-add-one-time-command-collection.patch +Patch7: 0007-fix-bug-free-spe-mem-after-use-data.patch +Patch8: 0008-Adjust-the-header-file-structure.patch +Patch9: 0009-cycles-sample-add-elf-resolve-to-support-d-fot.patch BuildRequires: cmake make gcc-c++ BuildRequires: boost-devel @@ -25,7 +29,7 @@ BuildRequires: libnl3 libnl3-devel BuildRequires: numactl-devel BuildRequires: kernel-devel Requires: graphviz yaml-cpp curl log4cplus boost systemd libboundscheck -Requires: libnl3 +Requires: libnl3 acl Obsoletes: oeAware-collector < v2.0.0 Obsoletes: oeAware-scenario < v2.0.0 @@ -56,12 +60,12 @@ install -D -p -m 0644 oeaware.service %{buildroot}%{_unitdir}/oeaware.s #install plugin mkdir -p %{buildroot}%{_libdir}/oeAware-plugin/ -mkdir -p %{buildroot}%{_includedir}/oeaware/interface +mkdir -p %{buildroot}%{_includedir}/oeaware/data install -dm 0755 %{buildroot}%{_prefix}/lib/smc install -b -m740 ./build/output/plugin/lib/*.so %{buildroot}%{_libdir}/oeAware-plugin/ -install -b -m740 ./build/output/include/*.h %{buildroot}%{_includedir}/oeaware -install -b -m740 ./build/output/include/interface/*.h %{buildroot}%{_includedir}/oeaware/interface +install -b -m740 ./build/output/include/oeaware/*.h %{buildroot}%{_includedir}/oeaware +install -b -m740 ./build/output/include/oeaware/data/*.h %{buildroot}%{_includedir}/oeaware/data install -b -m740 ./build/output/sdk/liboeaware-sdk.so %{buildroot}%{_libdir} install -D -m 0640 ./build/output/plugin/lib/thread_scenario.conf %{buildroot}%{_libdir}/oeAware-plugin/ install -D -m 0640 ./build/output/plugin/lib/ub_tune.conf %{buildroot}%{_libdir}/oeAware-plugin/ @@ -97,10 +101,15 @@ fi %attr(0440, root, root) %{_libdir}/liboeaware-sdk.so %files devel -%attr(0440, root, root) %{_includedir}/oeaware/*.h -%attr(0440, root, root) %{_includedir}/oeaware/interface/*.h +%attr(0644, root, root) %{_includedir}/oeaware/*.h +%attr(0644, root, root) %{_includedir}/oeaware/data/*.h %changelog +* Fri Dec 6 2024 fly_1997 -v2.0.0-3 +- adjust the header file structure +- fix cycles sample, spe memory free +- add one time command collection + * Mon Dec 2 2024 fly_1997 -v2.0.0-2 - fix data free, plugin display, command plugin bugs - add oeaware group