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

Joerg Sonnenberger joerg at britannica.bec.de
Sun Sep 2 06:15:03 PDT 2007


On Sun, Sep 02, 2007 at 02:54:37PM +0200, Simon 'corecode' Schubert wrote:
> Joerg Sonnenberger wrote:
>> According to the AMD documentation, MWAIT would exit because:
>> Events that cause an exit from the monitor event pending state include:
>> ...
>> - Any far control transfer that occurs between the MONITOR and the MWAIT.
>> The exact conditions are written in the Architecture Guide, part 3. It
>> should be noted that a number of Opteron CPUs have an errata if you use
>> MONITOR/MWAIT in a tight loop and certain race conditions with other
>> CPUs happen and you have interrupts disabled. It should also be noted
>> that MWAIT produces less bus contention as well, so it should be used
>> for all spinlocks.
>
> Using it for spinlocks is rather easy, because there is just one variable 
> to monitor.  The intel docs also indicate that there can be a MWAIT 
> functionality to work with interrupts disabled and as interrupt as a break 
> condition.  I'm not exactly sure how this would work, maybe the interrupt 
> would be serviced as soon as you enable interrupts again?

MWAIT itself would abort and the assumption is that you reenable
interrupts directly after that. So that would catch the interrupt.

Joerg





More information about the Kernel mailing list