Re: [PATCH] Re: /proc/uptime idle counter remains at 0

From: Martin Schwidefsky
Date: Mon May 11 2009 - 04:10:52 EST


On Mon, 11 May 2009 09:42:03 +0200 (CEST)
Jan Engelhardt <jengelh@xxxxxxxxxx> wrote:

>
> On Monday 2009-05-11 09:35, Martin Schwidefsky wrote:
> >> I have to confess I don't really understand the logic of what's going on
> >> here -- in particular, what does the idle process do other than account
> >> for time when the processor has nothing useful to do? It does seem to me
> >> now that the .utime and .stime fields are now less than useful -- maybe
> >> they can be deleted now?
> >
> >The idle task does not just sleep, it will do "real" work, e.g. softirq
> >handling for interrupts / network traffic.
>
> With an RT kernel, SIRQ and such are separate tasks. That should also
> be play a role while 0 is displayed.

With an RT kernel there still is a tiny amount of system work in idle,
that is the instruction executed to switch to the idle process, go to
sleep, wake up again and switch back to another process.

> >> I've always assumed that the second field of /proc/uptime was a simple
> >> measure of time not spent doing real work, in other words a crude measure
> >> of spare CPU resources. My instrument basically uses the the two fields
> >> of this file to compute a measure of CPU loading so it can raise an alert
> >> if the CPU doesn't have enough spare (idle) capacity.
> >
> >But it wasn't.. the old style stime of idle is a mixture of true idle
> >time and some system time.
>
> Then I would say let's show the idle time only (but still inculde
> the idle time when the CPU is halted).

That is hard to do. I've implemented this for s390 where the idle time
really is the time spent waiting. To improve x86 with its tick based
accounting you need to find out if the timer interrupt arrived while
the cpu has been waiting, e.g. check the instruction pointed to by eip
for "hlt".

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.

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