public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] /proc/uptime on SMP machines
@ 2001-03-17 23:30 Uwe Bonnes
  2001-03-18  3:26 ` Tim Moore
  2001-03-18  3:41 ` Tim Moore
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Bonnes @ 2001-03-17 23:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: bon

Hallo,

I didn't see a maintainer for the /proc filesystem, to I send this mail to
linux-kernel for discussion. 

At present the idle value in /proc/uptime is only the idle time for the first
processor. With 2.4, processes seam "stickier" for my, and e.g "yes
>/dev/null" on an otherwise idle machine can stay for a long time on one
processor of my (intel) SMP machine. That way, the present output of
/proc/uptime can lead to a wrong conclusion.

Appended patch returns the average of all idle processes an all
processors. 

If I don't hear back, I will send to Linus and Alan for inclusion.

Bye

Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Free Software: If you contribute nothing, expect nothing
--

--- linux-2.4.2.SuSE/fs/proc/proc_misc.c	Thu Mar 15 16:48:04 2001
+++ linux-2.4.2.SuSE-5/fs/proc/proc_misc.c	Sat Mar 17 23:11:47 2001
@@ -105,11 +105,15 @@
 {
 	unsigned long uptime;
 	unsigned long idle;
-	int len;
+	int len,i;
 
 	uptime = jiffies;
+#ifdef CONFIG_SMP
+	for (idle =0,i = 0; i < smp_num_cpus; i++)
+	    idle += (init_tasks[i]->times.tms_utime + init_tasks[i]->times.tms_stime)/smp_num_cpus;
+#else
 	idle = init_tasks[0]->times.tms_utime + init_tasks[0]->times.tms_stime;
-
+#endif
 	/* The formula for the fraction parts really is ((t * 100) / HZ) % 100, but
 	   that would overflow about every five days at HZ == 100.
 	   Therefore the identity a = (a / b) * b + a % b is used so that it is

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] /proc/uptime on SMP machines
  2001-03-17 23:30 [PATCH] /proc/uptime on SMP machines Uwe Bonnes
@ 2001-03-18  3:26 ` Tim Moore
  2001-03-18  3:41 ` Tim Moore
  1 sibling, 0 replies; 4+ messages in thread
From: Tim Moore @ 2001-03-18  3:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Uwe Bonnes

> At present the idle value in /proc/uptime is only the idle time for the first
> processor. With 2.4, processes seam "stickier" for my, and e.g "yes
> >/dev/null" on an otherwise idle machine can stay for a long time on one
> processor of my (intel) SMP machine. That way, the present output of
> /proc/uptime can lead to a wrong conclusion.

Same for 2.2.19p17

[tim@smp ~]# cat /proc/uptime
19262.25 18487.44
[tim@smp ~]# cat /proc/stat | grep cpu
cpu  108661 0 24741 3719438
cpu0 65697 0 11814 1848909
cpu1 42964 0 12927 1870529

--- 2.2.19pre17/fs/proc/array.c Fri Mar 16 04:09:41 2001
+++ 2.2.19pre17/fs/proc/array.c.idle    Sat Mar 17 19:20:22 2001
@@ -339,9 +339,16 @@
 {
        unsigned long uptime;
        unsigned long idle;
+       int i;
 
        uptime = jiffies;
+#ifdef CONFIG_SMP
+       for (idle =0,i = 0; i < smp_num_cpus; i++)
+       idle += (init_tasks[i]->times.tms_utime +
+               init_tasks[i]->times.tms_stime)/smp_num_cpus;
+#else
        idle = task[0]->times.tms_utime + task[0]->times.tms_stime;
+#endif
 
        /* The formula for the fraction parts really is ((t * 100) / HZ)
% 100, but
           that would overflow about every five days at HZ == 100.


--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] /proc/uptime on SMP machines
  2001-03-17 23:30 [PATCH] /proc/uptime on SMP machines Uwe Bonnes
  2001-03-18  3:26 ` Tim Moore
@ 2001-03-18  3:41 ` Tim Moore
  2001-03-18  4:46   ` Tim Moore
  1 sibling, 1 reply; 4+ messages in thread
From: Tim Moore @ 2001-03-18  3:41 UTC (permalink / raw)
  To: Uwe Bonnes; +Cc: linux-kernel

> Same for 2.2.19p17

except that init_tasks is a 2.4 struc.  Corrected as below.

rgds,
tim

--- 2.2.19pre17/fs/proc/array.c.old     Fri Mar 16 04:09:41 2001
+++ 2.2.19pre17/fs/proc/array.c.idle    Sat Mar 17 19:35:36 2001
@@ -339,9 +339,16 @@
 {
        unsigned long uptime;
        unsigned long idle;
+       int i;
 
        uptime = jiffies;
+#ifdef CONFIG_SMP
+       for (idle =0,i = 0; i < smp_num_cpus; i++)
+       idle += (task[i]->times.tms_utime +
+               task[i]->times.tms_stime)/smp_num_cpus;
+#else
        idle = task[0]->times.tms_utime + task[0]->times.tms_stime;
+#endif
 
        /* The formula for the fraction parts really is ((t * 100) / HZ) % 100, but
           that would overflow about every five days at HZ == 100.

--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] /proc/uptime on SMP machines
  2001-03-18  3:41 ` Tim Moore
@ 2001-03-18  4:46   ` Tim Moore
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Moore @ 2001-03-18  4:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: Uwe Bonnes

The patch works on 2.2.19pre17.  The second machine (asus) has Uwe's patch modified for 2.2.  The
machine 'smp' is not patched.

rgds,
tim.

[tim@smp ~]# cat /proc/uptime ; cat /proc/stat | grep cpu ; yes > /dev/null & ; sleep 180 ; killall
yes ; cat /proc/uptime ; cat /proc/stat | grep cpu
[2] 1485
22689.88 21324.40
cpu  175685 0 32321 4329972
cpu0 121396 0 15195 2132398
cpu1 54289 0 17126 2197574
Terminated
22869.90 21324.40
cpu  193551 0 33066 4347365
cpu0 139179 0 15414 2132398
cpu1 54372 0 17652 2214967
[2]  - Exit 143                      ( cat /proc/uptime; cat /proc/stat | grep cpu; yes > /dev/null
)

[tim@asus ~]# date ; cat /proc/uptime ; cat /proc/stat | grep cpu ; yes > /dev/null & ; sleep 180 ;
killall yes ; cat /proc/uptime ; cat /proc/stat | grep cpu
[1] 870
Sat Mar 17 20:41:49 PST 2001
3260.19 2337.13
cpu  174676 0 9849 467515
cpu0 90385 0 4666 230969
cpu1 84291 0 5183 236546
Terminated
3440.20 2424.73
cpu  192352 0 10656 485034
cpu0 108059 0 4992 230970
cpu1 84293 0 5664 254064
[1]  + Exit 143                      ( date; cat /proc/uptime; cat /proc/stat | grep cpu; yes >
/dev/null )
[tim@asus ~]# cat /proc/version
Linux version 2.2.19pre17 (root@asus) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release))
#5 SMP Sat Mar 17 19:44:42 PST 2001

--

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-03-18  4:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-17 23:30 [PATCH] /proc/uptime on SMP machines Uwe Bonnes
2001-03-18  3:26 ` Tim Moore
2001-03-18  3:41 ` Tim Moore
2001-03-18  4:46   ` Tim Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox