public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled
@ 2004-04-27  0:09 Keith Owens
  2004-04-27  0:31 ` David Mosberger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Keith Owens @ 2004-04-27  0:09 UTC (permalink / raw)
  To: linux-ia64

There is a nasty race if smp_call_function() is called with interrupts
disabled.

CPU A                               CPU B
Disable interrupts
                                    smp_call_function()
                                    Take call_lock
                                    Send IPIs
                                    Wait for all cpus to acknowledge IPI
                                    CPU A has not responded, spin waiting
                                    for cpu A to respond, holding call_lock
smp_call_function()
Spin waiting for call_lock
Deadlock                            Deadlock

This bug is hard to reproduce and even harder to diagnose.  Since the
comments at the start of smp_call_function() say it should never be
entered with interrupts disabled, make it so.

Index: linux/arch/ia64/kernel/smp.c
=================================--- linux.orig/arch/ia64/kernel/smp.c	Mon Apr 26 15:20:17 2004
+++ linux/arch/ia64/kernel/smp.c	Tue Apr 27 09:56:55 2004
@@ -319,10 +319,14 @@
 {
 	struct call_data_struct data;
 	int cpus = num_online_cpus()-1;
+	unsigned long psr;
 
 	if (!cpus)
 		return 0;
 
+	__asm__ __volatile__ ("mov %0=psr;; " : "=r" (psr));
+	BUG_ON(!(psr & IA64_PSR_I));
+
 	data.func = func;
 	data.info = info;
 	atomic_set(&data.started, 0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled
  2004-04-27  0:09 [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled Keith Owens
@ 2004-04-27  0:31 ` David Mosberger
  2004-04-27  0:43 ` Keith Owens
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Mosberger @ 2004-04-27  0:31 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Tue, 27 Apr 2004 10:09:39 +1000, Keith Owens <kaos@sgi.com> said:

  Keith> + __asm__ __volatile__ ("mov %0=psr;; " : "=r" (psr))

Please no inline-asm.  Especially when there is a perfectly suitable
macro already (local_save_flags).

	--david

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled
  2004-04-27  0:09 [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled Keith Owens
  2004-04-27  0:31 ` David Mosberger
@ 2004-04-27  0:43 ` Keith Owens
  2004-04-27  0:54 ` David Mosberger
  2004-04-27  1:32 ` Keith Owens
  3 siblings, 0 replies; 5+ messages in thread
From: Keith Owens @ 2004-04-27  0:43 UTC (permalink / raw)
  To: linux-ia64

On Mon, 26 Apr 2004 17:31:32 -0700, 
David Mosberger <davidm@napali.hpl.hp.com> wrote:
>>>>>> On Tue, 27 Apr 2004 10:09:39 +1000, Keith Owens <kaos@sgi.com> said:
>
>  Keith> + __asm__ __volatile__ ("mov %0=psr;; " : "=r" (psr))
>
>Please no inline-asm.  Especially when there is a perfectly suitable
>macro already (local_save_flags).

Sorry, ported from an older 2.4 kernel.  Redo.

There is a nasty race if smp_call_function() is called with interrupts
disabled.

CPU A                               CPU B
Disable interrupts
                                    smp_call_function()
                                    Take call_lock
                                    Send IPIs
                                    Wait for all cpus to acknowledge IPI
                                    CPU A has not responded, spin waiting
                                    for cpu A to respond, holding call_lock
smp_call_function()
Spin waiting for call_lock
Deadlock                            Deadlock

This bug is hard to reproduce and even harder to diagnose.  Since the
comments at the start of smp_call_function() say it should never be
entered with interrupts disabled, make it so.

Index: linux/arch/ia64/kernel/smp.c
=================================--- linux.orig/arch/ia64/kernel/smp.c	Mon Apr 26 15:20:17 2004
+++ linux/arch/ia64/kernel/smp.c	Tue Apr 27 10:36:58 2004
@@ -319,10 +319,14 @@
 {
 	struct call_data_struct data;
 	int cpus = num_online_cpus()-1;
+	unsigned long psr;
 
 	if (!cpus)
 		return 0;
 
+	local_save_flags(psr);
+	BUG_ON(!(psr & IA64_PSR_I));
+
 	data.func = func;
 	data.info = info;
 	atomic_set(&data.started, 0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled
  2004-04-27  0:09 [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled Keith Owens
  2004-04-27  0:31 ` David Mosberger
  2004-04-27  0:43 ` Keith Owens
@ 2004-04-27  0:54 ` David Mosberger
  2004-04-27  1:32 ` Keith Owens
  3 siblings, 0 replies; 5+ messages in thread
From: David Mosberger @ 2004-04-27  0:54 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Tue, 27 Apr 2004 10:43:39 +1000, Keith Owens <kaos@sgi.com> said:

  Keith> Sorry, ported from an older 2.4 kernel.  Redo.

Sorry for doing this in an incremental fashion, but upon re-reading
your patch, I vaguely remembered that we had a macro to check whether
irqs are disabled.  Sure enough, there is:

	irqs_disabled()

  --david

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled
  2004-04-27  0:09 [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled Keith Owens
                   ` (2 preceding siblings ...)
  2004-04-27  0:54 ` David Mosberger
@ 2004-04-27  1:32 ` Keith Owens
  3 siblings, 0 replies; 5+ messages in thread
From: Keith Owens @ 2004-04-27  1:32 UTC (permalink / raw)
  To: linux-ia64

Take 3.

There is a nasty race if smp_call_function() is called with interrupts
disabled.

CPU A                               CPU B
Disable interrupts
                                    smp_call_function()
                                    Take call_lock
                                    Send IPIs
                                    Wait for all cpus to acknowledge IPI
                                    CPU A has not responded, spin waiting
                                    for cpu A to respond, holding call_lock
smp_call_function()
Spin waiting for call_lock
Deadlock                            Deadlock

This bug is hard to reproduce and even harder to diagnose.  Since the
comments at the start of smp_call_function() say it should never be
entered with interrupts disabled, make it so.

Index: linux/arch/ia64/kernel/smp.c
=================================--- linux.orig/arch/ia64/kernel/smp.c	Mon Apr 26 15:20:17 2004
+++ linux/arch/ia64/kernel/smp.c	Tue Apr 27 11:30:48 2004
@@ -323,6 +323,8 @@
 	if (!cpus)
 		return 0;
 
+	BUG_ON(irqs_disabled());
+
 	data.func = func;
 	data.info = info;
 	atomic_set(&data.started, 0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-04-27  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-27  0:09 [patch] 2.6.5 BUG if smp_call_function is called with interrupts disabled Keith Owens
2004-04-27  0:31 ` David Mosberger
2004-04-27  0:43 ` Keith Owens
2004-04-27  0:54 ` David Mosberger
2004-04-27  1:32 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox