Subject: Re: Current kernels and power consumption
To: Juan RP <juan@xtrarom.org>
From: Andrew Doran <ad@netbsd.org>
List: current-users
Date: 09/26/2007 23:55:29
On Wed, Sep 26, 2007 at 11:44:04PM +0200, Juan RP wrote:

> Also all the persons that had these problems didn't use MONITOR/MWAIT
> but rather x86_stihlt.

My system uses those and it also has the problem.
 
> I see that x86_stihlt and cpu_idle_loop are taking a considerable amount
> of time, my laptop was mostly idle all the time... but might this be
> related to this problem? any idea?

So I looked at this and the problem is that MD code idles only if the 'need
resched' flag on the CPU is clear. If the flag is set it returns to the idle
loop, and the flag is usually cleared in mi_switch(). The idle loop will not
enter mi_switch() if there are no jobs in the run queues for the current
CPU. So sometimes the flag doesn't get cleared, and they end up spinning.
The fix is a bit tricky since there are a few different requirements at
play. I'm looking into it at the moment.

Andrew