8 #include <linux/kernel.h>
9 #include <linux/export.h>
18 #ifdef CONFIG_USE_GENERIC_SMP_HELPERS
32 struct call_function_data {
40 struct call_single_queue {
51 struct call_function_data *cfd = &
per_cpu(cfd_data, cpu);
56 if (!zalloc_cpumask_var_node(&cfd->cpumask,
GFP_KERNEL,
58 return notifier_from_errno(-
ENOMEM);
61 #ifdef CONFIG_HOTPLUG_CPU
67 free_cpumask_var(cfd->cpumask);
76 .notifier_call = hotplug_cfd,
79 void __init call_function_init(
void)
85 struct call_single_queue *
q = &
per_cpu(call_single_queue, i);
88 INIT_LIST_HEAD(&q->list);
92 register_cpu_notifier(&hotplug_cfd_notifier);
104 while (data->
flags & CSD_FLAG_LOCK)
111 data->
flags = CSD_FLAG_LOCK;
130 data->
flags &= ~CSD_FLAG_LOCK;
141 struct call_single_queue *
dst = &
per_cpu(call_single_queue, cpu);
146 ipi = list_empty(&dst->list);
172 void generic_smp_call_function_interrupt(
void)
174 struct call_function_data *
data;
194 list_for_each_entry_rcu(data, &call_function.queue, csd.list) {
216 func = data->csd.func;
217 func(data->csd.info);
225 if (!cpumask_test_and_clear_cpu(cpu, data->cpumask)) {
226 WARN(1,
"%pf enabled interrupts and double executed\n", func);
236 WARN_ON(!cpumask_empty(data->cpumask));
239 list_del_rcu(&data->csd.list);
242 csd_unlock(&data->csd);
251 void generic_smp_call_function_single_interrupt(
void)
254 unsigned int data_flags;
263 list_replace_init(&q->list, &
list);
266 while (!list_empty(&
list)) {
277 data_flags = data->
flags;
284 if (data_flags & CSD_FLAG_LOCK)
324 if (cpu == this_cpu) {
329 if ((
unsigned)cpu < nr_cpu_ids &&
cpu_online(cpu)) {
339 generic_exec_single(cpu, data, wait);
367 int smp_call_function_any(
const struct cpumask *
mask,
371 const struct cpumask *nodemask;
409 unsigned int this_cpu;
422 if (cpu == this_cpu) {
428 generic_exec_single(cpu, data, wait);
450 struct call_function_data *
data;
469 if (cpu >= nr_cpu_ids)
474 if (next_cpu == this_cpu)
478 if (next_cpu >= nr_cpu_ids) {
484 csd_lock(&data->csd);
512 data->csd.func =
func;
513 data->csd.info =
info;
519 cpumask_and(data->cpumask, mask, cpu_online_mask);
520 cpumask_clear_cpu(this_cpu, data->cpumask);
521 refs = cpumask_weight(data->cpumask);
525 csd_unlock(&data->csd);
535 list_add_rcu(&data->csd.list, &call_function.queue);
556 csd_lock_wait(&data->csd);
620 if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
628 static int __init maxcpus(
char *str)
631 if (setup_max_cpus == 0)
704 void *info,
bool wait)
757 if (cond_func(cpu, info))
758 cpumask_set_cpu(cpu, cpus);
761 free_cpumask_var(cpus);
769 if (cond_func(cpu, info)) {
779 static void do_nothing(
void *
unused)