* Re: [PATCH] 2.4.18 raid1 - fix SMP locking/interrupt
@ 2002-03-25 19:50 Manfred Spraul
2002-03-25 20:22 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Spraul @ 2002-03-25 19:50 UTC (permalink / raw)
To: Paul Clements, Andrew Morton; +Cc: linux-kernel
>
> However a bare spin_unlock_irq() in a function means that
> callers which wish to keep interrupts disabled are subtly
> subverted. We've had bugs from this before.
>
It is trivial to catch such bugs at runtime. I tried it a year ago, and
immediately run into sleep_on() users that legitimately call
spin_lock_irq() with disabled interrupts. Perhaps they are gone now,
I'll retest my patch.
> So the irqrestore functions are much more robust. I believe
> that they should be the default choice. The non-restore
> versions should be viewed as a micro-optimised version,
> to be used with caution. The additional expense of the save/restore
> is quite tiny - 20-30 cycles, perhaps.
OTHO, if a function doesn't work correctly if it's called with disabled
interrupts, then it should not use spin_lock_irqsave() - it's
misleading.
e.g. if it calls kmalloc(GFP_KERNEL), down(), schedule(), etc.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] 2.4.18 raid1 - fix SMP locking/interrupt
2002-03-25 19:50 [PATCH] 2.4.18 raid1 - fix SMP locking/interrupt Manfred Spraul
@ 2002-03-25 20:22 ` Andrew Morton
2002-03-25 20:57 ` Manfred Spraul
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2002-03-25 20:22 UTC (permalink / raw)
To: Manfred Spraul; +Cc: Paul Clements, linux-kernel
Manfred Spraul wrote:
>
> >
> > However a bare spin_unlock_irq() in a function means that
> > callers which wish to keep interrupts disabled are subtly
> > subverted. We've had bugs from this before.
> >
> It is trivial to catch such bugs at runtime. I tried it a year ago, and
> immediately run into sleep_on() users that legitimately call
> spin_lock_irq() with disabled interrupts. Perhaps they are gone now,
> I'll retest my patch.
heh. Yes, I tried that too a year or so ago. Basically just
add
if (!(eflags & 0x0200))
whine();
to spin_lock_irq(). There was a *lot* of whining.
> > So the irqrestore functions are much more robust. I believe
> > that they should be the default choice. The non-restore
> > versions should be viewed as a micro-optimised version,
> > to be used with caution. The additional expense of the save/restore
> > is quite tiny - 20-30 cycles, perhaps.
>
> OTHO, if a function doesn't work correctly if it's called with disabled
> interrupts, then it should not use spin_lock_irqsave() - it's
> misleading.
> e.g. if it calls kmalloc(GFP_KERNEL), down(), schedule(), etc.
mm? Those are legal (albeit unpleasant) inside local_irq_save(),
but illegal inside global_cli() in 2.5. Aren't they? If not,
then release_kernel_lock() needs talking to.
-
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] 2.4.18 raid1 - fix SMP locking/interrupt
2002-03-25 20:22 ` Andrew Morton
@ 2002-03-25 20:57 ` Manfred Spraul
0 siblings, 0 replies; 3+ messages in thread
From: Manfred Spraul @ 2002-03-25 20:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: Paul Clements, linux-kernel
From: "Andrew Morton" <akpm@zip.com.au>
> > OTHO, if a function doesn't work correctly if it's called with
disabled
> > interrupts, then it should not use spin_lock_irqsave() - it's
> > misleading.
> > e.g. if it calls kmalloc(GFP_KERNEL), down(), schedule(), etc.
>
> mm? Those are legal (albeit unpleasant) inside local_irq_save(),
> but illegal inside global_cli() in 2.5. Aren't they? If not,
> then release_kernel_lock() needs talking to.
>
If a function is called with disabled interrupts, then the caller
probably expects that the interrupts remain disabled - otherwise he
would have reenabled them before calling. schedule reenables interrupts.
The calls might be legal, but usually they indicate a bug.
--
Manfred
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-03-25 20:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-25 19:50 [PATCH] 2.4.18 raid1 - fix SMP locking/interrupt Manfred Spraul
2002-03-25 20:22 ` Andrew Morton
2002-03-25 20:57 ` Manfred Spraul
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.