From: Srivatsa S. Bhat Date: Thu, 23 May 2013 00:36:52 +0000 (+1000) Subject: cpu-hotplug-provide-a-generic-helper-to-disable-enable-cpu-hotplug-v11 X-Git-Tag: next-20130527~1^2~267 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4377363fa860fd2785126f7895e6d50751cf4113;p=karo-tx-linux.git cpu-hotplug-provide-a-generic-helper-to-disable-enable-cpu-hotplug-v11 Signed-off-by: Srivatsa S. Bhat Signed-off-by: Robin Holt Signed-off-by: Andrew Morton --- diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 73f02a3e6ab7..9f3c7e81270a 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -168,20 +168,6 @@ static inline void cpu_maps_update_done(void) } #endif /* CONFIG_SMP */ - -#ifdef CONFIG_PM_SLEEP_SMP -extern void cpu_hotplug_enable(void); -extern void cpu_hotplug_disable(void); -#else -static inline void cpu_hotplug_enable(void) -{ -} - -static inline void cpu_hotplug_disable(void) -{ -} -#endif - extern struct bus_type cpu_subsys; #ifdef CONFIG_HOTPLUG_CPU @@ -189,6 +175,8 @@ extern struct bus_type cpu_subsys; extern void get_online_cpus(void); extern void put_online_cpus(void); +extern void cpu_hotplug_disable(void); +extern void cpu_hotplug_enable(void); #define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri) #define register_hotcpu_notifier(nb) register_cpu_notifier(nb) #define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) @@ -212,6 +200,8 @@ static inline void cpu_hotplug_driver_unlock(void) #define get_online_cpus() do { } while (0) #define put_online_cpus() do { } while (0) +#define cpu_hotplug_disable() do { } while (0) +#define cpu_hotplug_enable() do { } while (0) #define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) /* These aren't inline functions due to a GCC bug. */ #define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) diff --git a/kernel/cpu.c b/kernel/cpu.c index 28769f5ca9a4..198a38883e64 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -133,6 +133,27 @@ static void cpu_hotplug_done(void) mutex_unlock(&cpu_hotplug.lock); } +/* + * Wait for currently running CPU hotplug operations to complete (if any) and + * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects + * the 'cpu_hotplug_disabled' flag. The same lock is also acquired by the + * hotplug path before performing hotplug operations. So acquiring that lock + * guarantees mutual exclusion from any currently running hotplug operations. + */ +void cpu_hotplug_disable(void) +{ + cpu_maps_update_begin(); + cpu_hotplug_disabled = 1; + cpu_maps_update_done(); +} + +void cpu_hotplug_enable(void) +{ + cpu_maps_update_begin(); + cpu_hotplug_disabled = 0; + cpu_maps_update_done(); +} + #else /* #if CONFIG_HOTPLUG_CPU */ static void cpu_hotplug_begin(void) {} static void cpu_hotplug_done(void) {} @@ -540,27 +561,6 @@ static int __init alloc_frozen_cpus(void) } core_initcall(alloc_frozen_cpus); -/* - * Wait for currently running CPU hotplug operations to complete (if any) and - * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects - * the 'cpu_hotplug_disabled' flag. The same lock is also acquired by the - * hotplug path before performing hotplug operations. So acquiring that lock - * guarantees mutual exclusion from any currently running hotplug operations. - */ -void cpu_hotplug_disable(void) -{ - cpu_maps_update_begin(); - cpu_hotplug_disabled = 1; - cpu_maps_update_done(); -} - -void cpu_hotplug_enable(void) -{ - cpu_maps_update_begin(); - cpu_hotplug_disabled = 0; - cpu_maps_update_done(); -} - /* * When callbacks for CPU hotplug notifications are being executed, we must * ensure that the state of the system with respect to the tasks being frozen