2001-11-29 18:59:05

by Derek Glidden

[permalink] [raw]
Subject: kapm-idled no longer idling CPU?


I posted this question about a month ago, but haven't seen a response
since, so I'm reposting.

I'm having a problem with all recent 2.4 systems that when any
application that uses more than very minor system resources is running,
(i.e. mozilla, netscape, xemacs, apache, Tomcat, just to name a few
common ones I've seen this behaviour with) kapm-idled no longer receives
scheduling time from what I can tell and I assume that means my CPU is
never getting idled when nothing is scheduled.

I'm pretty sure this is a legit problem and not just kapm-idled
reporting its time incorrectly since my laptop has gone from about 2-1/2
hours of battery life in early 2.4 versions to less than 1 hour of
battery life under the same conditions for recent kernels. Plus, if I
exit everything until I'm just sitting at a shell prompt, I'll see
kapm-idled start to receive time again. (Of course, the laptop isn't
much fun when it's not running anything...)

I've seen this on a number of laptops and desktop machines since about
2.4.9 or so.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#!/usr/bin/perl -w
$_='while(read+STDIN,$_,2048){$a=29;$b=73;$c=142;$t=255;@t=map
{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;
$t^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m&17)),$b^=$_%64?12:0,@z)
[$_%8]}(16..271);if((@a=unx"C*",$_)[20]&48){$h=5;$_=unxb24,join
"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$d=
unxV,xb25,$_;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=$t&($d
>>12^$d>>4^$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*
8^$q<<6))<<9,$_=$t[$_]^(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}
print+x"C*",@a}';s/x/pack+/g;eval

usage: qrpff 153 2 8 105 225 < /mnt/dvd/VOB_FILENAME \
| extract_mpeg2 | mpeg2dec -

http://www.cs.cmu.edu/~dst/DeCSS/Gallery/
http://www.eff.org/ http://www.anti-dmca.org/


2001-11-30 11:41:57

by Alan

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?

