fix log while not supporting pmu uncore

(cherry picked from commit 27b1a2a9f88db276079d6a914022b5e14d625981)
This commit is contained in:
zhoukaiqi 2024-04-29 17:36:57 +08:00 committed by openeuler-sync-bot
parent 7fa4f82ed5
commit edcd68ad00
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,54 @@
From e51951c9f047962a2dc1d6a1c0fe1407bafebe81 Mon Sep 17 00:00:00 2001
From: zhoukaiqi <zhoukaiqi@huawei.com>
Date: Mon, 29 Apr 2024 16:57:00 +0800
Subject: [PATCH] fix log while not supporting pmu uncore
---
pmu/plugin/plugin_uncore.c | 8 ++++++--
pmu/plugin/pmu_uncore.c | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/pmu/plugin/plugin_uncore.c b/pmu/plugin/plugin_uncore.c
index 007e72d..2042d16 100644
--- a/pmu/plugin/plugin_uncore.c
+++ b/pmu/plugin/plugin_uncore.c
@@ -45,9 +45,14 @@ static int uncore_open()
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("hha init failed\n");
+ printf("This system not support pmu_uncore\n");
return pd;
}
@@ -76,7 +81,6 @@ static int uncore_open()
return pd;
}
- uncore_is_open = true;
return pd;
}
diff --git a/pmu/plugin/pmu_uncore.c b/pmu/plugin/pmu_uncore.c
index 0d1506c..56b9190 100644
--- a/pmu/plugin/pmu_uncore.c
+++ b/pmu/plugin/pmu_uncore.c
@@ -97,7 +97,7 @@ int hha_uncore_config_init(void)
struct dirent **namelist;
hha_num = scandir(DEVICE_PATH, &namelist, hha_scandir_select, alphasort);
- if (hha_num < 0) {
+ if (hha_num <= 0) {
printf("scandir failed\n");
return -1;
}
--
2.27.0

View File

@ -1,10 +1,11 @@
Name: oeAware-collector
Version: v1.0.0
Release: 2
Release: 3
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-fix-log-while-not-supporting-pmu-uncore.patch
%global libkperf_name libkperf
%global libkperf_tagver v1.0
@ -79,6 +80,9 @@ install -b -m740 ./thread_collector/build/libthread_collector.so ${RPM_BUIL
%attr(0440, root, root) %{_libdir}/oeAware-plugin/collector/*.so
%changelog
* Mon Apr 29 2024 zhoukaiqi<zhoukaiqi@huawei.com> - v1.0.0-3
- fix log while not supporting pmu uncore
* Thu Apr 18 2024 liuchanggeng<liuchanggeng@huawei.com> - v1.0.0-2
- add debug package