Re: [PATCH] /proc/uptime on SMP machines

Tim Moore (timothymoore@bigfoot.com)
Sat, 17 Mar 2001 19:26:50 -0800


> 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.

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/