Re: Q: "kapm-idled" and CPU usage

Nick Holloway (Nick.Holloway@pyrites.org.uk)
18 Mar 2001 23:47:40 -0000


jgarzik@mandrakesoft.com (Jeff Garzik) writes:
> Is there some way to hack the scheduler statistics so that idle
> processes are special cases, which do not accumulate CPU time nor
> contribute to the load average?

I wondered about getting kapm-idled to take the CPU time allocated to
itself, and reallocate to the idle task. Something like the following
at a strategic point inside the apm loop.

unsigned long user, system;
user = current->times.tms_utime;
system = current->times.tms_stime;
current->times.tms_utime = current->times.tms_stime = 0;
idle->times.tms_utime += user;
idle->times.tms_stime += system;

I haven't looked to see what point would be a good idea, and investigated
what locks need to be held. I've also just peeked at the 2.4 code,
and seen "current->per_cpu_utime[cpu]" -- does this need handling?
Is it visible to user space?

If you looked closely, you might see the CPU time falling for kapm-idled,
but generally you would see it allocated to the idle task, and not
kapm-idled.

> I agree that it's not pretty to special case idle function process(es),
> but those idle functions in turn are causing an incorrect picture of the
> system state to be presented to userland.

At least with this scheme, the special casing is inside the kapm specific
code, and not within the general timer handling.

Of course, this is no more than an idea. I haven't got as far as
running 2.4 on my only APM machine (486 Thinkpad), let alone trying out
this scheme.

-- 
 `O O'  | Nick.Holloway@pyrites.org.uk
// ^ \\ | http://www.pyrites.org.uk/
-
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/