Re: spinlocks() are severely broken in 2.2.X and 2.4.X for modules

David S. Miller (davem@redhat.com)
Sat, 1 Jul 2000 02:52:42 -0700


Date: Sat, 1 Jul 2000 10:09:56 +0200 (CEST)
From: =?ISO-8859-1?Q?G=E9rard_Roudier?= <groudier@club-internet.fr>

On Fri, 30 Jun 2000, Jeff V. Merkey wrote:

[...]

> void NWLockLRU(LRU_HANDLE *lru_handle)
> {
> spinlock_irqsave(&lru_handle->LRU_spinlock, lru_handle->LRU_flags);

Does not seem to me safe to store irq flags in shared data structures.
SMP .vs. UP does not seem to matter here.

In fact this is also a problem in that it encourages people to believe
that doing irqsave/irqrestore for the same "flags" in different
functions is ok. It is not and will crash on some architectures.

For example, this is OK:

{
unsigned long flags;

spin_lock_irqsave(&lock, flags);
...
spin_unlock_irqrestore(&lock, flags);
}

This is not OK:

void bar(unsigned long flags)
{
spin_unlock_irqrestore(&lock, flags);
}

void foo(void)
{
spin_lock_irqsave(&lock, flags);
...
bar();
}

It will crash on Sparc for example, it will probably cause problems
on some other non-x86 ports as well.

Later,
David S. Miller
davem@redhat.com

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