Re: Spinlocks

From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 10/18/05


Date: Tue, 18 Oct 2005 12:13:01 +0200

brankok@dkts.co.yu wrote:
>
> Now I'm wondering if I should have used spinlocks at
> all. Couldn't I have just disable interrupts in in the noninterrupt
> code, do the critical section and then enable interrupts? What am I not
> getting?

Multi CPU systems.

Even if you disable interrupts on one CPU it may still be taken
by another CPU. So you need to disable interrupts to protect
against interrupts on the same CPU and the spinlock to protect
against other CPUs. This is exactly what spinlock_irqsave will
take care of. (In configurations where the spinlock part is not
required, it will be excluded automatically, so you don't need
to worry about that).

-- 
Kasper Dupont
Note to self: Don't try to allocate
256000 pages with GFP_KERNEL on x86.


Relevant Pages


Loading