From: Dave H. <hel...@us...> - 2013-05-28 19:06:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "cmpi-base - Base OS CMPI Providers". The branch, master has been updated via aa228b9cfa96962488afffb662064db0f72b5f84 (commit) from 2b454ef0a824ded1dadbd61c407a3417d035e9bb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aa228b9cfa96962488afffb662064db0f72b5f84 Author: Dave Heller <hel...@us...> Date: Tue May 28 15:01:49 2013 -0400 Fixed SBLIM-2634: incorrect max cpu frequency ----------------------------------------------------------------------- Summary of changes: ChangeLog | 7 +++++++ NEWS | 6 ++++++ OSBase_Processor.c | 22 +++++++++++++++++++++- contributions.txt | 3 +++ 4 files changed, 37 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 031efce..319921a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-05-28 Dave Heller <hel...@us...> + + * NEWS, contributions.txt, OSBase_Processor.c: + + Fixed SBLIM-2634: incorrect max cpu frequency + (patch by Henning Sackewitz) + 2012-11-02 Tyrel Datwyler <ty...@us...> * NEWS, OSBase_UnixProcess.c: diff --git a/NEWS b/NEWS index 56f3383..dc4e3cd 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +Changes in Version 1.6.3 +======================== + +Bugs Fixed: +- SBLIM-2634: incorrect max cpu frequency + Changes in Version 1.6.2 ======================== diff --git a/OSBase_Processor.c b/OSBase_Processor.c index 9556a77..bae0e32 100644 --- a/OSBase_Processor.c +++ b/OSBase_Processor.c @@ -37,6 +37,7 @@ 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"; @@ -247,6 +248,9 @@ static int _processor_data( int id, struct cim_processor ** sptr ) { int count = 0; int lines = 0; int rc = 0; + char * maxcpufreq = NULL; + unsigned long maxMHz = 0; + FILE *fp; _OSBASE_TRACE(4,("--- _processor_data() called")); @@ -346,6 +350,18 @@ static int _processor_data( int id, struct cim_processor ** sptr ) { 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) @@ -380,9 +396,13 @@ static int _processor_data( int id, struct cim_processor ** sptr ) { #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")); diff --git a/contributions.txt b/contributions.txt index 28676f9..3d674be 100644 --- a/contributions.txt +++ b/contributions.txt @@ -22,3 +22,6 @@ Michal Hrušecký, Novell ----------------------- 08/25/2009 [ 2843613 ] Missing fclose in sblim-cmpi-base +Henning Sackewitz, +----------------------- +05/28/2013 [ SBLIM-2634 ] incorrect max cpu frequency hooks/post-receive -- cmpi-base - Base OS CMPI Providers |