From 4a8ee7c2f7f48f77684c01f0e013857c236885b9 Mon Sep 17 00:00:00 2001 From: zhoukaiqi Date: Fri, 5 Jul 2024 16:52:53 +0800 Subject: [PATCH] fix uninitialized PmuAttr attr (cherry picked from commit 0f5061e2c5a23efd154ae5b4a8dbd7fe5d47c38d) --- 0003-fix-uninitialized-PmuAttr-attr.patch | 121 ++++++++++++++++++++++ oeAware-collector.spec | 8 +- 2 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 0003-fix-uninitialized-PmuAttr-attr.patch diff --git a/0003-fix-uninitialized-PmuAttr-attr.patch b/0003-fix-uninitialized-PmuAttr-attr.patch new file mode 100644 index 0000000..4c9c244 --- /dev/null +++ b/0003-fix-uninitialized-PmuAttr-attr.patch @@ -0,0 +1,121 @@ +From 44bdefe0ef52ead10b51333d940d3adc45d60420 Mon Sep 17 00:00:00 2001 +From: zhoukaiqi +Date: Fri, 5 Jul 2024 15:53:36 +0800 +Subject: [PATCH] fix uninitialized PmuAttr attr + +--- + pmu/plugin/plugin_counting.c | 3 +++ + pmu/plugin/plugin_netif_rx.c | 3 +++ + pmu/plugin/plugin_sampling.c | 3 +++ + pmu/plugin/plugin_spe.c | 3 +++ + pmu/plugin/plugin_uncore.c | 3 +++ + 5 files changed, 15 insertions(+) + +diff --git a/pmu/plugin/plugin_counting.c b/pmu/plugin/plugin_counting.c +index b0de581..39573fa 100644 +--- a/pmu/plugin/plugin_counting.c ++++ b/pmu/plugin/plugin_counting.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include "pmu.h" + #include "pcerrc.h" + #include "interface.h" +@@ -50,6 +51,8 @@ static int counting_open() + char *evtList[1]; + int pd; + ++ (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); ++ + evtList[0] = "cycles"; + + attr.evtList = evtList; +diff --git a/pmu/plugin/plugin_netif_rx.c b/pmu/plugin/plugin_netif_rx.c +index 717f091..78f52d2 100644 +--- a/pmu/plugin/plugin_netif_rx.c ++++ b/pmu/plugin/plugin_netif_rx.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include "pmu.h" + #include "pcerrc.h" + #include "interface.h" +@@ -49,6 +50,8 @@ static int open() + char *evtList[1]; + int pd; + ++ (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); ++ + evtList[0] = "net:netif_rx"; + + attr.evtList = evtList; +diff --git a/pmu/plugin/plugin_sampling.c b/pmu/plugin/plugin_sampling.c +index 2c9fc5c..35e5dfb 100644 +--- a/pmu/plugin/plugin_sampling.c ++++ b/pmu/plugin/plugin_sampling.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include "pmu.h" + #include "pcerrc.h" + #include "interface.h" +@@ -50,6 +51,8 @@ static int sampling_open() + char *evtList[1]; + int pd; + ++ (void)memset_s(&attr, sizeof(struct PmuAttr), 0, sizeof(struct PmuAttr)); ++ + evtList[0] = "cycles"; + + attr.evtList = evtList; +diff --git a/pmu/plugin/plugin_spe.c b/pmu/plugin/plugin_spe.c +index da7f926..52c31c3 100644 +--- a/pmu/plugin/plugin_spe.c ++++ b/pmu/plugin/plugin_spe.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include "pmu.h" + #include "pcerrc.h" + #include "interface.h" +@@ -49,6 +50,8 @@ 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; +diff --git a/pmu/plugin/plugin_uncore.c b/pmu/plugin/plugin_uncore.c +index 4e4cea5..9b845db 100644 +--- a/pmu/plugin/plugin_uncore.c ++++ b/pmu/plugin/plugin_uncore.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include "pmu.h" + #include "pcerrc.h" + #include "interface.h" +@@ -78,6 +79,8 @@ static int uncore_open() + 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; +-- +2.27.0 + diff --git a/oeAware-collector.spec b/oeAware-collector.spec index fb6606e..d81a276 100644 --- a/oeAware-collector.spec +++ b/oeAware-collector.spec @@ -1,12 +1,13 @@ Name: oeAware-collector Version: v1.0.2 -Release: 5 +Release: 6 Summary: %{name} provides low-overhead metrics collection capabilities, including microarchitecture, system, and kernel information. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz Patch1: 0001-add-netif_rx-counting-pmu-instance.patch -Patch2: 0002-reduce-thread-collector-load.patch +Patch2: 0002-reduce-thread-collector-load.patch +Patch3: 0003-fix-uninitialized-PmuAttr-attr.patch %global libkperf_name libkperf %global libkperf_tagver v1.0.4 @@ -82,6 +83,9 @@ install -b -m740 ./thread_collector/build/libthread_collector.so ${RPM_BUIL %attr(0440, root, root) %{_libdir}/oeAware-plugin/libthread_collector.so %changelog +* Fri Jul 5 2024 zhoukaiqi - v1.0.2-6 +- fix uninitialized PmuAttr attr + * Tue Jul 2 2024 fly_1997 - v1.0.2-5 - reduce thread collector load -- Gitee