> application that uses more than very minor system resources is running,
> (i.e. mozilla, netscape, xemacs, apache, Tomcat, just to name a few
> common ones I've seen this behaviour with) kapm-idled no longer receives
> scheduling time from what I can tell and I assume that means my CPU is
> never getting idled when nothing is scheduled.

kapm_idled will get scheduling time when there is nothing else to run,
whether it wants it or is using it is more of the question.

> reporting its time incorrectly since my laptop has gone from about 2-1/2
> hours of battery life in early 2.4 versions to less than 1 hour of
> battery life under the same conditions for recent kernels. Plus, if I

Stick some printk calls in so you can see a count of when the thread runs
and also see when it decides to ask the BIOS to do idling (and also what
then occurs).

I fixed one case recently where we would spin calling the bios all the time
when instead of pausing the bios replied that it had slowed down the
processor. That however was post 2.4.9 so I dont think its related.

Alan

2001-11-30 12:37:01

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?


On 30-Nov-2001 Alan Cox wrote:
>> application that uses more than very minor system resources is running,
>> (i.e. mozilla, netscape, xemacs, apache, Tomcat, just to name a few
>> common ones I've seen this behaviour with) kapm-idled no longer receives
>> scheduling time from what I can tell and I assume that means my CPU is
>> never getting idled when nothing is scheduled.
>
> kapm_idled will get scheduling time when there is nothing else to run,
> whether it wants it or is using it is more of the question.
>

Well, that's exactly the problem. in apm_mainloop the following happens:

timeout = 2 * timeout;
if (timeout > APM_CHECK_TIMEOUT)
timeout = APM_CHECK_TIMEOUT;
schedule_timeout(timeout);

...

if (!system_idle())
continue;

...

if (apm_do_idle() != -1) {

...

timeout = 1;
}


This just means that after a busy condition we start at 1 and increase the
scheduling delay until the timeout reaches HZ.

system_idle itself just checks, if nr_running is 1. This means that if any
single other process is runnable every HZ time when apm_idled checks the system
state it won't switch to idle state even if the system is otherwise idle. I do
see this behaviour e.g. all the time with KDE.

Just create a process that does a select timeout every HZ and down the drain
goes your laptop battery, when the select call meets kapm-idled polling time.


Andreas Steinmetz
D.O.M. Datenverarbeitung GmbH

2001-11-30 12:57:53

by Borsenkow Andrej

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?

>
> I'm pretty sure this is a legit problem and not just kapm-idled
> reporting its time incorrectly since my laptop has gone from about
2-1/2
> hours of battery life in early 2.4 versions to less than 1 hour of
> battery life under the same conditions for recent kernels. Plus, if I
> exit everything until I'm just sitting at a shell prompt, I'll see
> kapm-idled start to receive time again. (Of course, the laptop isn't
> much fun when it's not running anything...)

I confirm this. I have two types of gkrellm reports:

28C CPU temperature/0% CPU load
31C CPU temperature/50% CPU load system

(well, in the average :-)

In the latter case I see kapm-idled using exactly these 50% CPU.

> I've seen this on a number of laptops and desktop machines since about

> 2.4.9 or so.

It was in all Mandrake 2.4.+ kernels I remember; I still have
2.4.8-31.1mdk, I'll try it.

-andrej

2001-11-30 13:14:48

by Alan

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?

> system_idle itself just checks, if nr_running is 1. This means that if any
> single other process is runnable every HZ time when apm_idled checks the system
> state it won't switch to idle state even if the system is otherwise idle. I do
> see this behaviour e.g. all the time with KDE.

Uggh - yes, that makes horrible sense. Does it behave any better if you
check say load average for the past 15 seconds < .1 ?

2001-11-30 15:48:45

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?

Not really. It depends on 'how in sync' kapm-idled is running with other
processes. It's easy to monitor on the laptop as the bios changes the color of
a LED during idle calls. Quite often when the laptop is nearly fully idle (a
bit of CPU for kmix and the dhcp client, easily verified with top) there are no
idle calls. When there's idle calls in this state (0.00<load<0.1) it's always
less than 50% idle time.
Maybe taking the load average into account for going idle or introducing some
jitter around HZ for the kamp-idled sleep can help.
What may irritate other people furthermore is that if the system idles via
kapm-idled this is accounted as system cpu time instead of idle time so it does
look like the system is constantly under load when it actually does idle calls.

On 30-Nov-2001 Alan Cox wrote:
>> system_idle itself just checks, if nr_running is 1. This means that if any
>> single other process is runnable every HZ time when apm_idled checks the
>> system
>> state it won't switch to idle state even if the system is otherwise idle. I
>> do
>> see this behaviour e.g. all the time with KDE.
>
> Uggh - yes, that makes horrible sense. Does it behave any better if you
> check say load average for the past 15 seconds < .1 ?
>

Andreas Steinmetz
D.O.M. Datenverarbeitung GmbH

2001-12-03 08:51:43

by Tim Connors

[permalink] [raw]
Subject: Re: kapm-idled no longer idling CPU?

On Thu, 29 Nov 2001, Derek Glidden wrote:

> I posted this question about a month ago, but haven't seen a response
> since, so I'm reposting.
>
> I'm having a problem with all recent 2.4 systems that when any
> application that uses more than very minor system resources is running,
> (i.e. mozilla, netscape, xemacs, apache, Tomcat, just to name a few
> common ones I've seen this behaviour with) kapm-idled no longer receives
> scheduling time from what I can tell and I assume that means my CPU is
> never getting idled when nothing is scheduled.

I always had that problem though. Doesn't it only set kapmd-idled running
if the CPU has been idle for at least 1/3 second, though?

> I'm pretty sure this is a legit problem and not just kapm-idled
> reporting its time incorrectly since my laptop has gone from about 2-1/2
> hours of battery life in early 2.4 versions to less than 1 hour of
> battery life under the same conditions for recent kernels. Plus, if I
> exit everything until I'm just sitting at a shell prompt, I'll see
> kapm-idled start to receive time again. (Of course, the laptop isn't
> much fun when it's not running anything...)
>
> I've seen this on a number of laptops and desktop machines since about
> 2.4.9 or so.

Mmmm, my dell insp. 4000 is now running at 53 degrees (2.4.16 - mozilla
and xemacs open) - it used to run a lot cooler, even with just 2.4.13-ac4.
This is with me doing absolutely nothing.

And integrated over the uptime of the laptop, kapmd-idled seems to only be
using about 30% CPU compared to the old 50% (and 90% with an old kernel -
but that could have been that bug detected a while back)

Of course, I just remembered we have just entered summer, and this room is
damn hot - but I wouldn't expect a laptop getting so hot it needs to turn
the fan on, when doing _nothing_!


--
TimC -- http://www.physics.usyd.edu.au/~tcon/

The other day I overheard that a friend of the family had called their
new kid "Noah". I thinks "Noah? I 'ardly -" and then I bursts out
laughing.. -- Screwtape in RHOD