Re: [PATCH] kernel/timer.c: using spin_lock_irqsave instead ofspin_lock + local_irq_save, especially when CONFIG_LOCKDEP not defined

From: Thomas Gleixner
Date: Wed Jun 19 2013 - 06:53:14 EST


On Wed, 19 Jun 2013, Chen Gang wrote:

> On 06/19/2013 05:59 PM, Thomas Gleixner wrote:
> > I'm well aware how that works. And there is no difference whether you
> > do:
> >
> > local_irq_save(flags);
> > spin_lock(&lock);
> > or
> > spin_lock_irqsave(&lock, flags);
>
> if CONFIG_LOCKDEP is not defined, they are not semantically the same.

Care to explain _your_ spinlock semantics to me?

The factual ones are:

spin_lock_irqsave() returns with the lock held, interrupts and
preemption disabled.

spin_lock() returns with the lock held, preemption disabled. It
does not affect interrupt disabled/enabled state

So
local_irq_save(flags);
spin_lock(&lock);

is semantically the same as

spin_lock_irqsave(&lock, flags);

And this is completely independent of LOCKDEP.

Thanks,

tglx


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/