Commit e9fb7631 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

cpu-hotplug: introduce cpu_notify(), __cpu_notify(), cpu_notify_nofail()

No functional change.  These are just wrappers of
raw_cpu_notifier_call_chain.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 36e15263
...@@ -134,6 +134,26 @@ int __ref register_cpu_notifier(struct notifier_block *nb) ...@@ -134,6 +134,26 @@ int __ref register_cpu_notifier(struct notifier_block *nb)
return ret; return ret;
} }
static int __cpu_notify(unsigned long val, void *v, int nr_to_call,
int *nr_calls)
{
return __raw_notifier_call_chain(&cpu_chain, val, v, nr_to_call,
nr_calls);
}
static int cpu_notify(unsigned long val, void *v)
{
return __cpu_notify(val, v, -1, NULL);
}
static void cpu_notify_nofail(unsigned long val, void *v)
{
int err;
err = cpu_notify(val, v);
BUG_ON(err == NOTIFY_BAD);
}
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
EXPORT_SYMBOL(register_cpu_notifier); EXPORT_SYMBOL(register_cpu_notifier);
...@@ -181,8 +201,7 @@ static int __ref take_cpu_down(void *_param) ...@@ -181,8 +201,7 @@ static int __ref take_cpu_down(void *_param)
if (err < 0) if (err < 0)
return err; return err;
raw_notifier_call_chain(&cpu_chain, CPU_DYING | param->mod, cpu_notify(CPU_DYING | param->mod, param->hcpu);
param->hcpu);
if (task_cpu(param->caller) == cpu) if (task_cpu(param->caller) == cpu)
move_task_off_dead_cpu(cpu, param->caller); move_task_off_dead_cpu(cpu, param->caller);
...@@ -212,14 +231,12 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) ...@@ -212,14 +231,12 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
cpu_hotplug_begin(); cpu_hotplug_begin();
set_cpu_active(cpu, false); set_cpu_active(cpu, false);
err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod, err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls);
hcpu, -1, &nr_calls);
if (err == NOTIFY_BAD) { if (err == NOTIFY_BAD) {
set_cpu_active(cpu, true); set_cpu_active(cpu, true);
nr_calls--; nr_calls--;
__raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, __cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL);
hcpu, nr_calls, NULL);
printk("%s: attempt to take down CPU %u failed\n", printk("%s: attempt to take down CPU %u failed\n",
__func__, cpu); __func__, cpu);
err = -EINVAL; err = -EINVAL;
...@@ -230,9 +247,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) ...@@ -230,9 +247,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
if (err) { if (err) {
set_cpu_active(cpu, true); set_cpu_active(cpu, true);
/* CPU didn't die: tell everyone. Can't complain. */ /* CPU didn't die: tell everyone. Can't complain. */
if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, cpu_notify_nofail(CPU_DOWN_FAILED | mod, hcpu);
hcpu) == NOTIFY_BAD)
BUG();
goto out_release; goto out_release;
} }
...@@ -246,19 +261,14 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) ...@@ -246,19 +261,14 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
__cpu_die(cpu); __cpu_die(cpu);
/* CPU is completely dead: tell everyone. Too late to complain. */ /* CPU is completely dead: tell everyone. Too late to complain. */
if (raw_notifier_call_chain(&cpu_chain, CPU_DEAD | mod, cpu_notify_nofail(CPU_DEAD | mod, hcpu);
hcpu) == NOTIFY_BAD)
BUG();
check_for_tasks(cpu); check_for_tasks(cpu);
out_release: out_release:
cpu_hotplug_done(); cpu_hotplug_done();
if (!err) { if (!err)
if (raw_notifier_call_chain(&cpu_chain, CPU_POST_DEAD | mod, cpu_notify_nofail(CPU_POST_DEAD | mod, hcpu);
hcpu) == NOTIFY_BAD)
BUG();
}
return err; return err;
} }
...@@ -293,8 +303,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) ...@@ -293,8 +303,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
return -EINVAL; return -EINVAL;
cpu_hotplug_begin(); cpu_hotplug_begin();
ret = __raw_notifier_call_chain(&cpu_chain, CPU_UP_PREPARE | mod, hcpu, ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls);
-1, &nr_calls);
if (ret == NOTIFY_BAD) { if (ret == NOTIFY_BAD) {
nr_calls--; nr_calls--;
printk("%s: attempt to bring up CPU %u failed\n", printk("%s: attempt to bring up CPU %u failed\n",
...@@ -312,12 +321,11 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) ...@@ -312,12 +321,11 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
set_cpu_active(cpu, true); set_cpu_active(cpu, true);
/* Now call notifier in preparation. */ /* Now call notifier in preparation. */
raw_notifier_call_chain(&cpu_chain, CPU_ONLINE | mod, hcpu); cpu_notify(CPU_ONLINE | mod, hcpu);
out_notify: out_notify:
if (ret != 0) if (ret != 0)
__raw_notifier_call_chain(&cpu_chain, __cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL);
cpu_hotplug_done(); cpu_hotplug_done();
return ret; return ret;
...@@ -481,7 +489,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu) ...@@ -481,7 +489,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu)
if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus)) if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus))
val = CPU_STARTING_FROZEN; val = CPU_STARTING_FROZEN;
#endif /* CONFIG_PM_SLEEP_SMP */ #endif /* CONFIG_PM_SLEEP_SMP */
raw_notifier_call_chain(&cpu_chain, val, (void *)(long)cpu); cpu_notify(val, (void *)(long)cpu);
} }
#endif /* CONFIG_SMP */ #endif /* CONFIG_SMP */
......
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