Bug 17391 - procinfo fails to calculate cpu percentages with long uptimes
procinfo fails to calculate cpu percentages with long uptimes
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: procinfo (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-09-10 01:41 EDT by jlewis
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-09-10 01:41:50 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description jlewis 2000-09-10 01:41:45 EDT
When uptime gets too high, procinfo displays 0.0% cpu related times...i.e.

Bootup: Thu Dec  2 12:52:02 1999    Load average: 0.00 0.00 0.00 1/67 3835

user  :  26d  5:07:18.21   0.0%  page in :258489789  disk 1:
11483638r80045744w
nice  :   1d 14:19:40.94   0.0%  page out:230660802  disk 2:
23483083r74082972w
system:   1d 23:17:29.24   0.0%  swap in :  1100327
idle  : 252d 17:04:27.09   0.0%  swap out:   215335
uptime: 282d 11:48:55.46         context :2362517450

This is broken in at least Red Hat i386 5.2 - 6.2 (procinfo-14 -
procinfo-17)...I haven't looked at older versions or other platforms.  The
fix is pretty simple.

--- procinfo-17.orig/procinfo.c Sat May 15 18:16:23 1999
+++ procinfo-17/procinfo.c      Sun Sep 10 01:14:38 2000
@@ -85,7 +85,7 @@
 static void
 first_page (long sl)
 {
-    long elapsed;
+    unsigned long elapsed;   
     char loadavg[32];
     int i;
     int have_m_c = 0;
--- procinfo-17.orig/procinfo.h Sat May 15 18:16:23 1999
+++ procinfo-17/procinfo.h      Sun Sep 10 01:12:38 2000
@@ -94,7 +94,7 @@
 char *make_version (FILE *verionfp);
 FILE *myfopen (char *name);  
 char *hms (unsigned long t); 
-char *perc (unsigned long i, long t, int cpus);
+char *perc (unsigned long i, unsigned long t, int cpus);

 #endif /* _PROCINFO_H */
--- procinfo-17.orig/routines.c Sat May 15 18:16:23 1999
+++ procinfo-17/routines.c      Sun Sep 10 01:12:25 2000
@@ -408,7 +408,7 @@

 /* Note: we're using a static char array, so use this only once per
printf. */
 char *
-perc (unsigned long i, long t, int cpus)
+perc (unsigned long i, unsigned long t, int cpus)
 {
     unsigned int v;
     static char buf[16];

With these changes:

Bootup: Thu Dec  2 12:52:02 1999    Load average: 0.00 0.00 0.00 1/67 3836

user  :  26d  5:07:19.22   9.3%  page in :258489789  disk 1:
11483638r80045825w
nice  :   1d 14:19:41.05   0.6%  page out:230660943  disk 2:
23483083r74083022w
system:   1d 23:17:29.32   0.7%  swap in :  1100327
idle  : 252d 17:04:58.13  89.5%  swap out:   215335
uptime: 282d 11:49:27.71         context :2362518682
Comment 1 Bernhard Rosenkraenzer 2000-10-01 19:10:43 EDT
This fix just doubles the uptime before the same problem occurs...
But that's better than nothing, I guess. ;)
I've applied your patch.

Note You need to log in before you can comment on or make changes to this bug.