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

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