Skip to content

Commit 79a6cde

Browse files
Lai Jiangshantorvalds
authored andcommitted
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>
1 parent c9d221f commit 79a6cde

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

‎kernel/cpu.c‎

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,29 @@
2020
/* Serializes the updates to cpu_online_mask, cpu_present_mask */
2121
static DEFINE_MUTEX(cpu_add_remove_lock);
2222

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+
2337
static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain);
2438

2539
/* If set, cpu_up and cpu_down will return -EBUSY and do nothing.
2640
* Should always be manipulated under cpu_add_remove_lock
2741
*/
2842
static int cpu_hotplug_disabled;
2943

44+
#ifdef CONFIG_HOTPLUG_CPU
45+
3046
static struct {
3147
struct task_struct *active_writer;
3248
struct mutex lock; /* Synchronizes accesses to refcount, */
@@ -41,8 +57,6 @@ static struct {
4157
.refcount = 0,
4258
};
4359

44-
#ifdef CONFIG_HOTPLUG_CPU
45-
4660
void get_online_cpus(void)
4761
{
4862
might_sleep();
@@ -67,22 +81,6 @@ void put_online_cpus(void)
6781
}
6882
EXPORT_SYMBOL_GPL(put_online_cpus);
6983

70-
#endif /* CONFIG_HOTPLUG_CPU */
71-
72-
/*
73-
* The following two API's must be used when attempting
74-
* to serialize the updates to cpu_online_mask, cpu_present_mask.
75-
*/
76-
void cpu_maps_update_begin(void)
77-
{
78-
mutex_lock(&cpu_add_remove_lock);
79-
}
80-
81-
void cpu_maps_update_done(void)
82-
{
83-
mutex_unlock(&cpu_add_remove_lock);
84-
}
85-
8684
/*
8785
* This ensures that the hotplug operation can begin only when the
8886
* refcount goes to zero.
@@ -124,6 +122,12 @@ static void cpu_hotplug_done(void)
124122
cpu_hotplug.active_writer = NULL;
125123
mutex_unlock(&cpu_hotplug.lock);
126124
}
125+
126+
#else /* #if CONFIG_HOTPLUG_CPU */
127+
static void cpu_hotplug_begin(void) {}
128+
static void cpu_hotplug_done(void) {}
129+
#endif /* #esle #if CONFIG_HOTPLUG_CPU */
130+
127131
/* Need to know about CPUs going up/down? */
128132
int __ref register_cpu_notifier(struct notifier_block *nb)
129133
{

0 commit comments

Comments
 (0)