Commit 08eed44c authored by Jan Kara's avatar Jan Kara Committed by Jens Axboe

smp: Teach __smp_call_function_single() to check for offline cpus

Align __smp_call_function_single() with smp_call_function_single() so
that it also checks whether requested cpu is still online.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 0ebeb79c
...@@ -50,8 +50,7 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), ...@@ -50,8 +50,7 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
smp_call_func_t func, void *info, bool wait, smp_call_func_t func, void *info, bool wait,
gfp_t gfp_flags); gfp_t gfp_flags);
void __smp_call_function_single(int cpuid, struct call_single_data *data, int __smp_call_function_single(int cpu, struct call_single_data *csd, int wait);
int wait);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
...@@ -276,18 +276,18 @@ EXPORT_SYMBOL_GPL(smp_call_function_any); ...@@ -276,18 +276,18 @@ EXPORT_SYMBOL_GPL(smp_call_function_any);
/** /**
* __smp_call_function_single(): Run a function on a specific CPU * __smp_call_function_single(): Run a function on a specific CPU
* @cpu: The CPU to run on. * @cpu: The CPU to run on.
* @data: Pre-allocated and setup data structure * @csd: Pre-allocated and setup data structure
* @wait: If true, wait until function has completed on specified CPU. * @wait: If true, wait until function has completed on specified CPU.
* *
* Like smp_call_function_single(), but allow caller to pass in a * Like smp_call_function_single(), but allow caller to pass in a
* pre-allocated data structure. Useful for embedding @data inside * pre-allocated data structure. Useful for embedding @data inside
* other structures, for instance. * other structures, for instance.
*/ */
void __smp_call_function_single(int cpu, struct call_single_data *csd, int __smp_call_function_single(int cpu, struct call_single_data *csd, int wait)
int wait)
{ {
unsigned int this_cpu; unsigned int this_cpu;
unsigned long flags; unsigned long flags;
int err = 0;
this_cpu = get_cpu(); this_cpu = get_cpu();
/* /*
...@@ -303,11 +303,14 @@ void __smp_call_function_single(int cpu, struct call_single_data *csd, ...@@ -303,11 +303,14 @@ void __smp_call_function_single(int cpu, struct call_single_data *csd,
local_irq_save(flags); local_irq_save(flags);
csd->func(csd->info); csd->func(csd->info);
local_irq_restore(flags); local_irq_restore(flags);
} else { } else if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) {
csd_lock(csd); csd_lock(csd);
generic_exec_single(cpu, csd, wait); generic_exec_single(cpu, csd, wait);
} else {
err = -ENXIO; /* CPU not online */
} }
put_cpu(); put_cpu();
return err;
} }
EXPORT_SYMBOL_GPL(__smp_call_function_single); EXPORT_SYMBOL_GPL(__smp_call_function_single);
......
...@@ -22,7 +22,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, ...@@ -22,7 +22,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
} }
EXPORT_SYMBOL(smp_call_function_single); EXPORT_SYMBOL(smp_call_function_single);
void __smp_call_function_single(int cpu, struct call_single_data *csd, int __smp_call_function_single(int cpu, struct call_single_data *csd,
int wait) int wait)
{ {
unsigned long flags; unsigned long flags;
...@@ -30,6 +30,7 @@ void __smp_call_function_single(int cpu, struct call_single_data *csd, ...@@ -30,6 +30,7 @@ void __smp_call_function_single(int cpu, struct call_single_data *csd,
local_irq_save(flags); local_irq_save(flags);
csd->func(csd->info); csd->func(csd->info);
local_irq_restore(flags); local_irq_restore(flags);
return 0;
} }
EXPORT_SYMBOL(__smp_call_function_single); EXPORT_SYMBOL(__smp_call_function_single);
......
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