Subject: Re: splx() optimization [was Re: SMP re-eetrancy in "bottom half" drivers]
To: David Laight <david@l8s.co.uk>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 06/09/2005 07:46:45
On Jun 9, 2005, at 12:22 AM, David Laight wrote:

> I suspect a single cpu can acquire the kernel_lock many times...

Right.  CANRECURSE is used, but only for acquisition from interrupt  
handlers.

> However this makes me realise there is a bigger problem.
> If cpu1 has the kernel_lock, then an interrupt on cpu0 will spin
> waiting for the lock - so interrupts are effectively disabled
> whenever the kernel is running.
> (unless something magic directs interrupts to the cpu holding the  
> lock)

Actually, right now we don't really spread out interrupts to multiple  
CPUs, to avoid that specific problem.  Instead, interrupts go to a  
single CPU, just like the non-SMP case.  There are two exceptions to  
this:

1. Clock interrupts are delivered to all CPUs.

2. Interprocessor interrupts are delivered to all CPUs.

In these two cases, the handlers run outside the kernel_lock perimeter.

-- thorpej