[sblim-cmpi-base] Fix incorrect max cpu frequency
vcrhonek
vcrhonek at fedoraproject.org
Thu Jun 6 14:08:24 UTC 2013
commit 4dd24b2fc1aa7bb8dfebd74ebbf4136d56d150bb
Author: Vitezslav Crhonek <vcrhonek at redhat.com>
Date: Thu Jun 6 16:08:05 2013 +0200
Fix incorrect max cpu frequency
sblim-cmpi-base-1.6.2-max-cpu-frequency.patch | 64 +++++++++++++++++++++++++
sblim-cmpi-base.spec | 8 +++-
2 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/sblim-cmpi-base-1.6.2-max-cpu-frequency.patch b/sblim-cmpi-base-1.6.2-max-cpu-frequency.patch
new file mode 100644
index 0000000..9935d11
--- /dev/null
+++ b/sblim-cmpi-base-1.6.2-max-cpu-frequency.patch
@@ -0,0 +1,64 @@
+diff --git a/OSBase_Processor.c b/OSBase_Processor.c
+index 9556a77..bae0e32 100644
+--- a/OSBase_Processor.c
++++ b/OSBase_Processor.c
+@@ -36,8 +36,9 @@ static int _processor_data( int, struct cim_processor ** );
+ static unsigned short _processor_family( int );
+ static unsigned short _processor_load_perc( int );
+
+ char * CPUINFO = "/proc/cpuinfo";
++char * CPUMAXFREQ = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
+
+ //char * CPUINFO = "/home/heidineu/local/sblim/cmpi-base-cpuinfo/x86_ibm_xSeries_2x";
+ //char * CPUINFO = "/home/heidineu/local/sblim/cmpi-base-cpuinfo/x86_ibm_xSeries_4x";
+ //char * CPUINFO = "/home/heidineu/local/sblim/cmpi-base-cpuinfo/x86_64_AMD";
+@@ -246,8 +247,11 @@ static int _processor_data( int id, struct cim_processor ** sptr ) {
+ char * ptr = NULL;
+ int count = 0;
+ int lines = 0;
+ int rc = 0;
++ char * maxcpufreq = NULL;
++ unsigned long maxMHz = 0;
++ FILE *fp;
+
+ _OSBASE_TRACE(4,("--- _processor_data() called"));
+
+ count = id;
+@@ -345,8 +349,20 @@ static int _processor_data( int id, struct cim_processor ** sptr ) {
+ cmd = (char *)malloc((strlen(CPUINFO)+64));
+ strcpy(cmd, "cat ");
+ strcat(cmd, CPUINFO);
+ #if defined (INTEL) || defined (X86_64) || defined (IA64)
++ /* if /sys/devices/system/cpu/cpu(id]/cpufreq/cpuinfo_max_freq exists */
++ /* then calculate MaxClockSpeed from there, otherwise the cpufreq module */
++ /* is not loaded, and /proc/cpuinfo always shows maximum speed */
++ maxcpufreq = malloc((strlen(CPUMAXFREQ)+5));
++ sprintf(maxcpufreq, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", id);
++ if ((fp = fopen(maxcpufreq, "r")) > 0) {
++ if (1 == fscanf(fp, "%lu", &maxMHz)) {
++ maxMHz = maxMHz / 1000;
++ _OSBASE_TRACE(3,("--- _processor_data() maxMHz = %lu", maxMHz));
++ }
++ fclose(fp);
++ }
+ strcat(cmd, " | grep 'cpu MHz'");
+ rc = runcommand( cmd, NULL, &hdout, NULL );
+ #elif defined (S390) || defined (MIPS)
+ rc = 0; /* clock speed cannot be determined on zSeries or mips */
+@@ -379,11 +395,15 @@ static int _processor_data( int id, struct cim_processor ** sptr ) {
+ ptr = strchr( hdout[id], ':');
+ #endif
+ ptr = ptr+1;
+ (*sptr)->curClockSpeed = atol(ptr);
+- (*sptr)->maxClockSpeed = atol(ptr);
++ if (maxMHz > 0)
++ (*sptr)->maxClockSpeed = maxMHz;
++ else
++ (*sptr)->maxClockSpeed = atol(ptr);
+ }
+ freeresultbuf(hdout);
++ if (maxcpufreq) free(maxcpufreq);
+ if(cmd) free(cmd);
+
+ _OSBASE_TRACE(4,("--- _processor_data() exited"));
+ return 0;
diff --git a/sblim-cmpi-base.spec b/sblim-cmpi-base.spec
index caa7be5..0beddbf 100644
--- a/sblim-cmpi-base.spec
+++ b/sblim-cmpi-base.spec
@@ -1,6 +1,6 @@
Name: sblim-cmpi-base
Version: 1.6.2
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: SBLIM CMPI Base Providers
Group: Applications/System
@@ -11,6 +11,8 @@ Patch0: sblim-cmpi-base-1.6.0-missing-fclose.patch
Patch1: sblim-cmpi-base-1.6.0-methods-enable.patch
Patch2: sblim-cmpi-base-1.6.0-provider-register-sfcb-init.patch
Patch3: sblim-cmpi-base-1.6.1-double-fclose.patch
+# Patch4: already upstream, http://sourceforge.net/p/sblim/bugs/2634/
+Patch4: sblim-cmpi-base-1.6.2-max-cpu-frequency.patch
Requires: cim-server sblim-indication_helper
BuildRequires: sblim-cmpi-devel sblim-indication_helper-devel
@@ -47,6 +49,7 @@ Testcase Files for the SBLIM Testsuite.
%patch1 -p0 -b .methods-enable
%patch2 -p1 -b .provider-register-sfcb-init
%patch3 -p1 -b .double-fclose
+%patch4 -p1 -b .cpu-freq
%build
%configure TESTSUITEDIR=%{_datadir}/sblim-testsuite --disable-static
@@ -176,6 +179,9 @@ fi
%postun -p /sbin/ldconfig
%changelog
+* Thu Jun 06 2013 Vitezslav Crhonek <vcrhonek at redhat.com> - 1.6.2-3
+- Fix incorrect max cpu frequency
+
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
More information about the scm-commits
mailing list