Skip to content

Commit

Permalink
[POWERPC] Avoid pointless WARN_ON(irqs_disabled()) from panic codepath
Browse files Browse the repository at this point in the history
> ------------[ cut here ]------------
> Badness at arch/powerpc/kernel/smp.c:202

comes when smp_call_function_map() has been called with irqs disabled,
which is illegal. However, there is a special case, the panic() codepath,
when we do not want to warn about this -- warning at that time is pointless
anyway, and only serves to scroll away the *real* cause of the panic and
distracts from the real bug.

* So let's extract the WARN_ON() from smp_call_function_map() into all its
  callers -- smp_call_function() and smp_call_function_single()

* Also, introduce another caller of smp_call_function_map(), namely
  __smp_call_function() (and make smp_call_function() a wrapper over this)
  which does *not* warn about disabled irqs

* Use this __smp_call_function() from the panic codepath's smp_send_stop()

We also end having to move code of smp_send_stop() below the definition
of __smp_call_function().

Signed-off-by: Satyam Sharma <satyam@infradead.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Satyam Sharma authored and Paul Mackerras committed Sep 22, 2007
1 parent 17b5ee0 commit 8fd7675
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ static void stop_this_cpu(void *dummy)
;
}

void smp_send_stop(void)
{
smp_call_function(stop_this_cpu, NULL, 1, 0);
}

/*
* Structure and data for smp_call_function(). This is designed to minimise
* static memory requirements. It also looks cleaner.
Expand Down Expand Up @@ -198,9 +193,6 @@ int smp_call_function_map(void (*func) (void *info), void *info, int nonatomic,
int cpu;
u64 timeout;

/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());

if (unlikely(smp_ops == NULL))
return ret;

Expand Down Expand Up @@ -270,10 +262,19 @@ int smp_call_function_map(void (*func) (void *info), void *info, int nonatomic,
return ret;
}

static int __smp_call_function(void (*func)(void *info), void *info,
int nonatomic, int wait)
{
return smp_call_function_map(func,info,nonatomic,wait,cpu_online_map);
}

int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
int wait)
{
return smp_call_function_map(func,info,nonatomic,wait,cpu_online_map);
/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());

return __smp_call_function(func, info, nonatomic, wait);
}
EXPORT_SYMBOL(smp_call_function);

Expand All @@ -283,6 +284,9 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
cpumask_t map = CPU_MASK_NONE;
int ret = 0;

/* Can deadlock when called with interrupts disabled */
WARN_ON(irqs_disabled());

if (!cpu_online(cpu))
return -EINVAL;

Expand All @@ -299,6 +303,11 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
}
EXPORT_SYMBOL(smp_call_function_single);

void smp_send_stop(void)
{
__smp_call_function(stop_this_cpu, NULL, 1, 0);
}

void smp_call_function_interrupt(void)
{
void (*func) (void *info);
Expand Down

0 comments on commit 8fd7675

Please sign in to comment.