Re: spin_locks without smp.

Alan Cox (alan@lxorguk.ukuu.org.uk)
10 Jan 2003 13:29:16 +0000


On Fri, 2003-01-10 at 11:42, Maciej Soltysiak wrote:
> Hi,
>
> while browsing through the network drivers about the etherleak issue i
> found that some drivers have:
>
> #ifdef CONFIG_SMP
> spin_lock_irqsave(...)
> #endif
>
> and some just:
>
> spin_lock_irqsave(...)
>
> or similar.
> Which version should be practiced? i thought spinlocks are irrelevant
> without SMP so we should use #ifdef to shorten the execution path.

Long answer: The network driver authors are doing some fairly clever
things to make old ISA adapters usable in Linux 2.4 and later. Linux
lacks the functionality to do

spin_lock_disable_irqmask(lock, flags, mask)

Implementing it is rather expensive and hard to do well. In general
those code paths need reviewing and probably to change to

preempt_disable()
#ifdef CONFIG_SMP
spin_lock_irqsave(..)
#endif
..

Please ensure that if you change these drivers you
a) Have the hardware and test it uniprocessor and SMP
b) Verify that with your change a serial modem port still works
c) Understand the game the author is playing

(Also d) ensure the author understands the games she/he is playing too!)

If you've been looking at the etherleak stuff btw, the -ac tree has what
is theoretically a full set of fixes. I'd love someone who is looking
at this into 2.5 to review them and merge them into the 2.5 tree. I
doubt I have them all right so more eyes is most welcome.

Alan

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