Detangle lwkt_switch() and the idle thread and consolidate sleep variables

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Sat Sep 1 10:39:51 PDT 2007


hey,

our lwkt_switch()/cpu_idle() code is kind of interwoven.  additionally, there are several variables on which we need to spin if there are runnable threads:  mplock and tokens.

This makes it kind of hard to implement a idle loop which suspends the CPU, using MONITOR/MWAIT.

A quick explanation for those not aware how MONITOR/MWAIT works:  you can "arm" the monitoring hardware in modern intel CPUs using MONITOR.  Any write to this address (the size is implementation specific, probably 64 bytes) will trigger the monitoring hardware.  A following MWAIT will place the CPU into a power saving state until the monitoring hardware gets triggered.  There can be other causes for a trigger, for instance interrupts.

So what I'd like to have is a single variable on which I can MWAIT, even if there are runnable threads.  This could be either the mplock, or maybe a per-CPU variable, being set if any token the CPU is waiting on gets released.

Is something like this architecturally possible?  I'd really love to use my laptop, but right now it is still running too hot.

cheers
 simon




More information about the Kernel mailing list