diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-08-25 17:07:14 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-08-25 17:45:48 -0700 |
commit | f73be6dedf4fa058ce80846dae604b08fa805ca1 (patch) | |
tree | eb38c111bedf6b356db3af20ab124dff846643cb /kernel/smp.c | |
parent | 2a61812af2e564cba2c8170cf96e1c823210f619 (diff) | |
download | lwn-f73be6dedf4fa058ce80846dae604b08fa805ca1.tar.gz lwn-f73be6dedf4fa058ce80846dae604b08fa805ca1.zip |
smp: have smp_call_function_single() detect invalid CPUs
Have smp_call_function_single() return invalid CPU indicies and return
-ENXIO. This function is already executed inside a
get_cpu()..put_cpu() which locks out CPU removal, so rather than
having the higher layers doing another layer of locking to guard
against unplugged CPUs do the test here.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'kernel/smp.c')
-rw-r--r-- | kernel/smp.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/smp.c b/kernel/smp.c index 782e2b93e465..f362a8553777 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -210,8 +210,10 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, { struct call_single_data d; unsigned long flags; - /* prevent preemption and reschedule on another processor */ + /* prevent preemption and reschedule on another processor, + as well as CPU removal */ int me = get_cpu(); + int err = 0; /* Can deadlock when called with interrupts disabled */ WARN_ON(irqs_disabled()); @@ -220,7 +222,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, local_irq_save(flags); func(info); local_irq_restore(flags); - } else { + } else if ((unsigned)cpu < NR_CPUS && cpu_online(cpu)) { struct call_single_data *data = NULL; if (!wait) { @@ -236,10 +238,12 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, data->func = func; data->info = info; generic_exec_single(cpu, data); + } else { + err = -ENXIO; /* CPU not online */ } put_cpu(); - return 0; + return err; } EXPORT_SYMBOL(smp_call_function_single); |