Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpuhotplug: do not need cpu_hotplug_begin() when CONFIG_HOTPLUG_CPU=n

Since when CONFIG_HOTPLUG_CPU=n, get_online_cpus() do nothing, so we don't
need cpu_hotplug_begin() either.

This patch moves cpu_hotplug_begin()/cpu_hotplug_done() into the code
block of CONFIG_HOTPLUG_CPU=y.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Gautham R Shenoy <ego@in.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Lai Jiangshan and committed by
Linus Torvalds
79a6cdeb c9d221f8

+22 -18
+22 -18
kernel/cpu.c
··· 20 20 /* Serializes the updates to cpu_online_mask, cpu_present_mask */ 21 21 static DEFINE_MUTEX(cpu_add_remove_lock); 22 22 23 + /* 24 + * The following two API's must be used when attempting 25 + * to serialize the updates to cpu_online_mask, cpu_present_mask. 26 + */ 27 + void cpu_maps_update_begin(void) 28 + { 29 + mutex_lock(&cpu_add_remove_lock); 30 + } 31 + 32 + void cpu_maps_update_done(void) 33 + { 34 + mutex_unlock(&cpu_add_remove_lock); 35 + } 36 + 23 37 static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); 24 38 25 39 /* If set, cpu_up and cpu_down will return -EBUSY and do nothing. 26 40 * Should always be manipulated under cpu_add_remove_lock 27 41 */ 28 42 static int cpu_hotplug_disabled; 43 + 44 + #ifdef CONFIG_HOTPLUG_CPU 29 45 30 46 static struct { 31 47 struct task_struct *active_writer; ··· 56 40 .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), 57 41 .refcount = 0, 58 42 }; 59 - 60 - #ifdef CONFIG_HOTPLUG_CPU 61 43 62 44 void get_online_cpus(void) 63 45 { ··· 80 66 81 67 } 82 68 EXPORT_SYMBOL_GPL(put_online_cpus); 83 - 84 - #endif /* CONFIG_HOTPLUG_CPU */ 85 - 86 - /* 87 - * The following two API's must be used when attempting 88 - * to serialize the updates to cpu_online_mask, cpu_present_mask. 89 - */ 90 - void cpu_maps_update_begin(void) 91 - { 92 - mutex_lock(&cpu_add_remove_lock); 93 - } 94 - 95 - void cpu_maps_update_done(void) 96 - { 97 - mutex_unlock(&cpu_add_remove_lock); 98 - } 99 69 100 70 /* 101 71 * This ensures that the hotplug operation can begin only when the ··· 122 124 cpu_hotplug.active_writer = NULL; 123 125 mutex_unlock(&cpu_hotplug.lock); 124 126 } 127 + 128 + #else /* #if CONFIG_HOTPLUG_CPU */ 129 + static void cpu_hotplug_begin(void) {} 130 + static void cpu_hotplug_done(void) {} 131 + #endif /* #esle #if CONFIG_HOTPLUG_CPU */ 132 + 125 133 /* Need to know about CPUs going up/down? */ 126 134 int __ref register_cpu_notifier(struct notifier_block *nb) 127 135 {