tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Question about spin-lock/interrupt/ipl interaction.



Spin locks have the semantics that IPL doesn't get lowered until the last spin 
lock is unlocked.  For example, taking a IPL_VM spinlock will make sure IPL is 
at least IPL_VM while the lock is locked.  If then a IPL_SCHED lock is locked, 
and the current ipl is IPL_VM, ipl is raised to IPL_SCHED.  If the IPL_SCHED 
lock is unlocked, the ipl stays at IPL_SCHED until the last spin lock is 
unlocked.  This is done to allow spin-locks to be unlocked in any order.

Now consider this scenario: a kernel takes a IPL_VM spin lock so IPL is now 
IPL_VM.  Now an interrupt happens from a IPL_SCHED source so that during 
execution of the handler a IPL_SCHED spin lock is locked and unlocked leaving 
IPL_SCHED the current ipl.  In this instance, we know that any spin-locks
locked in the interrupt handler must be unlocked before the handler returns.

Now my question is whether the interrupt dispatch code should process interrupt 
sources higher than IPL_SCHED (honoring the defined spin-lock/ipl semantics) or 
can it drop IPL back to its original level allowing more IPL_SCHED interrupt 
sources to be serviced (or not honoring the defined spin-lock/ipl semantics)?

Why the latter is a violation, it seems wrong to me for a interrupt to return 
to the code that was interrupted at a different ipl from which it was invoked.  

Should the spin-locks semantics be modified for interrupt usage?


Home | Main Index | Thread Index | Old Index