* FW: spinlocks dont work
@ 2004-02-13 21:12 RANDAZZO
2004-02-13 21:34 ` Tim Hockin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: RANDAZZO @ 2004-02-13 21:12 UTC (permalink / raw)
To: linux-kernel
On a uniprocessor system, with config_smp NOT Defined...
Note the following example:
driver 'A' calls spin_lock_irqsave and gets through (but does not call
..unlock).
driver 'B' calls spin_lock_irqsave and gets through???
How can B get through if A did not unlock yet?
-Mike
-----Original Message-----
From: Richard B. Johnson [mailto:root@chaos.analogic.com]
Sent: Friday, February 13, 2004 3:25 PM
To: RANDAZZO@ddc-web.com
Subject: RE: spinlocks dont work
On Fri, 13 Feb 2004 RANDAZZO@ddc-web.com wrote:
> if I need to lock out in the ISR, and I haven't
> compiled for SMP, what can I use instead?
>
> Mike
spinlock_t mylock = SPIN_LOCK_UNLOCKED;
You put:
unsigned int flags;
spin_lock_irqsave(&mylock, flags);
//
// Critical section code
//
spin_unlock_irqrestore(&mylock flags);
...this construct around any critical section. If you
don't know how to write interrupt service routines and
insist upon enabling interrupts within the ISR, you
need the same thing in the ISR.
Whether or not it's compiled for SMP should not then make
any difference because the 'cli' in the macro will still
exist.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
"This message may contain company proprietary information. If you are not
the intended recipient, any disclosure, copying, distribution or reliance on
the contents of this message is prohibited. If you received this message in
error, please delete and notify me."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FW: spinlocks dont work
2004-02-13 21:12 FW: spinlocks dont work RANDAZZO
@ 2004-02-13 21:34 ` Tim Hockin
2004-02-13 22:41 ` Brian Gerst
2004-02-14 1:26 ` Jamie Lokier
2 siblings, 0 replies; 5+ messages in thread
From: Tim Hockin @ 2004-02-13 21:34 UTC (permalink / raw)
To: RANDAZZO; +Cc: linux-kernel
On Fri, Feb 13, 2004 at 04:12:08PM -0500, RANDAZZO@ddc-web.com wrote:
> On a uniprocessor system, with config_smp NOT Defined...
>
> Note the following example:
>
> driver 'A' calls spin_lock_irqsave and gets through (but does not call
> ..unlock).
> driver 'B' calls spin_lock_irqsave and gets through???
>
> How can B get through if A did not unlock yet?
Because actual mutexing is a no-op without CONFIG_SMP. What you have is a BUG.
Don't do that.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FW: spinlocks dont work
2004-02-13 21:12 FW: spinlocks dont work RANDAZZO
2004-02-13 21:34 ` Tim Hockin
@ 2004-02-13 22:41 ` Brian Gerst
2004-02-14 1:22 ` Jamie Lokier
2004-02-14 1:26 ` Jamie Lokier
2 siblings, 1 reply; 5+ messages in thread
From: Brian Gerst @ 2004-02-13 22:41 UTC (permalink / raw)
To: RANDAZZO; +Cc: linux-kernel
RANDAZZO@ddc-web.com wrote:
> On a uniprocessor system, with config_smp NOT Defined...
>
> Note the following example:
>
> driver 'A' calls spin_lock_irqsave and gets through (but does not call
> ..unlock).
> driver 'B' calls spin_lock_irqsave and gets through???
>
> How can B get through if A did not unlock yet?
>
On UP, spinlocks are no-ops.
--
Brian Gerst
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FW: spinlocks dont work
2004-02-13 22:41 ` Brian Gerst
@ 2004-02-14 1:22 ` Jamie Lokier
0 siblings, 0 replies; 5+ messages in thread
From: Jamie Lokier @ 2004-02-14 1:22 UTC (permalink / raw)
To: Brian Gerst; +Cc: RANDAZZO, linux-kernel
Brian Gerst wrote:
> On UP, spinlocks are no-ops.
No they aren't. They disable preemption.
-- Jamie
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FW: spinlocks dont work
2004-02-13 21:12 FW: spinlocks dont work RANDAZZO
2004-02-13 21:34 ` Tim Hockin
2004-02-13 22:41 ` Brian Gerst
@ 2004-02-14 1:26 ` Jamie Lokier
2 siblings, 0 replies; 5+ messages in thread
From: Jamie Lokier @ 2004-02-14 1:26 UTC (permalink / raw)
To: RANDAZZO; +Cc: linux-kernel
RANDAZZO@ddc-web.com wrote:
> Note the following example:
>
> driver 'A' calls spin_lock_irqsave and gets through (but does not call
> ..unlock).
> driver 'B' calls spin_lock_irqsave and gets through???
>
> How can B get through if A did not unlock yet?
Is that code from B an interrupt handler?
If yes, then A should have called spin_lock_irqsave()
Otherwise, is that code from B a softirq or tasklet or timer handler?
If yes, then A should have called spin_lock_bh()
Otherwise, that code from B cannot run unless you are calling
schedule() from A after taking the lock, which is a bug in your code.
-- Jamie
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-02-14 1:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-13 21:12 FW: spinlocks dont work RANDAZZO
2004-02-13 21:34 ` Tim Hockin
2004-02-13 22:41 ` Brian Gerst
2004-02-14 1:22 ` Jamie Lokier
2004-02-14 1:26 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox