Spinlocks and interrupts

Jeff Haran jharan at bytemobile.com
Thu Nov 10 14:19:26 EST 2011


> -----Original Message-----
> From: kernelnewbies-bounces+jharan=bytemobile.com at kernelnewbies.org
> [mailto:kernelnewbies-
> bounces+jharan=bytemobile.com at kernelnewbies.org] On Behalf Of Dave
> Hylands
> Sent: Thursday, November 10, 2011 11:07 AM
> To: Kai Meyer
> Cc: kernelnewbies at kernelnewbies.org
> Subject: Re: Spinlocks and interrupts
> 
> Hi Kai,
> 
> On Thu, Nov 10, 2011 at 10:14 AM, Kai Meyer <kai at gnukai.com> wrote:
> > I think I get it. I'm hitting the scheduling while atomic because
I'm
> > calling my function from a struct bio's endio function, which is
> > probably running with a lock held somewhere else, and then my mutex
> > sleeps, while the spin_lock functions do not sleep.
> 
> Actually, just holding a lock doesn't create an atomic context.

I believe on kernels with kernel pre-emption enabled the act of taking
the lock disables pre-emption. If it didn't work this way you could end
up taking the lock in one process context and while the lock was held
get pre-empted. Then another process tries to take the lock and you dead
lock.

Jeff Haran






More information about the Kernelnewbies mailing list