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

Matthew Dillon dillon at apollo.backplane.com
Sat Sep 1 11:31:03 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

    I dont know the semantics of MONITOR/MWAIT.  What happens if you issue
    a MONITOR and the cpu takes an interrupt and issues another MONITOR/MWAIT
    before returning to your MWAIT?  That will govern whether/how we use the
    feature because it will determine whether we need to disable interrupts
    while doing the monitor/mwait sequence or not.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>





More information about the Kernel mailing list