diff --git a/0001-change-the-folder-permission-to-755-add-oeaware-grou.patch b/0001-change-the-folder-permission-to-755-add-oeaware-grou.patch new file mode 100644 index 0000000000000000000000000000000000000000..d7b1f30e67f7708e6cdfd6b7a6734bd1249e723b --- /dev/null +++ b/0001-change-the-folder-permission-to-755-add-oeaware-grou.patch @@ -0,0 +1,39 @@ +From 2b39cac80efe7327b6d68fe01934919bc41249b8 Mon Sep 17 00:00:00 2001 +From: fly_1997 +Date: Tue, 10 Dec 2024 21:46:27 +0800 +Subject: [PATCH] change the folder permission to 755, add oeaware group + permission to liboeaware-sdk.so + +--- + rpm/oeAware.spec | 1 + + src/common/utils.cpp | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/rpm/oeAware.spec b/rpm/oeAware.spec +index 5fbaf1f..4c01d0a 100644 +--- a/rpm/oeAware.spec ++++ b/rpm/oeAware.spec +@@ -60,6 +60,7 @@ install -D -m 0640 ./build/output/plugin/lib/xcall.yaml %{buildroot}%{ + %post + if ! grep -q "oeaware:" /etc/group; then + groupadd oeaware ++ setfacl -m g:oeaware:r /usr/lib64/liboeaware-sdk.so + fi + systemctl start oeaware.service + chcon -t modules_object_t %{_prefix}/lib/smc/smc_acc.ko >/dev/null 2>&1 +diff --git a/src/common/utils.cpp b/src/common/utils.cpp +index 8f63a70..b118235 100644 +--- a/src/common/utils.cpp ++++ b/src/common/utils.cpp +@@ -167,7 +167,7 @@ bool CreateDir(const std::string &path) + if (stat(subPath.c_str(), &buffer) == 0) { + continue; + } +- if (mkdir(subPath.c_str(), S_IRWXU | S_IRWXG) != 0) { ++ if (mkdir(subPath.c_str(), S_IRWXU | S_IXGRP | S_IRGRP | S_IROTH | S_IXOTH) != 0) { + return false; + } + } while (pos != std::string::npos); +-- +2.45.2.windows.1 + diff --git a/0001-remove-old-code.patch b/0001-remove-old-code.patch deleted file mode 100644 index 09e933e13330c9a6fd681f46b2685e061429f7e8..0000000000000000000000000000000000000000 --- a/0001-remove-old-code.patch +++ /dev/null @@ -1,2098 +0,0 @@ -From a7893161786a6195cbb97d82969a49e02e56adac Mon Sep 17 00:00:00 2001 -From: fly_1997 -Date: Wed, 20 Nov 2024 09:39:14 +0800 -Subject: [PATCH 1/5] remove old code - ---- - src/plugin/collect/pmu/plugin/plugin.c | 136 ------------ - src/plugin/collect/pmu/plugin/plugin_comm.c | 84 -------- - src/plugin/collect/pmu/plugin/plugin_comm.h | 39 ---- - .../collect/pmu/plugin/plugin_counting.c | 174 --------------- - .../collect/pmu/plugin/plugin_counting.h | 35 --- - .../plugin/plugin_napi_gro_receive_entry.c | 174 --------------- - .../plugin/plugin_napi_gro_receive_entry.h | 35 --- - .../collect/pmu/plugin/plugin_netif_rx.c | 173 --------------- - .../collect/pmu/plugin/plugin_netif_rx.h | 35 --- - .../collect/pmu/plugin/plugin_sampling.c | 176 ---------------- - .../collect/pmu/plugin/plugin_sampling.h | 35 --- - .../plugin/plugin_skb_copy_datagram_iovec.c | 174 --------------- - .../plugin/plugin_skb_copy_datagram_iovec.h | 35 --- - src/plugin/collect/pmu/plugin/plugin_spe.c | 174 --------------- - src/plugin/collect/pmu/plugin/plugin_spe.h | 35 --- - src/plugin/collect/pmu/plugin/plugin_uncore.c | 199 ------------------ - src/plugin/collect/pmu/plugin/plugin_uncore.h | 35 --- - src/plugin/collect/pmu/plugin/pmu_uncore.c | 142 ------------- - src/plugin/collect/pmu/plugin/pmu_uncore.h | 45 ---- - 19 files changed, 1935 deletions(-) - delete mode 100644 src/plugin/collect/pmu/plugin/plugin.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_comm.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_comm.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_counting.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_counting.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_netif_rx.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_netif_rx.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_sampling.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_sampling.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_spe.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_spe.h - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_uncore.c - delete mode 100644 src/plugin/collect/pmu/plugin/plugin_uncore.h - delete mode 100644 src/plugin/collect/pmu/plugin/pmu_uncore.c - delete mode 100644 src/plugin/collect/pmu/plugin/pmu_uncore.h - -diff --git a/src/plugin/collect/pmu/plugin/plugin.c b/src/plugin/collect/pmu/plugin/plugin.c -deleted file mode 100644 -index 0fc7dda..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin.c -+++ /dev/null -@@ -1,136 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include "interface.h" --#include "plugin_sampling.h" --#include "plugin_counting.h" --#include "plugin_uncore.h" --#include "plugin_spe.h" --#include "plugin_netif_rx.h" --#include "plugin_napi_gro_receive_entry.h" --#include "plugin_skb_copy_datagram_iovec.h" -- --#define INS_COLLECTOR_MAX 10 -- --static struct Interface ins_collector[INS_COLLECTOR_MAX] = {0}; -- --struct Interface sampling_collector = { -- .get_version = sampling_get_version, -- .get_description = sampling_get_description, -- .get_priority = sampling_get_priority, -- .get_type = sampling_get_type, -- .get_dep = sampling_get_dep, -- .get_name = sampling_get_name, -- .get_period = sampling_get_period, -- .enable = sampling_enable, -- .disable = sampling_disable, -- .get_ring_buf = sampling_get_ring_buf, -- .run = sampling_run, --}; -- --struct Interface counting_collector = { -- .get_version = counting_get_version, -- .get_description = counting_get_description, -- .get_priority = counting_get_priority, -- .get_type = counting_get_type, -- .get_dep = counting_get_dep, -- .get_name = counting_get_name, -- .get_period = counting_get_period, -- .enable = counting_enable, -- .disable = counting_disable, -- .get_ring_buf = counting_get_ring_buf, -- .run = counting_run, --}; -- --struct Interface uncore_collector = { -- .get_version = uncore_get_version, -- .get_description = uncore_get_description, -- .get_priority = uncore_get_priority, -- .get_type = uncore_get_type, -- .get_dep = uncore_get_dep, -- .get_name = uncore_get_name, -- .get_period = uncore_get_period, -- .enable = uncore_enable, -- .disable = uncore_disable, -- .get_ring_buf = uncore_get_ring_buf, -- .run = uncore_run, --}; -- --struct Interface spe_collector = { -- .get_version = spe_get_version, -- .get_description = spe_get_description, -- .get_priority = spe_get_priority, -- .get_type = spe_get_type, -- .get_dep = spe_get_dep, -- .get_name = spe_get_name, -- .get_period = spe_get_period, -- .enable = spe_enable, -- .disable = spe_disable, -- .get_ring_buf = spe_get_ring_buf, -- .run = spe_run, --}; -- --struct Interface netif_rx_collector = { -- .get_version = netif_rx_get_version, -- .get_description = netif_rx_get_description, -- .get_priority = netif_rx_get_priority, -- .get_type = netif_rx_get_type, -- .get_dep = netif_rx_get_dep, -- .get_name = netif_rx_get_name, -- .get_period = netif_rx_get_period, -- .enable = netif_rx_enable, -- .disable = netif_rx_disable, -- .get_ring_buf = netif_rx_get_ring_buf, -- .run = netif_rx_run, --}; -- --struct Interface g_napiGroRecEntryCollector = { -- .get_version = NapiGroRecEntryGetVer, -- .get_description = NapiGroRecEntryGetDes, -- .get_priority = NapiGroRecEntryGetPriority, -- .get_type = NapiGroRecEntryGetType, -- .get_dep = NapiGroRecEntryGetDep, -- .get_name = NapiGroRecEntryGetName, -- .get_period = NapiGroRecEntryGetPeriod, -- .enable = NapiGroRecEntryEnable, -- .disable = NapiGroRecEntryDisable, -- .get_ring_buf = NapiGroRecEntryGetBuf, -- .run = NapiGroRecEntryRun, --}; -- --struct Interface g_skbCopyDatagramIovecCollector = { -- .get_version = SkbCopyDatagramIovecGetVer, -- .get_description = SkbCopyDatagramIovecGetDes, -- .get_priority = SkbCopyDatagramIovecGetPriority, -- .get_type = SkbCopyDatagramIovecGetType, -- .get_dep = SkbCopyDatagramIovecGetDep, -- .get_name = SkbCopyDatagramIovecGetName, -- .get_period = SkbCopyDatagramIovecGetPeriod, -- .enable = SkbCopyDatagramIovecEnable, -- .disable = SkbCopyDatagramIovecDisable, -- .get_ring_buf = SkbCopyDatagramIovecGetBuf, -- .run = SkbCopyDatagramIovecRun, --}; --int get_instance(struct Interface **interface) --{ -- int ins_count = 0; -- -- ins_collector[ins_count++] = sampling_collector; -- ins_collector[ins_count++] = counting_collector; -- ins_collector[ins_count++] = uncore_collector; -- ins_collector[ins_count++] = spe_collector; -- ins_collector[ins_count++] = netif_rx_collector; -- ins_collector[ins_count++] = g_napiGroRecEntryCollector; -- ins_collector[ins_count++] = g_skbCopyDatagramIovecCollector; -- *interface = &ins_collector[0]; -- -- return ins_count; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_comm.c b/src/plugin/collect/pmu/plugin/plugin_comm.c -deleted file mode 100644 -index 401ef1f..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_comm.c -+++ /dev/null -@@ -1,84 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "interface.h" -- --struct DataRingBuf *init_buf(int buf_len, const char *instance_name) --{ -- struct DataRingBuf *data_ringbuf; -- -- data_ringbuf = (struct DataRingBuf *)malloc(sizeof(struct DataRingBuf)); -- if (!data_ringbuf) { -- printf("malloc data_ringbuf failed\n"); -- return NULL; -- } -- -- (void)memset_s(data_ringbuf, sizeof(struct DataRingBuf), 0, sizeof(struct DataRingBuf)); -- -- data_ringbuf->instance_name = instance_name; -- data_ringbuf->index = -1; -- -- data_ringbuf->buf = (struct DataBuf *)malloc(sizeof(struct DataBuf) * buf_len); -- if (!data_ringbuf->buf) { -- printf("malloc data_ringbuf buf failed\n"); -- free(data_ringbuf); -- data_ringbuf = NULL; -- return NULL; -- } -- -- (void)memset_s(data_ringbuf->buf, sizeof(struct DataBuf) * buf_len, 0, sizeof(struct DataBuf) * buf_len); -- data_ringbuf->buf_len = buf_len; -- -- return data_ringbuf; --} -- --void free_buf(struct DataRingBuf *data_ringbuf) --{ -- if (!data_ringbuf) { -- return; -- } -- -- if (!data_ringbuf->buf) { -- goto out; -- } -- -- free(data_ringbuf->buf); -- data_ringbuf->buf = NULL; -- --out: -- free(data_ringbuf); -- data_ringbuf = NULL; --} -- --void fill_buf(struct DataRingBuf *data_ringbuf, struct PmuData *pmu_data, int len) --{ -- struct DataBuf *buf; -- int index; -- -- index = (data_ringbuf->index + 1) % data_ringbuf->buf_len; -- data_ringbuf->index = index; -- data_ringbuf->count++; -- buf = &data_ringbuf->buf[index]; -- -- if (buf->data != NULL) { -- PmuDataFree(buf->data); -- buf->data = NULL; -- buf->len = 0; -- } -- -- buf->len = len; -- buf->data = (void *)pmu_data; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_comm.h b/src/plugin/collect/pmu/plugin/plugin_comm.h -deleted file mode 100644 -index 1bdc239..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_comm.h -+++ /dev/null -@@ -1,39 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_COMM_H__ --#define __PLUGIN_COMM_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --#define CYCLES_COUNTING_BUF_SIZE 10 --#define CYCLES_SAMPLING_BUF_SIZE 10 --#define UNCORE_BUF_SIZE 10 --#define SPE_BUF_SIZE 10 --#define NETIF_RX_BUF_SIZE 10 --#define NAPI_GRO_REC_ENTRY_BUF_SIZE 10 --#define SKB_COPY_DATAGRAM_IOVEC_BUF_SIZE 10 --#define NET_RECEIVE_TRACE_SAMPLE_PERIOD 10 -- --struct DataRingBuf; --struct PmuData; -- --struct DataRingBuf *init_buf(int buf_len, const char *instance_name); --void free_buf(struct DataRingBuf *data_ringbuf); --void fill_buf(struct DataRingBuf *data_ringbuf, struct PmuData *pmu_data, int len); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_counting.c b/src/plugin/collect/pmu/plugin/plugin_counting.c -deleted file mode 100644 -index 39573fa..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_counting.c -+++ /dev/null -@@ -1,174 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_counting.h" -- --static bool counting_is_open = false; --static int counting_pd = -1; --static struct DataRingBuf *counting_buf = NULL; --struct PmuData *counting_data = NULL; -- --static int counting_init() --{ -- counting_buf = init_buf(CYCLES_COUNTING_BUF_SIZE, PMU_CYCLES_COUNTING); -- if (!counting_buf) { -- return -1; -- } -- -- return 0; --} -- --static void counting_fini() --{ -- if (!counting_buf) { -- return; -- } -- -- free_buf(counting_buf); -- counting_buf = NULL; --} -- --static int counting_open() --{ -- struct PmuAttr attr; -- char *evtList[1]; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- evtList[0] = "cycles"; -- -- attr.evtList = evtList; -- attr.numEvt = 1; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- -- pd = PmuOpen(COUNTING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- counting_is_open = true; -- return pd; --} -- --static void counting_close() --{ -- PmuClose(counting_pd); -- counting_pd = -1; -- counting_is_open = false; --} -- --bool counting_enable() --{ -- if (!counting_buf) { -- int ret = counting_init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!counting_is_open) { -- counting_pd = counting_open(); -- if (counting_pd == -1) { -- counting_fini(); -- goto err; -- } -- } -- -- return PmuEnable(counting_pd) == 0; -- --err: -- return false; --} -- --void counting_disable() --{ -- PmuDisable(counting_pd); -- counting_close(); -- counting_fini(); --} -- --const struct DataRingBuf *counting_get_ring_buf() --{ -- return (const struct DataRingBuf *)counting_buf; --} -- --static void counting_reflash_ring_buf() --{ -- struct DataRingBuf *data_ringbuf; -- int len; -- -- data_ringbuf = (struct DataRingBuf *)counting_buf; -- if (!data_ringbuf) { -- printf("counting_buf has no malloc\n"); -- return; -- } -- -- PmuDisable(counting_pd); -- len = PmuRead(counting_pd, &counting_data); -- PmuEnable(counting_pd); -- -- fill_buf(data_ringbuf, counting_data, len); --} -- --void counting_run(const struct Param *param) --{ -- (void)param; -- counting_reflash_ring_buf(); --} -- --const char *counting_get_version() --{ -- return NULL; --} -- --const char *counting_get_name() --{ -- return PMU_CYCLES_COUNTING; --} -- --const char *counting_get_description() --{ -- return NULL; --} -- --const char *counting_get_dep() --{ -- return NULL; --} -- --int counting_get_priority() --{ -- return 0; --} -- --int counting_get_type() --{ -- return -1; --} -- --int counting_get_period() --{ -- return 100; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_counting.h b/src/plugin/collect/pmu/plugin/plugin_counting.h -deleted file mode 100644 -index c414458..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_counting.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_COUNTING_H__ --#define __PLUGIN_COUNTING_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *counting_get_version(); --const char *counting_get_name(); --const char *counting_get_description(); --const char *counting_get_dep(); --int counting_get_priority(); --int counting_get_type(); --int counting_get_period(); --bool counting_enable(); --void counting_disable(); --const struct DataRingBuf *counting_get_ring_buf(); --void counting_run(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.c b/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.c -deleted file mode 100644 -index 6c7b9a3..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.c -+++ /dev/null -@@ -1,174 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_sampling.h" -- --static bool g_samplingIsOpen = false; --static int g_samplingPd = -1; --static struct DataRingBuf *g_samplingBuf = NULL; --struct PmuData *g_pmuData = NULL; -- --static int Init() --{ -- g_samplingBuf = init_buf(NAPI_GRO_REC_ENTRY_BUF_SIZE, PMU_NAPI_GRO_REC_ENTRY); -- if (!g_samplingBuf) { -- return -1; -- } -- -- return 0; --} -- --static void Finish() --{ -- if (!g_samplingBuf) { -- return; -- } -- -- free_buf(g_samplingBuf); -- g_samplingBuf = NULL; --} -- --static int Open() --{ -- struct PmuAttr attr; -- char *evtList[1]; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- evtList[0] = "net:napi_gro_receive_entry"; -- -- attr.evtList = evtList; -- attr.numEvt = 1; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- attr.period = NET_RECEIVE_TRACE_SAMPLE_PERIOD; -- -- pd = PmuOpen(SAMPLING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- g_samplingIsOpen = true; -- return pd; --} -- --static void Close() --{ -- PmuClose(g_samplingPd); -- g_samplingPd = -1; -- g_samplingIsOpen = false; --} -- --bool NapiGroRecEntryEnable() --{ -- if (!g_samplingBuf) { -- int ret = Init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!g_samplingIsOpen) { -- g_samplingPd = Open(); -- if (g_samplingPd == -1) { -- Finish(); -- goto err; -- } -- } -- -- return PmuEnable(g_samplingPd) == 0; -- --err: -- return false; --} -- --void NapiGroRecEntryDisable() --{ -- PmuDisable(g_samplingPd); -- Close(); -- Finish(); --} -- --const struct DataRingBuf *NapiGroRecEntryGetBuf() --{ -- return (const struct DataRingBuf *)g_samplingBuf; --} -- --static void NapiGroRecEntryReflashBuf() --{ -- struct DataRingBuf *dataRingBuf; -- int len; -- -- dataRingBuf = (struct DataRingBuf *)g_samplingBuf; -- if (!dataRingBuf) { -- printf("g_samplingBuf has not malloc\n"); -- return; -- } -- -- PmuDisable(g_samplingPd); -- len = PmuRead(g_samplingPd, &g_pmuData); -- PmuEnable(g_samplingPd); -- fill_buf(dataRingBuf, g_pmuData, len); --} -- --void NapiGroRecEntryRun(const struct Param *param) --{ -- (void)param; -- NapiGroRecEntryReflashBuf(); --} -- --const char *NapiGroRecEntryGetVer() --{ -- return NULL; --} -- --const char *NapiGroRecEntryGetName() --{ -- return PMU_NAPI_GRO_REC_ENTRY; --} -- --const char *NapiGroRecEntryGetDes() --{ -- return "event used to collect net queue info"; --} -- --const char *NapiGroRecEntryGetDep() --{ -- return NULL; --} -- --int NapiGroRecEntryGetPriority() --{ -- return 0; --} -- --int NapiGroRecEntryGetType() --{ -- return -1; --} -- --int NapiGroRecEntryGetPeriod() --{ -- return 100; // 100ms --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.h b/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.h -deleted file mode 100644 -index 14469d9..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_napi_gro_receive_entry.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PMU_NAPI_GRO_RECEIVE_ENTRY_H__ --#define __PMU_NAPI_GRO_RECEIVE_ENTRY_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *NapiGroRecEntryGetVer(); --const char *NapiGroRecEntryGetName(); --const char *NapiGroRecEntryGetDes(); --const char *NapiGroRecEntryGetDep(); --int NapiGroRecEntryGetPriority(); --int NapiGroRecEntryGetType(); --int NapiGroRecEntryGetPeriod(); --bool NapiGroRecEntryEnable(); --void NapiGroRecEntryDisable(); --const struct DataRingBuf *NapiGroRecEntryGetBuf(); --void NapiGroRecEntryRun(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_netif_rx.c b/src/plugin/collect/pmu/plugin/plugin_netif_rx.c -deleted file mode 100644 -index 78f52d2..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_netif_rx.c -+++ /dev/null -@@ -1,173 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" -- --static bool event_is_open = false; --static int pmu_id = -1; --static struct DataRingBuf *ring_buf = NULL; --struct PmuData *pmu_data = NULL; -- --static int init() --{ -- ring_buf = init_buf(NETIF_RX_BUF_SIZE, PMU_NETIF_RX); -- if (!ring_buf) { -- return -1; -- } -- -- return 0; --} -- --static void finish() --{ -- if (!ring_buf) { -- return; -- } -- -- free_buf(ring_buf); -- ring_buf = NULL; --} -- --static int open() --{ -- struct PmuAttr attr; -- char *evtList[1]; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- evtList[0] = "net:netif_rx"; -- -- attr.evtList = evtList; -- attr.numEvt = 1; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- -- pd = PmuOpen(COUNTING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- event_is_open = true; -- return pd; --} -- --static void netif_rx_close() --{ -- PmuClose(pmu_id); -- pmu_id = -1; -- event_is_open = false; --} -- --bool netif_rx_enable() --{ -- if (!ring_buf) { -- int ret = init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!event_is_open) { -- pmu_id = open(); -- if (pmu_id == -1) { -- finish(); -- goto err; -- } -- } -- -- return PmuEnable(pmu_id) == 0; -- --err: -- return false; --} -- --void netif_rx_disable() --{ -- PmuDisable(pmu_id); -- netif_rx_close(); -- finish(); --} -- --const struct DataRingBuf *netif_rx_get_ring_buf() --{ -- return (const struct DataRingBuf *)ring_buf; --} -- --static void reflash_ring_buf() --{ -- struct DataRingBuf *data_ringbuf; -- int len; -- -- data_ringbuf = (struct DataRingBuf *)ring_buf; -- if (!data_ringbuf) { -- printf("ring_buf has not malloc\n"); -- return; -- } -- -- PmuDisable(pmu_id); -- len = PmuRead(pmu_id, &pmu_data); -- PmuEnable(pmu_id); -- -- fill_buf(data_ringbuf, pmu_data, len); --} -- --void netif_rx_run(const struct Param *param) --{ -- (void)param; -- reflash_ring_buf(); --} -- --const char *netif_rx_get_version() --{ -- return NULL; --} -- --const char *netif_rx_get_name() --{ -- return PMU_NETIF_RX; --} -- --const char *netif_rx_get_description() --{ -- return NULL; --} -- --const char *netif_rx_get_dep() --{ -- return NULL; --} -- --int netif_rx_get_priority() --{ -- return 0; --} -- --int netif_rx_get_type() --{ -- return -1; --} -- --int netif_rx_get_period() --{ -- return 100; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_netif_rx.h b/src/plugin/collect/pmu/plugin/plugin_netif_rx.h -deleted file mode 100644 -index 0c82936..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_netif_rx.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_NETIF_RX_H__ --#define __PLUGIN_NETIF_RX_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *netif_rx_get_version(); --const char *netif_rx_get_name(); --const char *netif_rx_get_description(); --const char *netif_rx_get_dep(); --int netif_rx_get_priority(); --int netif_rx_get_type(); --int netif_rx_get_period(); --bool netif_rx_enable(); --void netif_rx_disable(); --const struct DataRingBuf *netif_rx_get_ring_buf(); --void netif_rx_run(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_sampling.c b/src/plugin/collect/pmu/plugin/plugin_sampling.c -deleted file mode 100644 -index 35e5dfb..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_sampling.c -+++ /dev/null -@@ -1,176 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_sampling.h" -- --static bool sampling_is_open = false; --static int sampling_pd = -1; --static struct DataRingBuf *sampling_buf = NULL; --struct PmuData *sampling_data = NULL; -- --static int sampling_init() --{ -- sampling_buf = init_buf(CYCLES_SAMPLING_BUF_SIZE, PMU_CYCLES_SAMPLING); -- if (!sampling_buf) { -- return -1; -- } -- -- return 0; --} -- --static void sampling_fini() --{ -- if (!sampling_buf) { -- return; -- } -- -- free_buf(sampling_buf); -- sampling_buf = NULL; --} -- --static int sampling_open() --{ -- struct PmuAttr attr; -- char *evtList[1]; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- evtList[0] = "cycles"; -- -- attr.evtList = evtList; -- attr.numEvt = 1; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- attr.freq = 100; -- attr.useFreq = 1; -- -- pd = PmuOpen(SAMPLING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- sampling_is_open = true; -- return pd; --} -- --static void sampling_close() --{ -- PmuClose(sampling_pd); -- sampling_pd = -1; -- sampling_is_open = false; --} -- --bool sampling_enable() --{ -- if (!sampling_buf) { -- int ret = sampling_init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!sampling_is_open) { -- sampling_pd = sampling_open(); -- if (sampling_pd == -1) { -- sampling_fini(); -- goto err; -- } -- } -- -- return PmuEnable(sampling_pd) == 0; -- --err: -- return false; --} -- --void sampling_disable() --{ -- PmuDisable(sampling_pd); -- sampling_close(); -- sampling_fini(); --} -- --const struct DataRingBuf *sampling_get_ring_buf() --{ -- return (const struct DataRingBuf *)sampling_buf; --} -- --static void sampling_reflash_ring_buf() --{ -- struct DataRingBuf *data_ringbuf; -- int len; -- -- data_ringbuf = (struct DataRingBuf *)sampling_buf; -- if (!data_ringbuf) { -- printf("sampling_buf has not malloc\n"); -- return; -- } -- -- PmuDisable(sampling_pd); -- len = PmuRead(sampling_pd, &sampling_data); -- PmuEnable(sampling_pd); -- -- fill_buf(data_ringbuf, sampling_data, len); --} -- --void sampling_run(const struct Param *param) --{ -- (void)param; -- sampling_reflash_ring_buf(); --} -- --const char *sampling_get_version() --{ -- return NULL; --} -- --const char *sampling_get_name() --{ -- return PMU_CYCLES_SAMPLING; --} -- --const char *sampling_get_description() --{ -- return NULL; --} -- --const char *sampling_get_dep() --{ -- return NULL; --} -- --int sampling_get_priority() --{ -- return 0; --} -- --int sampling_get_type() --{ -- return -1; --} -- --int sampling_get_period() --{ -- return 100; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_sampling.h b/src/plugin/collect/pmu/plugin/plugin_sampling.h -deleted file mode 100644 -index 066d74f..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_sampling.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_SAMPLING_H__ --#define __PLUGIN_SAMPLING_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *sampling_get_version(); --const char *sampling_get_name(); --const char *sampling_get_description(); --const char *sampling_get_dep(); --int sampling_get_priority(); --int sampling_get_type(); --int sampling_get_period(); --bool sampling_enable(); --void sampling_disable(); --const struct DataRingBuf *sampling_get_ring_buf(); --void sampling_run(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.c b/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.c -deleted file mode 100644 -index ae4abef..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.c -+++ /dev/null -@@ -1,174 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_sampling.h" -- --static bool g_samplingIsOpen = false; --static int g_samplingPd = -1; --static struct DataRingBuf *g_samplingBuf = NULL; --static struct PmuData *g_pmuData = NULL; -- --static int Init() --{ -- g_samplingBuf = init_buf(SKB_COPY_DATAGRAM_IOVEC_BUF_SIZE, PMU_SKB_COPY_DATEGRAM_IOVEC); -- if (!g_samplingBuf) { -- return -1; -- } -- -- return 0; --} -- --static void Finish() --{ -- if (!g_samplingBuf) { -- return; -- } -- -- free_buf(g_samplingBuf); -- g_samplingBuf = NULL; --} -- --static int Open() --{ -- struct PmuAttr attr; -- char *evtList[1]; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- evtList[0] = "skb:skb_copy_datagram_iovec"; -- -- attr.evtList = evtList; -- attr.numEvt = 1; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- attr.period = NET_RECEIVE_TRACE_SAMPLE_PERIOD; -- -- pd = PmuOpen(SAMPLING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- g_samplingIsOpen = true; -- return pd; --} -- --static void Close() --{ -- PmuClose(g_samplingPd); -- g_samplingPd = -1; -- g_samplingIsOpen = false; --} -- --bool SkbCopyDatagramIovecEnable() --{ -- if (!g_samplingBuf) { -- int ret = Init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!g_samplingIsOpen) { -- g_samplingPd = Open(); -- if (g_samplingPd == -1) { -- Finish(); -- goto err; -- } -- } -- -- return PmuEnable(g_samplingPd) == 0; -- --err: -- return false; --} -- --void SkbCopyDatagramIovecDisable() --{ -- PmuDisable(g_samplingPd); -- Close(); -- Finish(); --} -- --const struct DataRingBuf *SkbCopyDatagramIovecGetBuf() --{ -- return (const struct DataRingBuf *)g_samplingBuf; --} -- --static void SkbCopyDatagramIovecReflashBuf() --{ -- struct DataRingBuf *dataRingBuf; -- int len; -- -- dataRingBuf = (struct DataRingBuf *)g_samplingBuf; -- if (!dataRingBuf) { -- printf("g_samplingBuf has not malloc\n"); -- return; -- } -- -- PmuDisable(g_samplingPd); -- len = PmuRead(g_samplingPd, &g_pmuData); -- PmuEnable(g_samplingPd); -- fill_buf(dataRingBuf, g_pmuData, len); --} -- --void SkbCopyDatagramIovecRun(const struct Param *param) --{ -- (void)param; -- SkbCopyDatagramIovecReflashBuf(); --} -- --const char *SkbCopyDatagramIovecGetVer() --{ -- return NULL; --} -- --const char *SkbCopyDatagramIovecGetName() --{ -- return PMU_SKB_COPY_DATEGRAM_IOVEC; --} -- --const char *SkbCopyDatagramIovecGetDes() --{ -- return "event used to collect recv skb addr info"; --} -- --const char *SkbCopyDatagramIovecGetDep() --{ -- return NULL; --} -- --int SkbCopyDatagramIovecGetPriority() --{ -- return 0; --} -- --int SkbCopyDatagramIovecGetType() --{ -- return -1; --} -- --int SkbCopyDatagramIovecGetPeriod() --{ -- return 100; // 100ms --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.h b/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.h -deleted file mode 100644 -index 49c5202..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_skb_copy_datagram_iovec.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_SKB_COPY_DATAGRAM_IOVEC_H__ --#define __PLUGIN_SKB_COPY_DATAGRAM_IOVEC_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *SkbCopyDatagramIovecGetVer(); --const char *SkbCopyDatagramIovecGetName(); --const char *SkbCopyDatagramIovecGetDes(); --const char *SkbCopyDatagramIovecGetDep(); --int SkbCopyDatagramIovecGetPriority(); --int SkbCopyDatagramIovecGetType(); --int SkbCopyDatagramIovecGetPeriod(); --bool SkbCopyDatagramIovecEnable(); --void SkbCopyDatagramIovecDisable(); --const struct DataRingBuf *SkbCopyDatagramIovecGetBuf(); --void SkbCopyDatagramIovecRun(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_spe.c b/src/plugin/collect/pmu/plugin/plugin_spe.c -deleted file mode 100644 -index 52c31c3..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_spe.c -+++ /dev/null -@@ -1,174 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_spe.h" -- --static bool spe_is_open = false; --static int spe_pd = -1; --static struct DataRingBuf *spe_buf = NULL; --struct PmuData *spe_data = NULL; -- --static int spe_init() --{ -- spe_buf = init_buf(SPE_BUF_SIZE, PMU_SPE); -- if (!spe_buf) { -- return -1; -- } -- -- return 0; --} -- --static void spe_fini() --{ -- if (!spe_buf) { -- return; -- } -- -- free_buf(spe_buf); -- spe_buf = NULL; --} -- --static int spe_open() --{ -- struct PmuAttr attr; -- int pd; -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- attr.evtList = NULL; -- attr.numEvt = 0; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- attr.period = 2048; -- attr.dataFilter = SPE_DATA_ALL; -- attr.evFilter = SPE_EVENT_RETIRED; -- attr.minLatency = 0x60; -- -- pd = PmuOpen(SPE_SAMPLING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- spe_is_open = true; -- return pd; --} -- --static void spe_close() --{ -- PmuClose(spe_pd); -- spe_pd = -1; -- spe_is_open = false; --} -- --bool spe_enable() --{ -- if (!spe_buf) { -- int ret = spe_init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!spe_is_open) { -- spe_pd = spe_open(); -- if (spe_pd == -1) { -- spe_fini(); -- goto err; -- } -- } -- -- return PmuEnable(spe_pd) == 0; -- --err: -- return false; --} -- --void spe_disable() --{ -- PmuDisable(spe_pd); -- spe_close(); -- spe_fini(); --} -- --const struct DataRingBuf *spe_get_ring_buf() --{ -- return (const struct DataRingBuf *)spe_buf; --} -- --static void spe_reflash_ring_buf() --{ -- struct DataRingBuf *data_ringbuf; -- int len; -- -- data_ringbuf = (struct DataRingBuf *)spe_buf; -- if (!data_ringbuf) { -- printf("spe_buf has not malloc\n"); -- return; -- } -- -- // while using PMU_SPE, PmuRead internally calls PmuEnable and PmuDisable -- len = PmuRead(spe_pd, &spe_data); -- -- fill_buf(data_ringbuf, spe_data, len); --} -- --void spe_run(const struct Param *param) --{ -- (void)param; -- spe_reflash_ring_buf(); --} -- --const char *spe_get_version() --{ -- return NULL; --} -- --const char *spe_get_name() --{ -- return PMU_SPE; --} -- --const char *spe_get_description() --{ -- return NULL; --} -- --const char *spe_get_dep() --{ -- return NULL; --} -- --int spe_get_priority() --{ -- return 0; --} -- --int spe_get_type() --{ -- return -1; --} -- --int spe_get_period() --{ -- return 100; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_spe.h b/src/plugin/collect/pmu/plugin/plugin_spe.h -deleted file mode 100644 -index 11bb71f..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_spe.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_SPE_H__ --#define __PLUGIN_SPE_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *spe_get_version(); --const char *spe_get_name(); --const char *spe_get_description(); --const char *spe_get_dep(); --int spe_get_priority(); --int spe_get_type(); --int spe_get_period(); --bool spe_enable(); --void spe_disable(); --const struct DataRingBuf *spe_get_ring_buf(); --void spe_run(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/plugin_uncore.c b/src/plugin/collect/pmu/plugin/plugin_uncore.c -deleted file mode 100644 -index 9b845db..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_uncore.c -+++ /dev/null -@@ -1,199 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include "pmu.h" --#include "pcerrc.h" --#include "interface.h" --#include "pmu_plugin.h" --#include "plugin_comm.h" --#include "plugin_uncore.h" --#include "pmu_uncore.h" -- --static bool uncore_is_open = false; --static int uncore_pd = -1; --static struct DataRingBuf *uncore_buf = NULL; --struct PmuData *uncore_data = NULL; -- --static int uncore_init() --{ -- uncore_buf = init_buf(UNCORE_BUF_SIZE, PMU_UNCORE); -- if (!uncore_buf) { -- return -1; -- } -- -- return 0; --} -- --static void uncore_fini() --{ -- if (!uncore_buf) { -- return; -- } -- -- free_buf(uncore_buf); -- uncore_buf = NULL; --} -- --static int uncore_open() --{ -- struct PmuAttr attr; -- struct uncore_config *rx_outer; -- struct uncore_config *rx_sccl; -- struct uncore_config *rx_ops_num; -- int hha_num; -- int pd = -1; -- int ret; -- -- // Base on oeAware framework, uncore_open is called within uncore_enable. -- // If pmu_uncore is not supported, it will generate a large number of error logs. -- // So temporarily set uncore_is_open = true util oeAware framework provides open API. -- uncore_is_open = true; -- -- ret = hha_uncore_config_init(); -- if (ret != 0) { -- printf("This system not support pmu_uncore\n"); -- return pd; -- } -- -- hha_num = get_uncore_hha_num(); -- rx_outer = get_rx_outer(); -- rx_sccl = get_rx_sccl(); -- rx_ops_num = get_rx_ops_num(); -- -- char *evtList[hha_num * UNCORE_MAX]; -- for (int i = 0; i < hha_num; i++) { -- evtList[i + hha_num * RX_OUTER] = rx_outer[i].uncore_name; -- evtList[i + hha_num * RX_SCCL] = rx_sccl[i].uncore_name; -- evtList[i + hha_num * RX_OPS_NUM] = rx_ops_num[i].uncore_name; -- } -- -- (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); -- -- attr.evtList = evtList; -- attr.numEvt = hha_num * UNCORE_MAX; -- attr.pidList = NULL; -- attr.numPid = 0; -- attr.cpuList = NULL; -- attr.numCpu = 0; -- -- pd = PmuOpen(COUNTING, &attr); -- if (pd == -1) { -- printf("%s\n", Perror()); -- return pd; -- } -- -- return pd; --} -- --static void uncore_close() --{ -- PmuClose(uncore_pd); -- uncore_pd = -1; -- uncore_is_open = false; --} -- --bool uncore_enable() --{ -- if (!uncore_buf) { -- int ret = uncore_init(); -- if (ret != 0) { -- goto err; -- } -- } -- -- if (!uncore_is_open) { -- uncore_pd = uncore_open(); -- if (uncore_pd == -1) { -- uncore_fini(); -- goto err; -- } -- } -- -- return PmuEnable(uncore_pd) == 0; -- --err: -- return false; --} -- --void uncore_disable() --{ -- PmuDisable(uncore_pd); -- uncore_close(); -- uncore_fini(); --} -- --const struct DataRingBuf *uncore_get_ring_buf() --{ -- return (const struct DataRingBuf *)uncore_buf; --} -- --static void uncore_reflash_ring_buf() --{ -- struct DataRingBuf *data_ringbuf; -- int len; -- -- data_ringbuf = (struct DataRingBuf *)uncore_buf; -- if (!data_ringbuf) { -- printf("uncore_buf has not malloc\n"); -- return; -- } -- -- PmuDisable(uncore_pd); -- len = PmuRead(uncore_pd, &uncore_data); -- PmuEnable(uncore_pd); -- -- fill_buf(data_ringbuf, uncore_data, len); --} -- --void uncore_run(const struct Param *param) --{ -- (void)param; -- uncore_reflash_ring_buf(); --} -- --const char *uncore_get_version() --{ -- return NULL; --} -- --const char *uncore_get_name() --{ -- return PMU_UNCORE; --} -- --const char *uncore_get_description() --{ -- return NULL; --} -- --const char *uncore_get_dep() --{ -- return NULL; --} -- --int uncore_get_priority() --{ -- return 0; --} -- --int uncore_get_type() --{ -- return -1; --} -- --int uncore_get_period() --{ -- return 100; --} -diff --git a/src/plugin/collect/pmu/plugin/plugin_uncore.h b/src/plugin/collect/pmu/plugin/plugin_uncore.h -deleted file mode 100644 -index a15d950..0000000 ---- a/src/plugin/collect/pmu/plugin/plugin_uncore.h -+++ /dev/null -@@ -1,35 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PLUGIN_UNCORE_H__ --#define __PLUGIN_UNCORE_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --const char *uncore_get_version(); --const char *uncore_get_name(); --const char *uncore_get_description(); --const char *uncore_get_dep(); --int uncore_get_priority(); --int uncore_get_type(); --int uncore_get_period(); --bool uncore_enable(); --void uncore_disable(); --const struct DataRingBuf *uncore_get_ring_buf(); --void uncore_run(const struct Param *param); -- --#ifdef __cplusplus --} --#endif -- --#endif -diff --git a/src/plugin/collect/pmu/plugin/pmu_uncore.c b/src/plugin/collect/pmu/plugin/pmu_uncore.c -deleted file mode 100644 -index 71dcda1..0000000 ---- a/src/plugin/collect/pmu/plugin/pmu_uncore.c -+++ /dev/null -@@ -1,142 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#include --#include --#include --#include --#include --#include "pmu_uncore.h" -- --static int hha_num = 0; --static struct uncore_config *uncore_rx_outer = NULL; --static struct uncore_config *uncore_rx_sccl = NULL; --static struct uncore_config *uncore_rx_ops_num = NULL; -- --int get_uncore_hha_num() --{ -- return hha_num; --} -- --struct uncore_config *get_rx_outer() --{ -- return uncore_rx_outer; --} -- --struct uncore_config *get_rx_sccl() --{ -- return uncore_rx_sccl; --} -- --struct uncore_config *get_rx_ops_num() --{ -- return uncore_rx_ops_num; --} -- --static int read_single_uncore_event(const char *hha_name, struct uncore_config *uncore_event, const char *event_name) --{ -- char hha_path[MAX_PATH_LEN] = {0}; -- -- // Read cfg -- snprintf_truncated_s(hha_path, MAX_PATH_LEN, "%s/%s/", hha_name, event_name); -- -- strcpy(uncore_event->uncore_name, hha_path); -- -- return 0; --} -- --static void free_namelist(int n, struct dirent **namelist) --{ -- while (n--) { -- free(namelist[n]); -- } -- free(namelist); --} -- --static int hha_read_uncore_config(int n, struct dirent **namelist) --{ -- int index = 0; -- -- while (index < n) { -- if (read_single_uncore_event(namelist[index]->d_name, &uncore_rx_outer[index], "rx_outer") != 0) { -- return -1; -- } -- if (read_single_uncore_event(namelist[index]->d_name, &uncore_rx_sccl[index], "rx_sccl") != 0) { -- return -1; -- } -- if (read_single_uncore_event(namelist[index]->d_name, &uncore_rx_ops_num[index], "rx_ops_num") != 0) { -- return -1; -- } -- -- index++; -- } -- -- return 0; --} -- --static int hha_scandir_select(const struct dirent *ptr) --{ -- int ret = 0; -- if (strstr(ptr->d_name, "hha") != NULL) { -- ret = 1; -- } -- -- return ret; --} -- --int hha_uncore_config_init(void) --{ -- int ret; -- struct dirent **namelist; -- -- hha_num = scandir(DEVICE_PATH, &namelist, hha_scandir_select, alphasort); -- if (hha_num <= 0) { -- printf("scandir failed\n"); -- return -1; -- } -- -- uncore_rx_outer = (struct uncore_config *)calloc(hha_num, sizeof(struct uncore_config)); -- if (uncore_rx_outer == NULL) { -- free_namelist(hha_num, namelist); -- return -1; -- } -- uncore_rx_sccl = (struct uncore_config *)calloc(hha_num, sizeof(struct uncore_config)); -- if (uncore_rx_sccl == NULL) { // free uncore_rx_sccl in function uncore_config_fini -- free_namelist(hha_num, namelist); -- return -1; -- } -- uncore_rx_ops_num = (struct uncore_config *)calloc(hha_num, sizeof(struct uncore_config)); -- if (uncore_rx_ops_num == NULL) { // free uncore_rx_ops_num in function uncore_config_fini -- free_namelist(hha_num, namelist); -- return -1; -- } -- -- ret = hha_read_uncore_config(hha_num, namelist); -- free_namelist(hha_num, namelist); -- -- return ret; --} -- --void uncore_config_fini(void) --{ --#define UNCORE_CONFIG_FREE(uncore_event) do { \ -- if (uncore_event != NULL) { \ -- free(uncore_event); \ -- uncore_event = NULL; \ -- } \ --} while (0) -- -- UNCORE_CONFIG_FREE(uncore_rx_outer); -- UNCORE_CONFIG_FREE(uncore_rx_sccl); -- UNCORE_CONFIG_FREE(uncore_rx_ops_num); -- -- hha_num = 0; --} -diff --git a/src/plugin/collect/pmu/plugin/pmu_uncore.h b/src/plugin/collect/pmu/plugin/pmu_uncore.h -deleted file mode 100644 -index d49208c..0000000 ---- a/src/plugin/collect/pmu/plugin/pmu_uncore.h -+++ /dev/null -@@ -1,45 +0,0 @@ --/****************************************************************************** -- * Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. -- * oeAware is licensed under Mulan PSL v2. -- * You can use this software according to the terms and conditions of the Mulan PSL v2. -- * You may obtain a copy of Mulan PSL v2 at: -- * http://license.coscl.org.cn/MulanPSL2 -- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -- * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -- * See the Mulan PSL v2 for more details. -- ******************************************************************************/ --#ifndef __PMU_UNCORE_H__ --#define __PMU_UNCORE_H__ -- --#ifdef __cplusplus --extern "C" { --#endif -- --#define UNCORE_NAME_SIZE 256 --#define MAX_PATH_LEN 256 --#define DEVICE_PATH "/sys/devices/" -- --struct uncore_config { -- char uncore_name[UNCORE_NAME_SIZE]; --}; -- --enum uncore_type { -- RX_OUTER, -- RX_SCCL, -- RX_OPS_NUM, -- UNCORE_MAX, --}; -- --int get_uncore_hha_num(void); --struct uncore_config *get_rx_outer(void); --struct uncore_config *get_rx_sccl(void); --struct uncore_config *get_rx_ops_num(void); --int hha_uncore_config_init(void); --void uncore_config_fini(void); -- --#ifdef __cplusplus --} --#endif -- --#endif --- -2.33.0 - diff --git a/0002-add-data-free-and-fix-unsubscribe-error.patch b/0002-add-data-free-and-fix-unsubscribe-error.patch deleted file mode 100644 index c3c62e84de78c78123233db2767c7bc9b59947c7..0000000000000000000000000000000000000000 --- a/0002-add-data-free-and-fix-unsubscribe-error.patch +++ /dev/null @@ -1,524 +0,0 @@ -From 9fb0aa74fece1deea72ef7c8eef5e45da2113b21 Mon Sep 17 00:00:00 2001 -From: fly_1997 -Date: Tue, 26 Nov 2024 15:59:15 +0800 -Subject: [PATCH 2/5] add data free and fix unsubscribe error - ---- - src/common/CMakeLists.txt | 7 + - src/common/data_register.cpp | 247 +++++++++++++++---- - src/common/data_register.h | 20 +- - src/plugin/collect/include/command_data.h | 2 +- - src/plugin_mgr/event/unsubscribe_handler.cpp | 7 +- - src/plugin_mgr/instance_run_handler.cpp | 2 +- - src/sdk/oe_client.cpp | 1 + - 7 files changed, 227 insertions(+), 59 deletions(-) - -diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt -index 2d49b3e..46084e5 100644 ---- a/src/common/CMakeLists.txt -+++ b/src/common/CMakeLists.txt -@@ -22,6 +22,13 @@ target_link_libraries(${PROJECT_NAME} log4cplus) - target_link_libraries(${PROJECT_NAME} yaml-cpp) - target_link_libraries(${PROJECT_NAME} curl boundscheck) - -+if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") -+target_link_directories(${PROJECT_NAME} PUBLIC -+ ${LIB_KPERF_LIBPATH} -+) -+target_link_libraries(${PROJECT_NAME} kperf) -+endif() -+ - file(COPY - "${CMAKE_CURRENT_SOURCE_DIR}/data_list.h" - DESTINATION "${CMAKE_BINARY_DIR}/output/include") -diff --git a/src/common/data_register.cpp b/src/common/data_register.cpp -index 89e660e..cdf6d97 100644 ---- a/src/common/data_register.cpp -+++ b/src/common/data_register.cpp -@@ -16,68 +16,107 @@ - - namespace oeaware { - --int TopicSerialize(const void *topic, OutStream &out) -+void TopicFree(CTopic *topic) - { -- auto tmpTopic = static_cast(topic); -- std::string instanceName(tmpTopic->instanceName); -- std::string topicName(tmpTopic->topicName); -- std::string params(tmpTopic->params); -+ if (topic == nullptr) { -+ return; -+ } -+ if (topic->instanceName != nullptr) { -+ delete[] topic->instanceName; -+ topic->instanceName = nullptr; -+ } -+ if (topic->topicName != nullptr) { -+ delete[] topic->topicName; -+ topic->topicName = nullptr; -+ } -+ if (topic->params != nullptr) { -+ delete[] topic->params; -+ topic->params = nullptr; -+ } -+} -+ -+int TopicSerialize(const CTopic *topic, OutStream &out) -+{ -+ std::string instanceName(topic->instanceName); -+ std::string topicName(topic->topicName); -+ std::string params(topic->params); - out << instanceName << topicName << params; - return 0; - } - --int TopicDeserialize(void *topic, InStream &in) -+int TopicDeserialize(CTopic *topic, InStream &in) - { - std::string instanceName; - std::string topicName; - std::string params; - in >> instanceName >> topicName >> params; -- ((CTopic*)topic)->instanceName = new char[instanceName.size() + 1]; -- ((CTopic*)topic)->topicName = new char[topicName.size() + 1]; -- ((CTopic*)topic)->params = new char[params.size() + 1]; -+ topic->instanceName = new char[instanceName.size() + 1]; -+ topic->topicName = new char[topicName.size() + 1]; -+ topic->params = new char[params.size() + 1]; - -- auto ret = strcpy_s(((CTopic*)topic)->instanceName, instanceName.size() + 1, instanceName.data()); -+ auto ret = strcpy_s(topic->instanceName, instanceName.size() + 1, instanceName.data()); - if (ret != EOK) return ret; -- ret = strcpy_s(((CTopic*)topic)->topicName, topicName.size() + 1, topicName.data()); -+ ret = strcpy_s(topic->topicName, topicName.size() + 1, topicName.data()); - if (ret != EOK) return ret; -- ret = strcpy_s(((CTopic*)topic)->params, params.size() + 1, params.data()); -+ ret = strcpy_s(topic->params, params.size() + 1, params.data()); - if (ret != EOK) return ret; - return 0; - } - --int DataListSerialize(const void *dataList, OutStream &out) -+void DataListFree(DataList *dataList) -+{ -+ if (dataList == nullptr) { -+ return; -+ } -+ auto ® = Register::GetInstance(); -+ DataFreeFunc free = reg.GetDataFreeFunc(Concat({dataList->topic.instanceName, dataList->topic.topicName}, "::")); -+ if (free == nullptr) { -+ free = reg.GetDataFreeFunc(dataList->topic.instanceName); -+ } -+ if (free != nullptr) { -+ for (uint64_t i = 0; i < dataList->len; ++i) { -+ free(dataList->data[i]); -+ } -+ } -+ TopicFree(&dataList->topic); -+ if (dataList->data != nullptr) { -+ delete[] dataList->data; -+ dataList->data = nullptr; -+ } -+} -+ -+int DataListSerialize(const DataList *dataList, OutStream &out) - { -- auto tmpList = static_cast(dataList); -- TopicSerialize(&tmpList->topic, out); -- out << tmpList->len; -+ TopicSerialize(&dataList->topic, out); -+ out << dataList->len; - auto ® = Register::GetInstance(); -- auto func = reg.GetDataSerialize(Concat({tmpList->topic.instanceName, tmpList->topic.topicName}, "::")); -+ auto func = reg.GetDataSerialize(Concat({dataList->topic.instanceName, dataList->topic.topicName}, "::")); - if (func == nullptr) { -- func = reg.GetDataSerialize(tmpList->topic.instanceName); -+ func = reg.GetDataSerialize(dataList->topic.instanceName); - } -- for (uint64_t i = 0; i < tmpList->len; ++i) { -- func(tmpList->data[i], out); -+ for (uint64_t i = 0; i < dataList->len; ++i) { -+ func(dataList->data[i], out); - } - return 0; - } - --int DataListDeserialize(void *dataList, InStream &in) -+int DataListDeserialize(DataList *dataList, InStream &in) - { - CTopic topic; - TopicDeserialize(&topic, in); - uint64_t size; - in >> size; -- ((DataList*)dataList)->topic = topic; -- ((DataList*)dataList)->len = size; -- ((DataList*)dataList)->data = new void* [size]; -+ dataList->topic = topic; -+ dataList->len = size; -+ dataList->data = new void* [size]; - auto ® = Register::GetInstance(); - auto func = reg.GetDataDeserialize(Concat({topic.instanceName, topic.topicName}, "::")); - if (func == nullptr) { - func = reg.GetDataDeserialize(topic.instanceName); - } - for (uint64_t i = 0; i < size; ++i) { -- ((DataList*)dataList)->data[i] = nullptr; -- auto ret = func(&(((DataList*)dataList)->data[i]), in); -+ dataList->data[i] = nullptr; -+ auto ret = func(&(dataList->data[i]), in); - if (ret) { - return ret; - } -@@ -85,6 +124,16 @@ int DataListDeserialize(void *dataList, InStream &in) - return 0; - } - -+void ResultFree(Result *result) -+{ -+ if (result == nullptr) { -+ return; -+ } -+ if (result->payload != nullptr) { -+ delete[] result->payload; -+ result->payload = nullptr; -+ } -+} - - int ResultDeserialize(void *data, InStream &in) - { -@@ -96,6 +145,17 @@ int ResultDeserialize(void *data, InStream &in) - return ret; - } - #if defined(__arm__) || defined(__aarch64__) -+void PmuBaseDataFree(void *data) -+{ -+ auto tmpData = static_cast(data); -+ if (tmpData == nullptr) { -+ return; -+ } -+ PmuDataFree(tmpData->pmuData); -+ tmpData->pmuData = nullptr; -+ tmpData->len = 0; -+} -+ - int PmuCountingDataSerialize(const void *data, OutStream &out) - { - auto tmpData = static_cast(data); -@@ -456,6 +516,19 @@ int PmuUncoreDataDeserialize(void **data, InStream &in) - } - #endif - -+void ThreadInfoFree(void *data) -+{ -+ auto threadInfo = static_cast(data); -+ if (threadInfo == nullptr) { -+ return; -+ } -+ if (threadInfo->name != nullptr) { -+ delete[] threadInfo->name; -+ threadInfo->name = nullptr; -+ } -+ delete threadInfo; -+} -+ - int ThreadInfoSerialize(const void *data, OutStream &out) - { - auto threadInfo = static_cast(data); -@@ -476,6 +549,32 @@ int ThreadInfoDeserialize(void **data, InStream &in) - return 0; - } - -+void KernelDataFree(void *data) -+{ -+ auto tmpData = static_cast(data); -+ if (tmpData == nullptr) { -+ return; -+ } -+ KernelDataNode *node = tmpData->kernelData; -+ for (int i = 0; i < tmpData->len; ++i) { -+ auto tmp = node->next; -+ if (node == nullptr) { -+ break; -+ } -+ if (node->key != nullptr) { -+ delete[] node->key; -+ node->key = nullptr; -+ } -+ if (node->value != nullptr) { -+ delete[] node->value; -+ node->value = nullptr; -+ } -+ delete node; -+ node = tmp; -+ } -+ delete tmpData; -+} -+ - int KernelDataSerialize(const void *data, OutStream &out) - { - auto tmpData = static_cast(data); -@@ -523,17 +622,47 @@ int KernelDataDeserialize(void **data, InStream &in) - return 0; - } - -+void CommandDataFree(void *data) -+{ -+ CommandData *commandData = (CommandData*)data; -+ if (commandData == nullptr) { -+ return; -+ } -+ for (int i = 0; i < commandData->attrLen; ++i) { -+ if (commandData->itemAttr[i] != nullptr) { -+ delete[] commandData->itemAttr[i]; -+ commandData->itemAttr[i] = nullptr; -+ } -+ } -+ if (commandData->items == nullptr) { -+ delete commandData; -+ return; -+ } -+ for (int i = 0; i < commandData->itemLen; ++i) { -+ for (int j = 0; j < commandData->attrLen; ++j) { -+ if (commandData->items[i].value[j] != nullptr) { -+ delete[] commandData->items[i].value[j]; -+ commandData->items[i].value[j] = nullptr; -+ } -+ } -+ } -+ delete[] commandData->items; -+ commandData->items = nullptr; -+ -+ delete commandData; -+} -+ - int CommandDataSerialize(const void *data, OutStream &out) - { -- auto sarData = (SarData*)data; -- out << sarData->attrLen << sarData->itemLen; -- for (int i = 0; i < sarData->attrLen; ++i) { -- std::string attr(sarData->itemAttr[i]); -+ auto commandData = (CommandData*)data; -+ out << commandData->attrLen << commandData->itemLen; -+ for (int i = 0; i < commandData->attrLen; ++i) { -+ std::string attr(commandData->itemAttr[i]); - out << attr; - } -- for (int i = 0; i < sarData->itemLen; ++i) { -- for (int j = 0; j < sarData->attrLen; ++j) { -- std::string item(sarData->items[i].value[j]); -+ for (int i = 0; i < commandData->itemLen; ++i) { -+ for (int j = 0; j < commandData->attrLen; ++j) { -+ std::string item(commandData->items[i].value[j]); - out << item; - } - } -@@ -542,8 +671,8 @@ int CommandDataSerialize(const void *data, OutStream &out) - - int CommandDataDeserialize(void **data, InStream &in) - { -- *data = new SarData(); -- auto sarData = static_cast(*data); -+ *data = new CommandData(); -+ auto sarData = static_cast(*data); - in >> sarData->attrLen >> sarData->itemLen; - int ret; - for (int i = 0; i < sarData->attrLen; ++i) { -@@ -570,6 +699,15 @@ int CommandDataDeserialize(void **data, InStream &in) - return 0; - } - -+void AnalysisDataFree(void *data) -+{ -+ auto analysisData = static_cast(data); -+ if (analysisData == nullptr) { -+ return; -+ } -+ delete analysisData; -+} -+ - int AnalysisDataSerialize(const void *data, OutStream &out) - { - auto analysisData = static_cast(data); -@@ -600,44 +738,55 @@ int AnalysisDataDeserialize(void **data, InStream &in) - - void Register::RegisterData(const std::string &name, const RegisterEntry &entry) - { -- deserializeFuncs[name] = entry; -+ registerEntry[name] = entry; - } - - void Register::InitRegisterData() - { - #if defined(__arm__) || defined(__aarch64__) -- RegisterData("pmu_counting_collector", RegisterEntry(PmuCountingDataSerialize, PmuCountingDataDeserialize)); -+ RegisterData("pmu_counting_collector", RegisterEntry(PmuCountingDataSerialize, PmuCountingDataDeserialize, -+ PmuBaseDataFree)); - -- RegisterData("pmu_sampling_collector", RegisterEntry(PmuSamplingDataSerialize, PmuSamplingDataDeserialize)); -+ RegisterData("pmu_sampling_collector", RegisterEntry(PmuSamplingDataSerialize, PmuSamplingDataDeserialize, -+ PmuBaseDataFree)); - -- RegisterData("pmu_spe_collector", RegisterEntry(PmuSpeDataSerialize, PmuSpeDataDeserialize)); -+ RegisterData("pmu_spe_collector", RegisterEntry(PmuSpeDataSerialize, PmuSpeDataDeserialize, PmuBaseDataFree)); - -- RegisterData("pmu_uncore_collector", RegisterEntry(PmuUncoreDataSerialize, PmuUncoreDataDeserialize)); -+ RegisterData("pmu_uncore_collector", RegisterEntry(PmuUncoreDataSerialize, PmuUncoreDataDeserialize, -+ PmuBaseDataFree)); - #endif -- RegisterData("thread_collector", RegisterEntry(ThreadInfoSerialize, ThreadInfoDeserialize)); -+ RegisterData("thread_collector", RegisterEntry(ThreadInfoSerialize, ThreadInfoDeserialize, ThreadInfoFree)); -+ -+ RegisterData("kernel_config", RegisterEntry(KernelDataSerialize, KernelDataDeserialize, KernelDataFree)); - -- RegisterData("kernel_config", RegisterEntry(KernelDataSerialize, KernelDataDeserialize)); -+ RegisterData("thread_scenario", RegisterEntry(ThreadInfoSerialize, ThreadInfoDeserialize, ThreadInfoFree)); - -- RegisterData("thread_scenario", RegisterEntry(ThreadInfoSerialize, ThreadInfoDeserialize)); -+ RegisterData("command_collector", RegisterEntry(CommandDataSerialize, CommandDataDeserialize, CommandDataFree)); - -- RegisterData("command_collector", RegisterEntry(CommandDataSerialize, CommandDataDeserialize)); -- RegisterData("command_collector", RegisterEntry(CommandDataSerialize, CommandDataDeserialize)); - RegisterData("analysis_aware", RegisterEntry(AnalysisDataSerialize, AnalysisDataDeserialize)); - } - - SerializeFunc Register::GetDataSerialize(const std::string &name) - { -- if (!deserializeFuncs.count(name)) { -+ if (!registerEntry.count(name)) { - return nullptr; - } -- return deserializeFuncs[name].se; -+ return registerEntry[name].se; - } - - DeserializeFunc Register::GetDataDeserialize(const std::string &name) - { -- if (!deserializeFuncs.count(name)) { -+ if (!registerEntry.count(name)) { -+ return nullptr; -+ } -+ return registerEntry[name].de; -+} -+ -+DataFreeFunc Register::GetDataFreeFunc(const std::string &name) -+{ -+ if (!registerEntry.count(name)) { - return nullptr; - } -- return deserializeFuncs[name].de; -+ return registerEntry[name].free; - } - } -diff --git a/src/common/data_register.h b/src/common/data_register.h -index 5e1ae4a..b72cd97 100644 ---- a/src/common/data_register.h -+++ b/src/common/data_register.h -@@ -13,18 +13,21 @@ - #define COMMON_DATA_REGISTER_H - #include - #include "serialize.h" -+#include "data_list.h" - - namespace oeaware { - using DeserializeFunc = int(*)(void**, InStream &in); - using SerializeFunc = int(*)(const void*, OutStream &out); --using FreeData = void(*)(void *); -+using DataFreeFunc = void(*)(void *); - - struct RegisterEntry { - RegisterEntry() { } - RegisterEntry(const SerializeFunc &se, const DeserializeFunc &de) : se(se), de(de) { } -+ RegisterEntry(const SerializeFunc &se, const DeserializeFunc &de, const DataFreeFunc &free) : se(se), -+ de(de), free(free) { } - SerializeFunc se; - DeserializeFunc de; -- FreeData free; -+ DataFreeFunc free; - }; - - class Register { -@@ -40,17 +43,20 @@ public: - void InitRegisterData(); - DeserializeFunc GetDataDeserialize(const std::string &name); - SerializeFunc GetDataSerialize(const std::string &name); -+ DataFreeFunc GetDataFreeFunc(const std::string &name); - void RegisterData(const std::string &name, const RegisterEntry &func); - private: - Register() { }; - -- std::unordered_map deserializeFuncs; -+ std::unordered_map registerEntry; - }; -- --int DataListSerialize(const void *data, OutStream &out); --int DataListDeserialize(void *data, InStream &in); -+void DataListFree(DataList *dataList); -+int DataListSerialize(const DataList *dataList, OutStream &out); -+int DataListDeserialize(DataList *dataList, InStream &in); - int ResultDeserialize(void *data, InStream &in); --int TopicSerialize(const void *topic, OutStream &out); -+int TopicSerialize(const CTopic *topic, OutStream &out); -+int TopicDeserialize(CTopic *topic, InStream &in); -+void TopicFree(CTopic *topic); - } - - #endif -diff --git a/src/plugin/collect/include/command_data.h b/src/plugin/collect/include/command_data.h -index f466bd3..e7a8540 100644 ---- a/src/plugin/collect/include/command_data.h -+++ b/src/plugin/collect/include/command_data.h -@@ -26,7 +26,7 @@ typedef struct { - int attrLen; - char *itemAttr[ATTR_MAX_LENGTH]; - CommandIter *items; --} SarData, CommandData; -+} CommandData; - #ifdef __cplusplus - } - #endif -diff --git a/src/plugin_mgr/event/unsubscribe_handler.cpp b/src/plugin_mgr/event/unsubscribe_handler.cpp -index 72b53bf..749a683 100644 ---- a/src/plugin_mgr/event/unsubscribe_handler.cpp -+++ b/src/plugin_mgr/event/unsubscribe_handler.cpp -@@ -23,7 +23,12 @@ EventResult UnsubscribeHandler::Handle(const Event &event) - INFO(logger, "sdk " << event.payload[0] << " disconnected and has been unsubscribed related topics."); - return eventResult; - } -- auto msg = std::make_shared(RunType::UNSUBSCRIBE, event.payload); -+ CTopic cTopic; -+ InStream in(event.payload[0]); -+ TopicDeserialize(&cTopic, in); -+ Topic topic{cTopic.instanceName, cTopic.topicName, cTopic.params}; -+ auto msg = std::make_shared(RunType::UNSUBSCRIBE, -+ std::vector{topic.GetType(), event.payload[1]}); - instanceRunHandler->RecvQueuePush(msg); - msg->Wait(); - result = msg->result; -diff --git a/src/plugin_mgr/instance_run_handler.cpp b/src/plugin_mgr/instance_run_handler.cpp -index 2e11d0d..30dc886 100644 ---- a/src/plugin_mgr/instance_run_handler.cpp -+++ b/src/plugin_mgr/instance_run_handler.cpp -@@ -181,7 +181,7 @@ void InstanceRunHandler::PublishData(std::shared_ptr &msg) - auto instance = memoryStore->GetInstance(subscriber); - instance->interface->UpdateData(msg->dataList); - } -- // free dataList -+ DataListFree(&msg->dataList); - } - - bool InstanceRunHandler::HandleMessage() -diff --git a/src/sdk/oe_client.cpp b/src/sdk/oe_client.cpp -index 4eb04ae..9452a37 100644 ---- a/src/sdk/oe_client.cpp -+++ b/src/sdk/oe_client.cpp -@@ -70,6 +70,7 @@ void Impl::HandleRecv() - for (auto handle : topicHandle[key]) { - handle(&dataList); - } -+ DataListFree(&dataList); - break; - } - default: --- -2.33.0 - diff --git a/0003-fix-failed-to-connect-to-the-sdk-and-command-executi.patch b/0003-fix-failed-to-connect-to-the-sdk-and-command-executi.patch deleted file mode 100644 index 3d9ace0fd96f508b078c6846c302def2dbbadc0e..0000000000000000000000000000000000000000 --- a/0003-fix-failed-to-connect-to-the-sdk-and-command-executi.patch +++ /dev/null @@ -1,412 +0,0 @@ -From 51355e66be3eeec6ebe79faa88324c788e5a3829 Mon Sep 17 00:00:00 2001 -From: fly_1997 -Date: Wed, 27 Nov 2024 05:13:26 +0800 -Subject: [PATCH 3/5] fix failed to connect to the sdk and command execution is - stuck - ---- - src/common/utils.cpp | 16 ++++ - src/common/utils.h | 1 + - .../collect/system/command/command_base.cpp | 48 +++++++++++- - .../collect/system/command/command_base.h | 9 +++ - .../system/command/command_collector.cpp | 9 ++- - src/plugin/collect/system/kernel_config.cpp | 1 + - src/plugin_mgr/config.cpp | 17 ----- - src/plugin_mgr/config.h | 1 - - src/plugin_mgr/message_manager.cpp | 76 +++++++++++++++++-- - src/plugin_mgr/message_manager.h | 3 +- - src/sdk/oe_client.cpp | 12 ++- - 11 files changed, 160 insertions(+), 33 deletions(-) - -diff --git a/src/common/utils.cpp b/src/common/utils.cpp -index 4e12a57..a300a6a 100644 ---- a/src/common/utils.cpp -+++ b/src/common/utils.cpp -@@ -156,4 +156,20 @@ std::vector SplitString(const std::string &str, const std::string & - } - return tokens; - } -+bool CreateDir(const std::string &path) -+{ -+ size_t pos = 0; -+ do { -+ pos = path.find_first_of("/", pos + 1); -+ std::string subPath = path.substr(0, pos); -+ struct stat buffer; -+ if (stat(subPath.c_str(), &buffer) == 0) { -+ continue; -+ } -+ if (mkdir(subPath.c_str(), S_IRWXU | S_IRWXG) != 0) { -+ return false; -+ } -+ } while (pos != std::string::npos); -+ return true; -+} - } -diff --git a/src/common/utils.h b/src/common/utils.h -index ba787fe..48b72bd 100644 ---- a/src/common/utils.h -+++ b/src/common/utils.h -@@ -28,6 +28,7 @@ bool EndWith(const std::string &s, const std::string &ending); - std::string Concat(const std::vector& strings, const std::string &split); - // Separate "str" with the separator "split" - std::vector SplitString(const std::string &str, const std::string &split); -+bool CreateDir(const std::string &path); - } - - #endif // !COMMON_UTILS_H -\ 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 d5a30dd..bf658b8 100644 ---- a/src/plugin/collect/system/command/command_base.cpp -+++ b/src/plugin/collect/system/command/command_base.cpp -@@ -10,6 +10,45 @@ - * See the Mulan PSL v2 for more details. - ******************************************************************************/ - #include "command_base.h" -+#include -+#include -+ -+int PopenProcess::Pclose() -+{ -+ if (fclose(stream) == EOF) { -+ return -1; -+ } -+ stream = nullptr; -+ if (kill(pid, SIGTERM) == -1) { -+ return -1; -+ } -+ return 0; -+} -+ -+void PopenProcess::Popen(const std::string &cmd) -+{ -+ int pipeFd[2]; -+ if (pipe(pipeFd) == -1) { -+ return; -+ } -+ pid = fork(); -+ if (pid == -1) { -+ close(pipeFd[0]); -+ close(pipeFd[1]); -+ } else if (pid == 0) { -+ close(pipeFd[0]); -+ dup2(pipeFd[1], STDOUT_FILENO); -+ close(pipeFd[1]); -+ execl("/bin/bash", "bash", "-c", cmd.data(), nullptr); -+ _exit(1); -+ } -+ close(pipeFd[1]); -+ stream = fdopen(pipeFd[0], "r"); -+ if (!stream) { -+ close(pipeFd[0]); -+ return; -+ } -+} - - CommandBase::CommandBase() - { -@@ -23,18 +62,19 @@ CommandBase::CommandBase() - bool CommandBase::ValidateArgs(const oeaware::Topic& topic) - { - auto cmd = GetCommand(topic); -- FILE *pipe = popen(cmd.c_str(), "r"); -- if (!pipe) { -+ PopenProcess p; -+ p.Popen(cmd); -+ if (!p.stream) { - return false; - } - char buffer[128]; - bool isValid = false; -- if (fgets(buffer, sizeof(buffer), pipe) != nullptr) { -+ if (fgets(buffer, sizeof(buffer), p.stream) != nullptr) { - if (strstr(buffer, "Linux") != nullptr || strstr(buffer, "procs") != nullptr) { - isValid = true; - } - } -- pclose(pipe); -+ p.Pclose(); - return isValid; - } - -diff --git a/src/plugin/collect/system/command/command_base.h b/src/plugin/collect/system/command/command_base.h -index eb75c49..a6d7627 100644 ---- a/src/plugin/collect/system/command/command_base.h -+++ b/src/plugin/collect/system/command/command_base.h -@@ -44,4 +44,13 @@ public: - void Close(); - }; - -+class PopenProcess { -+public: -+ int Pclose(); -+ void Popen(const std::string &cmd); -+ -+ FILE *stream; -+ pid_t pid; -+}; -+ - #endif -diff --git a/src/plugin/collect/system/command/command_collector.cpp b/src/plugin/collect/system/command/command_collector.cpp -index 6c54555..640a406 100644 ---- a/src/plugin/collect/system/command/command_collector.cpp -+++ b/src/plugin/collect/system/command/command_collector.cpp -@@ -32,15 +32,16 @@ CommandCollector::CommandCollector(): oeaware::Interface() - void CommandCollector::CollectThread(const oeaware::Topic &topic, CommandBase* collector) - { - std::string cmd = collector->GetCommand(topic); -- FILE* pipe = popen(cmd.c_str(), "r"); -- if (!pipe) { -+ PopenProcess p; -+ p.Popen(cmd); -+ if (!p.stream) { - return; - } - char buffer[256]; -- while (collector->isRunning && fgets(buffer, sizeof(buffer), pipe) != nullptr) { -+ while (collector->isRunning && fgets(buffer, sizeof(buffer), p.stream) != nullptr) { - collector->ParseLine(std::string(buffer)); - } -- pclose(pipe); -+ p.Pclose(); - - collector->Close(); - } -diff --git a/src/plugin/collect/system/kernel_config.cpp b/src/plugin/collect/system/kernel_config.cpp -index 63aafea..6bdfc8a 100644 ---- a/src/plugin/collect/system/kernel_config.cpp -+++ b/src/plugin/collect/system/kernel_config.cpp -@@ -113,6 +113,7 @@ static bool IsSymlink(const std::string &path) - } - return S_ISLNK(st.st_mode); - } -+ - void KernelConfig::GetAllEth() - { - const std::string path = "/sys/class/net"; -diff --git a/src/plugin_mgr/config.cpp b/src/plugin_mgr/config.cpp -index 341880b..8cd1432 100644 ---- a/src/plugin_mgr/config.cpp -+++ b/src/plugin_mgr/config.cpp -@@ -15,23 +15,6 @@ - #include "default_path.h" - - namespace oeaware { --bool CreateDir(const std::string &path) --{ -- size_t pos = 0; -- do { -- pos = path.find_first_of("/", pos + 1); -- std::string subPath = path.substr(0, pos); -- struct stat buffer; -- if (stat(subPath.c_str(), &buffer) == 0) { -- continue; -- } -- if (mkdir(subPath.c_str(), S_IRWXU | S_IRWXG) != 0) { -- return false; -- } -- } while (pos != std::string::npos); -- return true; --} -- - bool CheckPluginList(YAML::Node pluginListItem) - { - if (pluginListItem["name"].IsNull()) { -diff --git a/src/plugin_mgr/config.h b/src/plugin_mgr/config.h -index 640ab00..19e6d33 100644 ---- a/src/plugin_mgr/config.h -+++ b/src/plugin_mgr/config.h -@@ -130,7 +130,6 @@ private: - }; - - std::string GetPath(); --bool CreateDir(const std::string &path); - } - - #endif -diff --git a/src/plugin_mgr/message_manager.cpp b/src/plugin_mgr/message_manager.cpp -index 1ffa4cc..bfa5b0c 100644 ---- a/src/plugin_mgr/message_manager.cpp -+++ b/src/plugin_mgr/message_manager.cpp -@@ -11,6 +11,7 @@ - ******************************************************************************/ - #include "message_manager.h" - #include -+#include - #include - #include "default_path.h" - #include "utils.h" -@@ -41,15 +42,56 @@ int Epoll::EventWait(struct epoll_event *events, int maxEvents, int timeout) - return epoll_wait(epfd, events, maxEvents, timeout); - } - -+static std::vector GetUserFromGroup(const std::string &groupName) -+{ -+ std::vector users; -+ std::ifstream file("/etc/group"); -+ if (!file.is_open()) { -+ return users; -+ } -+ std::string line; -+ size_t userPartIndex = 3; -+ while (std::getline(file, line)) { -+ std::vector parts = SplitString(line, ":"); -+ if (parts.size() > userPartIndex && parts[0] == groupName) { -+ std::vector userParts = SplitString(parts[userPartIndex], ","); -+ users.insert(users.end(), userParts.begin(), userParts.end()); -+ break; -+ } -+ } -+ file.close(); -+ return users; -+} -+ -+static int GetUid(const std::string &name) -+{ -+ struct passwd pwd; -+ struct passwd *result; -+ char buf[1024]; -+ int res = getpwnam_r(name.c_str(), &pwd, buf, sizeof(buf), &result); -+ if (res != 0 || result == nullptr) { -+ return -1; -+ } -+ return pwd.pw_uid; -+} -+ - void TcpSocket::InitGroups() - { - std::vector groupNames{"oeaware", "root"}; -+ groups[0].emplace_back(0); - for (auto &groupName : groupNames) { - auto gid = GetGidByGroupName(groupName); - if (gid < 0) { - continue; - } -- groups.emplace_back(gid); -+ auto users = GetUserFromGroup(groupName); -+ for (auto &user : users) { -+ auto uid = GetUid(user); -+ if (uid < 0) { -+ continue; -+ } -+ groups[gid].emplace_back(uid); -+ } - } - } - -@@ -68,6 +110,11 @@ bool TcpSocket::StartListen() - ERROR(logger, path << " chmod error!"); - return false; - } -+ std::string cmd = "setfacl -m g:oeaware:rw " + path; -+ auto ret = system(cmd.c_str()); -+ if (ret) { -+ WARN(logger, "failed to set the communication permission of the oeaware user group."); -+ } - if (domainSocket->Listen() < 0) { - ERROR(logger, "listen error!"); - return false; -@@ -136,7 +183,6 @@ static void GetEventResult(Message &msg, EventResultQueue sendMessage) - } - - const int DISCONNECTED = -1; --const int DISCONNECTED_AND_UNSUBCRIBE = -2; - - void TcpMessageHandler::Init(EventQueue newRecvMessage, EventResultQueue newSendMessage, EventQueue newRecvData) - { -@@ -240,6 +286,23 @@ void TcpMessageHandler::Start() - } - } - -+bool TcpSocket::CheckFileGroups(const std::string &path) -+{ -+ struct stat st; -+ if (lstat(path.c_str(), &st) < 0) { -+ return false; -+ } -+ for (auto &p : groups) { -+ bool ok = std::any_of(p.second.begin(), p.second.end(), [&](uid_t uid) { -+ return uid == st.st_uid; -+ }); -+ if (ok) { -+ return true; -+ } -+ } -+ return false; -+} -+ - void TcpSocket::SaveConnection() - { - struct sockaddr_un un; -@@ -255,12 +318,12 @@ void TcpSocket::SaveConnection() - memcpy_s(name, maxNameLength, un.sun_path, len); - name[len] = 0; - bool isSdk = false; -- if (strcmp(name, DEFAULT_SDK_CONN_PATH.c_str()) == 0) { -+ if (len > 0) { - isSdk = true; - } - // check permission -- if (isSdk && !CheckFileGroups(DEFAULT_SDK_CONN_PATH, groups)) { -- WARN(logger, "sdk permission error"); -+ if (isSdk && !CheckFileGroups(name)) { -+ WARN(logger, "sdk permission error, " << name); - return; - } - if (!epoll->EventCtl(EPOLL_CTL_ADD, conn)) { -@@ -274,6 +337,9 @@ void TcpSocket::SaveConnection() - type |= CMD_CONN; - } - tcpMessageHandler.AddConn(conn, type); -+ if (isSdk) { -+ INFO(logger, "a sdk connection is established, " << name); -+ } - DEBUG(logger, "client connected!"); - } - -diff --git a/src/plugin_mgr/message_manager.h b/src/plugin_mgr/message_manager.h -index 38f544d..3c67096 100644 ---- a/src/plugin_mgr/message_manager.h -+++ b/src/plugin_mgr/message_manager.h -@@ -73,12 +73,13 @@ private: - bool StartListen(); - void SaveConnection(); - void HandleEvents(struct epoll_event *events, int num); -+ bool CheckFileGroups(const std::string &path); - private: - log4cplus::Logger logger; - std::unique_ptr domainSocket; - std::unique_ptr epoll; - TcpMessageHandler tcpMessageHandler; -- std::vector groups; -+ std::unordered_map> groups; - const int maxRequestNum = 20; - const int maxNameLength = 108; - }; -diff --git a/src/sdk/oe_client.cpp b/src/sdk/oe_client.cpp -index 9452a37..040433a 100644 ---- a/src/sdk/oe_client.cpp -+++ b/src/sdk/oe_client.cpp -@@ -80,7 +80,17 @@ void Impl::HandleRecv() - } - int Impl::Init() - { -- domainSocket = std::make_shared(DEFAULT_SDK_CONN_PATH); -+ auto home = getenv("HOME"); -+ std::string homeDir; -+ if (home == nullptr) { -+ homeDir = "/var/run/oeAware"; -+ } else { -+ homeDir = home; -+ homeDir += "/.oeaware"; -+ } -+ -+ CreateDir(homeDir); -+ domainSocket = std::make_shared(homeDir + "/oeaware-sdk.sock"); - domainSocket->SetRemotePath(DEFAULT_SERVER_LISTEN_PATH); - resultQueue = std::make_shared>(); - int sock = domainSocket->Socket(); --- -2.33.0 - diff --git a/0004-add-command-verification.patch b/0004-add-command-verification.patch deleted file mode 100644 index 09c7b79c352fb065623529148ccdae9392aa81af..0000000000000000000000000000000000000000 --- a/0004-add-command-verification.patch +++ /dev/null @@ -1,204 +0,0 @@ -From eff9e77d5a695f2ef800c54206dbe0ac11dc0272 Mon Sep 17 00:00:00 2001 -From: fly_1997 -Date: Wed, 27 Nov 2024 10:18:57 +0800 -Subject: [PATCH 4/5] add command verification - ---- - src/plugin/collect/system/CMakeLists.txt | 2 +- - .../collect/system/command/command_base.cpp | 29 ++++++++++--------- - .../collect/system/command/command_base.h | 3 ++ - .../system/command/command_collector.h | 3 +- - src/plugin/collect/system/kernel_config.cpp | 9 ++++++ - src/plugin/collect/system/kernel_config.h | 1 + - src/plugin_mgr/event/subscribe_handler.cpp | 10 ++----- - src/plugin_mgr/instance_run_handler.cpp | 3 +- - 8 files changed, 36 insertions(+), 24 deletions(-) - -diff --git a/src/plugin/collect/system/CMakeLists.txt b/src/plugin/collect/system/CMakeLists.txt -index ee6044f..af4a239 100644 ---- a/src/plugin/collect/system/CMakeLists.txt -+++ b/src/plugin/collect/system/CMakeLists.txt -@@ -1,6 +1,6 @@ - cmake_minimum_required(VERSION 3.11) - project(system_collector) --include_directories(../include) -+include_directories(command) - add_compile_options(-O2 -fPIC -Wall -Wextra) - add_library(system_collector SHARED - thread_collector.cpp -diff --git a/src/plugin/collect/system/command/command_base.cpp b/src/plugin/collect/system/command/command_base.cpp -index bf658b8..e6c0a83 100644 ---- a/src/plugin/collect/system/command/command_base.cpp -+++ b/src/plugin/collect/system/command/command_base.cpp -@@ -10,6 +10,7 @@ - * See the Mulan PSL v2 for more details. - ******************************************************************************/ - #include "command_base.h" -+#include - #include - #include - -@@ -59,23 +60,25 @@ CommandBase::CommandBase() - attrsFirst["vmstat"] = {"swpd"}; - } - -+std::vector CommandBase::command{"mpstat", "iostat", "vmstat", "sar", "pidstat"}; -+std::vector CommandBase::illegal{"|", ";", "&", "$", ">", "<", "`", "\n"}; -+ -+bool CommandBase::ValidateCmd(const std::string &cmd) -+{ -+ for (auto word : illegal) { -+ if (strstr(cmd.c_str(), word.c_str())) { -+ return false; -+ } -+ } -+ return true; -+} -+ - bool CommandBase::ValidateArgs(const oeaware::Topic& topic) - { -- auto cmd = GetCommand(topic); -- PopenProcess p; -- p.Popen(cmd); -- if (!p.stream) { -+ if (std::find(command.begin(), command.end(), topic.topicName) == command.end()) { - return false; - } -- char buffer[128]; -- bool isValid = false; -- if (fgets(buffer, sizeof(buffer), p.stream) != nullptr) { -- if (strstr(buffer, "Linux") != nullptr || strstr(buffer, "procs") != nullptr) { -- isValid = true; -- } -- } -- p.Pclose(); -- return isValid; -+ return ValidateCmd(topic.params); - } - - void CommandBase::ParseLine(const std::string& line) -diff --git a/src/plugin/collect/system/command/command_base.h b/src/plugin/collect/system/command/command_base.h -index a6d7627..ef9bd7c 100644 ---- a/src/plugin/collect/system/command/command_base.h -+++ b/src/plugin/collect/system/command/command_base.h -@@ -35,9 +35,12 @@ public: - oeaware::Topic topic; - std::unordered_map> attrsFirst; - std::vector skipLine{"---swap--"}; -+ static std::vector command; -+ static std::vector illegal; - CommandBase(); - virtual ~CommandBase() = default; - static bool ValidateArgs(const oeaware::Topic& topic); -+ static bool ValidateCmd(const std::string &cmd); - void ParseLine(const std::string& line); - static std::string GetCommand(const oeaware::Topic& topic); - bool FillDataStruct(void* dataStruct); -diff --git a/src/plugin/collect/system/command/command_collector.h b/src/plugin/collect/system/command/command_collector.h -index 26fc7e7..72553e3 100644 ---- a/src/plugin/collect/system/command/command_collector.h -+++ b/src/plugin/collect/system/command/command_collector.h -@@ -27,8 +27,7 @@ public: - void Disable() override; - void Run() override; - private: -- std::vector topicStr = {"mpstat", "iostat", "vmstat", "sar", "pidstat", "lscpu", "zone_reclaim_mode", -- "meminfo", "ethtool", "ifconfig", "os-release", "version"}; -+ std::vector topicStr = {"mpstat", "iostat", "vmstat", "sar", "pidstat"}; - std::unordered_map> collectors; - std::unordered_map collectThreads; - std::unordered_map publishThreads; -diff --git a/src/plugin/collect/system/kernel_config.cpp b/src/plugin/collect/system/kernel_config.cpp -index 6bdfc8a..3d25251 100644 ---- a/src/plugin/collect/system/kernel_config.cpp -+++ b/src/plugin/collect/system/kernel_config.cpp -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include "command_base.h" - - KernelConfig::KernelConfig(): oeaware::Interface() - { -@@ -258,12 +259,20 @@ void KernelConfig::WriteSysParam(const std::string &path, const std::string &val - INFO(logger, "successfully wrote value{" << value <<"} to " << path << "."); - } - -+std::vector KernelConfig::cmdGroup{"sysctl", "ifconfig", "/sbin/blockdev"}; -+ - void KernelConfig::SetKernelConfig() - { - for (auto &p : setSystemParams) { - WriteSysParam(p.first, p.second); - } - for (auto &cmd : cmdRun) { -+ auto cmdParts = oeaware::SplitString(cmd, " "); -+ if (cmdParts.empty() || std::find(cmdGroup.begin(), cmdGroup.end(), cmdParts[0]) == cmdGroup.end() || -+ !CommandBase::ValidateCmd(cmd)) { -+ WARN(logger, "cmd{" << cmd << "} invalid."); -+ continue; -+ } - FILE *pipe = popen(cmd.data(), "r"); - if (!pipe) { - WARN(logger, "{" << cmd << "} run failed."); -diff --git a/src/plugin/collect/system/kernel_config.h b/src/plugin/collect/system/kernel_config.h -index aa96886..32049d4 100644 ---- a/src/plugin/collect/system/kernel_config.h -+++ b/src/plugin/collect/system/kernel_config.h -@@ -62,6 +62,7 @@ private: - std::unordered_map kernelParams; - - std::vector cmdRun; -+ static std::vector cmdGroup; - std::vector allEths; - }; - -diff --git a/src/plugin_mgr/event/subscribe_handler.cpp b/src/plugin_mgr/event/subscribe_handler.cpp -index 8697958..f29b455 100644 ---- a/src/plugin_mgr/event/subscribe_handler.cpp -+++ b/src/plugin_mgr/event/subscribe_handler.cpp -@@ -14,24 +14,20 @@ - namespace oeaware { - Result SubscribeHandler::Subscribe(const std::string &name, const Topic &topic) - { -- Result result; - if (!memoryStore->IsInstanceExist(topic.instanceName)) { - WARN(logger, "The subscribed instance " << topic.instanceName << " does not exist."); -- result.code = -1; -- return result; -+ return Result(FAILED, "instance does not exist."); - } - auto instance = memoryStore->GetInstance(topic.instanceName); - if (!instance->supportTopics.count(topic.topicName)) { - WARN(logger, "The subscribed topic " << topic.topicName << " does not exist."); -- result.code = -1; -- return result; -+ return Result(FAILED, "topic does not exist."); - } - auto msg = std::make_shared(RunType::SUBSCRIBE, - std::vector{topic.GetType(), name}); - instanceRunHandler->RecvQueuePush(msg); - msg->Wait(); -- result = msg->result; -- return result; -+ return msg->result; - } - - EventResult SubscribeHandler::Handle(const Event &event) -diff --git a/src/plugin_mgr/instance_run_handler.cpp b/src/plugin_mgr/instance_run_handler.cpp -index 30dc886..abee581 100644 ---- a/src/plugin_mgr/instance_run_handler.cpp -+++ b/src/plugin_mgr/instance_run_handler.cpp -@@ -61,7 +61,8 @@ Result InstanceRunHandler::Subscribe(const std::vector &payload) - if (!topicState[topic.instanceName][topic.topicName][topic.params]) { - result = instance->interface->OpenTopic(topic); - if (result.code < 0) { -- WARN(logger, "topic open failed, " << result.payload); -+ WARN(logger, "topic{" << LogText(topic.instanceName) << ", " << LogText(topic.topicName) << ", " << -+ LogText(topic.params) << "} open failed, " << result.payload); - DisableInstance(instance->name); - return result; - } --- -2.33.0 - diff --git a/0005-modify-C-interface-name-add-enable-count-and-fix-bug.patch b/0005-modify-C-interface-name-add-enable-count-and-fix-bug.patch deleted file mode 100644 index 270322f049a548e48c019443533c8eedbe800318..0000000000000000000000000000000000000000 --- a/0005-modify-C-interface-name-add-enable-count-and-fix-bug.patch +++ /dev/null @@ -1,233 +0,0 @@ -From 1a84134fbe63c1a7bea679b5696bafd99a1b6666 Mon Sep 17 00:00:00 2001 -From: fly_1997 -Date: Sat, 30 Nov 2024 15:25:03 +0800 -Subject: [PATCH 5/5] modify C interface name, add enable count and fix bugs - ---- - src/client/cmd_handler.cpp | 7 ++++--- - src/client/main.cpp | 4 ++-- - src/plugin_mgr/config.cpp | 5 +++++ - src/plugin_mgr/config.h | 1 + - src/plugin_mgr/event/enable_handler.cpp | 3 +++ - src/plugin_mgr/instance_run_handler.cpp | 3 ++- - src/plugin_mgr/plugin.cpp | 2 +- - src/plugin_mgr/plugin.h | 1 + - src/sdk/oe_client.cpp | 14 +++++++++----- - src/sdk/oe_client.h | 10 +++++----- - 10 files changed, 33 insertions(+), 17 deletions(-) - -diff --git a/src/client/cmd_handler.cpp b/src/client/cmd_handler.cpp -index b1e2ba0..289461b 100644 ---- a/src/client/cmd_handler.cpp -+++ b/src/client/cmd_handler.cpp -@@ -33,7 +33,7 @@ void LoadHandler::Handler(Message &msg) - void LoadHandler::ResHandler(Message &msg) - { - if (msg.opt == Opt::RESPONSE_OK) { -- std::cout << "Plugin loaded successfully."; -+ std::cout << "Plugin loaded successfully.\n"; - } else { - std::cout << "Plugin loaded failed, because "<< msg.payload[0] << ".\n"; - } -@@ -54,9 +54,10 @@ void QueryHandler::PrintFormat() - { - std::cout << "format:\n" - "[plugin]\n" -- "\t[instance]([dependency status], [running status])\n" -+ "\t[instance]([dependency status], [running status], [enable cnt])\n" - "dependency status: available means satisfying dependency, otherwise unavailable.\n" -- "running status: running means that instance is running, otherwise close.\n"; -+ "running status: running means that instance is running, otherwise close.\n" -+ "enable cnt: number of instances enabled.\n"; - } - - void QueryHandler::ResHandler(Message &msg) -diff --git a/src/client/main.cpp b/src/client/main.cpp -index 188d5e2..1c50f1a 100644 ---- a/src/client/main.cpp -+++ b/src/client/main.cpp -@@ -41,8 +41,8 @@ int main(int argc, char *argv[]) - std::string analysis = argv[1]; - if (analysis == "analysis") { - CTopic topic = {"analysis_aware", "analysis_aware", ""}; -- Init(); -- Subscribe(&topic, AnalysisCallback); -+ OeInit(); -+ OeSubscribe(&topic, AnalysisCallback); - std::unique_lock lock(g_mutex); - g_cv.wait(lock, []{ return g_finish; }); - return 0; -diff --git a/src/plugin_mgr/config.cpp b/src/plugin_mgr/config.cpp -index 8cd1432..aee3243 100644 ---- a/src/plugin_mgr/config.cpp -+++ b/src/plugin_mgr/config.cpp -@@ -61,6 +61,10 @@ void Config::SetEnableList(const YAML::Node &node) - std::string pluginName = enableList[i]["name"].as(); - YAML::Node instances = enableList[i]["instances"]; - EnableItem enableItem(pluginName); -+ if (!instances.IsSequence()) { -+ WARN(logger, "the format of the enable list is incorrect."); -+ continue; -+ } - if (!instances.IsDefined() || instances.IsNull()) { - enableItem.SetEnabled(true); - } else { -@@ -75,6 +79,7 @@ void Config::SetEnableList(const YAML::Node &node) - - bool Config::Load(const std::string &path) - { -+ logger = Logger::GetInstance().Get("Main"); - YAML::Node node; - struct stat buffer; - if (stat(path.c_str(), &buffer) != 0) { -diff --git a/src/plugin_mgr/config.h b/src/plugin_mgr/config.h -index 19e6d33..dc02b37 100644 ---- a/src/plugin_mgr/config.h -+++ b/src/plugin_mgr/config.h -@@ -127,6 +127,7 @@ private: - std::string logType; - std::unordered_map pluginList; - std::vector enableList; -+ log4cplus::Logger logger; - }; - - std::string GetPath(); -diff --git a/src/plugin_mgr/event/enable_handler.cpp b/src/plugin_mgr/event/enable_handler.cpp -index 66eba6c..a5d8e1a 100644 ---- a/src/plugin_mgr/event/enable_handler.cpp -+++ b/src/plugin_mgr/event/enable_handler.cpp -@@ -29,6 +29,9 @@ ErrorCode EnableHandler::InstanceEnabled(const std::string &name) - instanceRunHandler->RecvQueuePush(msg); - /* Wait for InstanceRunHandler to finsh this task. */ - msg->Wait(); -+ if (msg->result.code < 0) { -+ return ErrorCode::ENABLE_INSTANCE_ENV; -+ } - return ErrorCode::OK; - } - -diff --git a/src/plugin_mgr/instance_run_handler.cpp b/src/plugin_mgr/instance_run_handler.cpp -index abee581..aa428ff 100644 ---- a/src/plugin_mgr/instance_run_handler.cpp -+++ b/src/plugin_mgr/instance_run_handler.cpp -@@ -26,6 +26,7 @@ Result InstanceRunHandler::EnableInstance(const std::string &name) - return result; - } - instance->enabled = true; -+ instance->enableCnt++; - if (instance->interface->GetType() & SCENARIO) { - scheduleQueue.push(ScheduleInstance{instance, time + instance->interface->GetPeriod()}); - } else if (instance->interface->GetType() & TUNE) { -@@ -196,7 +197,7 @@ bool InstanceRunHandler::HandleMessage() - DEBUG(logger, "handle message " << (int)msg->GetType()); - switch (msg->GetType()) { - case RunType::ENABLED: { -- EnableInstance(msg->payload[0]); -+ msg->result = EnableInstance(msg->payload[0]); - break; - } - case RunType::DISABLED: { -diff --git a/src/plugin_mgr/plugin.cpp b/src/plugin_mgr/plugin.cpp -index 5789737..8b894b6 100644 ---- a/src/plugin_mgr/plugin.cpp -+++ b/src/plugin_mgr/plugin.cpp -@@ -72,6 +72,6 @@ std::string Instance::GetInfo() const - { - std::string stateText = this->state ? pluginStateOn : pluginStateOff; - std::string runText = this->enabled ? pluginEnabled : pluginDisabled; -- return name + "(" + stateText + ", " + runText + ")"; -+ return name + "(" + stateText + ", " + runText + ", count: " + std::to_string(enableCnt) + ")"; - } - } -diff --git a/src/plugin_mgr/plugin.h b/src/plugin_mgr/plugin.h -index ef5fc1d..bf63852 100644 ---- a/src/plugin_mgr/plugin.h -+++ b/src/plugin_mgr/plugin.h -@@ -23,6 +23,7 @@ struct Instance { - std::string pluginName; - bool state = true; - bool enabled; -+ uint64_t enableCnt = 0; - std::shared_ptr interface; - std::unordered_map supportTopics; - const static std::string pluginEnabled; -diff --git a/src/sdk/oe_client.cpp b/src/sdk/oe_client.cpp -index 040433a..a9f82ef 100644 ---- a/src/sdk/oe_client.cpp -+++ b/src/sdk/oe_client.cpp -@@ -22,6 +22,7 @@ - namespace oeaware { - class Impl { - public: -+ Impl() noexcept : domainSocket(nullptr), socketStream(nullptr) { } - int Init(); - int Subscribe(const CTopic &topic, Callback callback); - int Unsubscribe(const CTopic &topic); -@@ -114,6 +115,9 @@ int Impl::Init() - int Impl::HandleRequest(const Opt &opt, const std::vector &payload) - { - MessageProtocol protocol(MessageHeader(MessageType::REQUEST), Message(opt, payload)); -+ if (socketStream == nullptr) { -+ return -1; -+ } - SendMessage(*socketStream, protocol); - Result result; - if (!resultQueue->WaitTimeAndPop(result)) { -@@ -166,28 +170,28 @@ void Impl::Close() - - static oeaware::Impl impl; - --int Init() -+int OeInit() - { - oeaware::Register::GetInstance().InitRegisterData(); - return impl.Init(); - } - --int Subscribe(const CTopic *topic, Callback callback) -+int OeSubscribe(const CTopic *topic, Callback callback) - { - return impl.Subscribe(*topic, callback); - } - --int Unsubscribe(const CTopic *topic) -+int OeUnsubscribe(const CTopic *topic) - { - return impl.Unsubscribe(*topic); - } - --int Publish(const DataList *dataList) -+int OePublish(const DataList *dataList) - { - return impl.Publish(*dataList); - } - --void Close() -+void OeClose() - { - impl.Close(); - } -diff --git a/src/sdk/oe_client.h b/src/sdk/oe_client.h -index 17d8e68..267462c 100644 ---- a/src/sdk/oe_client.h -+++ b/src/sdk/oe_client.h -@@ -16,11 +16,11 @@ - extern "C" { - #endif - typedef int(*Callback)(const DataList *); --int Init(); --int Subscribe(const CTopic *topic, Callback callback); --int Unsubscribe(const CTopic *topic); --int Publish(const DataList *dataList); --void Close(); -+int OeInit(); -+int OeSubscribe(const CTopic *topic, Callback callback); -+int OeUnsubscribe(const CTopic *topic); -+int OePublish(const DataList *dataList); -+void OeClose(); - #ifdef __cplusplus - } - #endif --- -2.33.0 - diff --git a/0006-add-one-time-command-collection.patch b/0006-add-one-time-command-collection.patch deleted file mode 100644 index 00088697c1dfc85c73828b0119b584c658f9743e..0000000000000000000000000000000000000000 --- a/0006-add-one-time-command-collection.patch +++ /dev/null @@ -1,510 +0,0 @@ -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 deleted file mode 100644 index 5838edf471af40bc0f151d2402139a01e73788d7..0000000000000000000000000000000000000000 --- a/0007-fix-bug-free-spe-mem-after-use-data.patch +++ /dev/null @@ -1,135 +0,0 @@ -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 deleted file mode 100644 index 93ad3d3125842d04d09f5a3513aa7b7cf81b775f..0000000000000000000000000000000000000000 --- a/0008-Adjust-the-header-file-structure.patch +++ /dev/null @@ -1,2007 +0,0 @@ -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 deleted file mode 100644 index 18a6c4a2107b3b34b31ba722af98a82de5fe4c0c..0000000000000000000000000000000000000000 --- a/0009-cycles-sample-add-elf-resolve-to-support-d-fot.patch +++ /dev/null @@ -1,24 +0,0 @@ -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-v2.0.0.tar.gz b/oeAware-manager-v2.0.0.tar.gz deleted file mode 100644 index b09136685a2a062ad693ab4b8791cdda0ec468dd..0000000000000000000000000000000000000000 Binary files a/oeAware-manager-v2.0.0.tar.gz and /dev/null differ diff --git a/oeAware-manager-v2.0.1.tar.gz b/oeAware-manager-v2.0.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..efff6bfaf3e0884c0f2aec30ebe1220241e3849e Binary files /dev/null and b/oeAware-manager-v2.0.1.tar.gz differ diff --git a/oeAware-manager.spec b/oeAware-manager.spec index 5dd9ae2b88fca6559dc21ecc1f9cc30750641013..32c67d10bd8986e9723cb5a1fcfea2ee5f8d34de 100644 --- a/oeAware-manager.spec +++ b/oeAware-manager.spec @@ -1,35 +1,28 @@ Name: oeAware-manager -Version: v2.0.0 -Release: 3 +Version: v2.0.1 +Release: 1 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 -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 +Patch1: 0001-change-the-folder-permission-to-755-add-oeaware-grou.patch BuildRequires: cmake make gcc-c++ BuildRequires: boost-devel BuildRequires: curl-devel BuildRequires: log4cplus-devel BuildRequires: yaml-cpp-devel -BuildRequires: gtest-devel gmock-devel BuildRequires: libboundscheck %ifarch aarch64 BuildRequires: libkperf libkperf-devel +Requires: libkperf %endif BuildRequires: libnl3 libnl3-devel BuildRequires: numactl-devel BuildRequires: kernel-devel Requires: graphviz yaml-cpp curl log4cplus boost systemd libboundscheck Requires: libnl3 acl +Requires: sysstat Obsoletes: oeAware-collector < v2.0.0 Obsoletes: oeAware-scenario < v2.0.0 @@ -64,17 +57,22 @@ 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/oeaware/*.h %{buildroot}%{_includedir}/oeaware -install -b -m740 ./build/output/include/oeaware/data/*.h %{buildroot}%{_includedir}/oeaware/data +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/ +install -D -m 0640 ./build/output/plugin/lib/xcall.yaml %{buildroot}%{_libdir}/oeAware-plugin/ install -D -m 0400 ./build/output/plugin/ko/smc_acc.ko %{buildroot}%{_prefix}/lib/smc %preun %systemd_preun oeaware.service %post +if ! grep -q "oeaware:" /etc/group; then + groupadd oeaware + setfacl -m g:oeaware:r /usr/lib64/liboeaware-sdk.so +fi systemctl start oeaware.service chcon -t modules_object_t %{_prefix}/lib/smc/smc_acc.ko >/dev/null 2>&1 exit 0 @@ -85,10 +83,6 @@ if [ "${VERSION}" == "22.03 (LTS-SP4)" ]; then systemctl enable oeaware.service fi -if ! grep -q "oeaware:" /etc/group; then - groupadd oeaware -fi - %files %attr(0750, root, root) %{_bindir}/oeaware %attr(0750, root, root) %{_bindir}/oeawarectl @@ -96,6 +90,7 @@ fi %attr(0644, root, root) %{_unitdir}/oeaware.service %attr(0640, root, root) %{_libdir}/oeAware-plugin/ub_tune.conf %attr(0640, root, root) %{_libdir}/oeAware-plugin/thread_scenario.conf +%attr(0640, root, root) %{_libdir}/oeAware-plugin/xcall.yaml %attr(0400, root, root) %{_prefix}/lib/smc/smc_acc.ko %attr(0440, root, root) %{_libdir}/oeAware-plugin/*.so %attr(0440, root, root) %{_libdir}/liboeaware-sdk.so @@ -105,8 +100,15 @@ fi %attr(0644, root, root) %{_includedir}/oeaware/data/*.h %changelog +* Wed Dec 11 2024 LHesperus -v2.0.1-1 +- add some document +- fix bug : spe period dynamic changes +- fix bug : analysis client not work +- fix bug : cpuburst exit error +- adapt : seep tune , steal task tune, xcall tune + * Fri Dec 6 2024 fly_1997 -v2.0.0-3 -- adjust the header file structure +- adjust the header file structure - fix cycles sample, spe memory free - add one time command collection