Commit 4504ba5a authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64: avoid a deadlock during panic

Avoid a deadlock during panic.  Don't take the smp_call_function lock in
smp_send_stop()

Also fix the documentation to conform to Linux standards.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 10f6a5bf
...@@ -382,28 +382,14 @@ static struct call_data_struct * call_data; ...@@ -382,28 +382,14 @@ static struct call_data_struct * call_data;
* this function sends a 'generic call function' IPI to all other CPUs * this function sends a 'generic call function' IPI to all other CPUs
* in the system. * in the system.
*/ */
static void __smp_call_function (void (*func) (void *info), void *info,
int smp_call_function (void (*func) (void *info), void *info, int nonatomic, int nonatomic, int wait)
int wait)
/*
* [SUMMARY] Run a function on all other CPUs.
* <func> The function to run. This must be fast and non-blocking.
* <info> An arbitrary pointer to pass to the function.
* <nonatomic> currently unused.
* <wait> If true, wait (atomically) until function has completed on other CPUs.
* [RETURNS] 0 on success, else a negative status code. Does not return until
* remote CPUs are nearly ready to execute <<func>> or are or have executed.
*
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
* Actually there are a few legal cases, like panic.
*/
{ {
struct call_data_struct data; struct call_data_struct data;
int cpus = num_online_cpus()-1; int cpus = num_online_cpus()-1;
if (!cpus) if (!cpus)
return 0; return;
data.func = func; data.func = func;
data.info = info; data.info = info;
...@@ -412,7 +398,6 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic, ...@@ -412,7 +398,6 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
if (wait) if (wait)
atomic_set(&data.finished, 0); atomic_set(&data.finished, 0);
spin_lock(&call_lock);
call_data = &data; call_data = &data;
wmb(); wmb();
/* Send a message to all other CPUs and wait for them to respond */ /* Send a message to all other CPUs and wait for them to respond */
...@@ -425,8 +410,29 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic, ...@@ -425,8 +410,29 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
if (wait) if (wait)
while (atomic_read(&data.finished) != cpus) while (atomic_read(&data.finished) != cpus)
barrier(); barrier();
spin_unlock(&call_lock); }
/*
* smp_call_function - run a function on all other CPUs.
* @func: The function to run. This must be fast and non-blocking.
* @info: An arbitrary pointer to pass to the function.
* @nonatomic: currently unused.
* @wait: If true, wait (atomically) until function has completed on other
* CPUs.
*
* Returns 0 on success, else a negative status code. Does not return until
* remote CPUs are nearly ready to execute func or are or have executed.
*
* You must not call this function with disabled interrupts or from a
* hardware interrupt handler or from a bottom half handler.
* Actually there are a few legal cases, like panic.
*/
int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
int wait)
{
spin_lock(&call_lock);
__smp_call_function(func,info,nonatomic,wait);
spin_unlock(&call_lock);
return 0; return 0;
} }
...@@ -450,7 +456,16 @@ static void smp_really_stop_cpu(void *dummy) ...@@ -450,7 +456,16 @@ static void smp_really_stop_cpu(void *dummy)
void smp_send_stop(void) void smp_send_stop(void)
{ {
smp_call_function(smp_really_stop_cpu, NULL, 1, 0); int nolock = 0;
/* Don't deadlock on the call lock in panic */
if (!spin_trylock(&call_lock)) {
udelay(100);
/* ignore locking because we have paniced anyways */
nolock = 1;
}
__smp_call_function(smp_really_stop_cpu, NULL, 1, 0);
if (!nolock)
spin_unlock(&call_lock);
smp_stop_cpu(); smp_stop_cpu();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment