summaryrefslogtreecommitdiff
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorQais Yousef <qais.yousef@arm.com>2020-03-23 13:50:54 +0000
committerThomas Gleixner <tglx@linutronix.de>2020-03-25 12:59:31 +0100
commit93ef1429e556f739a208e3968883ed51480580e8 (patch)
tree66175ce1fa49e5f3b4473accce6db3a4a5adb154 /kernel/cpu.c
parentfd3eafda8f146d4ad8f95f91a8c2b9a5319ff6b2 (diff)
downloadlwn-93ef1429e556f739a208e3968883ed51480580e8.tar.gz
lwn-93ef1429e556f739a208e3968883ed51480580e8.zip
cpu/hotplug: Add new {add,remove}_cpu() functions
The new functions use device_{online,offline}() which are userspace safe. This is in preparation to move cpu_{up, down} kernel users to use a safer interface that is not racy with userspace. Suggested-by: "Paul E. McKenney" <paulmck@kernel.org> Signed-off-by: Qais Yousef <qais.yousef@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Paul E. McKenney <paulmck@kernel.org> Link: https://lkml.kernel.org/r/20200323135110.30522-2-qais.yousef@arm.com
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 9c706af713fb..069802f7010f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1057,6 +1057,18 @@ int cpu_down(unsigned int cpu)
}
EXPORT_SYMBOL(cpu_down);
+int remove_cpu(unsigned int cpu)
+{
+ int ret;
+
+ lock_device_hotplug();
+ ret = device_offline(get_cpu_device(cpu));
+ unlock_device_hotplug();
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(remove_cpu);
+
#else
#define takedown_cpu NULL
#endif /*CONFIG_HOTPLUG_CPU*/
@@ -1209,6 +1221,18 @@ int cpu_up(unsigned int cpu)
}
EXPORT_SYMBOL_GPL(cpu_up);
+int add_cpu(unsigned int cpu)
+{
+ int ret;
+
+ lock_device_hotplug();
+ ret = device_online(get_cpu_device(cpu));
+ unlock_device_hotplug();
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(add_cpu);
+
#ifdef CONFIG_PM_SLEEP_SMP
static cpumask_var_t frozen_cpus;