aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 16:37:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 16:37:05 -0400
commit67dbfc142310698b979d12a689aa9e0b4a93dced (patch)
treedc43e4d7f6eae18818230057cf8de6036f8ad1d5
parent46e0d28bdb8e6d00e27a0fe9e1d15df6098f0ffb (diff)
parentfcb3029a8d89487470f2e175645a9a993949233c (diff)
Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull SMP hotplug updates from Ingo Molnar: "Simplify the CPU hot-plug state machine" * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: cpu/hotplug: Fix unused function warning cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states
-rw-r--r--kernel/cpu.c60
1 files changed, 24 insertions, 36 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 53f7dc65f9a3..0db8938fbb23 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -124,24 +124,11 @@ struct cpuhp_step {
124}; 124};
125 125
126static DEFINE_MUTEX(cpuhp_state_mutex); 126static DEFINE_MUTEX(cpuhp_state_mutex);
127static struct cpuhp_step cpuhp_bp_states[]; 127static struct cpuhp_step cpuhp_hp_states[];
128static struct cpuhp_step cpuhp_ap_states[];
129
130static bool cpuhp_is_ap_state(enum cpuhp_state state)
131{
132 /*
133 * The extra check for CPUHP_TEARDOWN_CPU is only for documentation
134 * purposes as that state is handled explicitly in cpu_down.
135 */
136 return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU;
137}
138 128
139static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state) 129static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state)
140{ 130{
141 struct cpuhp_step *sp; 131 return cpuhp_hp_states + state;
142
143 sp = cpuhp_is_ap_state(state) ? cpuhp_ap_states : cpuhp_bp_states;
144 return sp + state;
145} 132}
146 133
147/** 134/**
@@ -239,6 +226,15 @@ err:
239} 226}
240 227
241#ifdef CONFIG_SMP 228#ifdef CONFIG_SMP
229static bool cpuhp_is_ap_state(enum cpuhp_state state)
230{
231 /*
232 * The extra check for CPUHP_TEARDOWN_CPU is only for documentation
233 * purposes as that state is handled explicitly in cpu_down.
234 */
235 return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU;
236}
237
242static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup) 238static inline void wait_for_ap_thread(struct cpuhp_cpu_state *st, bool bringup)
243{ 239{
244 struct completion *done = bringup ? &st->done_up : &st->done_down; 240 struct completion *done = bringup ? &st->done_up : &st->done_down;
@@ -1224,7 +1220,7 @@ int __boot_cpu_id;
1224#endif /* CONFIG_SMP */ 1220#endif /* CONFIG_SMP */
1225 1221
1226/* Boot processor state steps */ 1222/* Boot processor state steps */
1227static struct cpuhp_step cpuhp_bp_states[] = { 1223static struct cpuhp_step cpuhp_hp_states[] = {
1228 [CPUHP_OFFLINE] = { 1224 [CPUHP_OFFLINE] = {
1229 .name = "offline", 1225 .name = "offline",
1230 .startup.single = NULL, 1226 .startup.single = NULL,
@@ -1289,24 +1285,6 @@ static struct cpuhp_step cpuhp_bp_states[] = {
1289 .teardown.single = NULL, 1285 .teardown.single = NULL,
1290 .cant_stop = true, 1286 .cant_stop = true,
1291 }, 1287 },
1292 /*
1293 * Handled on controll processor until the plugged processor manages
1294 * this itself.
1295 */
1296 [CPUHP_TEARDOWN_CPU] = {
1297 .name = "cpu:teardown",
1298 .startup.single = NULL,
1299 .teardown.single = takedown_cpu,
1300 .cant_stop = true,
1301 },
1302#else
1303 [CPUHP_BRINGUP_CPU] = { },
1304#endif
1305};
1306
1307/* Application processor state steps */
1308static struct cpuhp_step cpuhp_ap_states[] = {
1309#ifdef CONFIG_SMP
1310 /* Final state before CPU kills itself */ 1288 /* Final state before CPU kills itself */
1311 [CPUHP_AP_IDLE_DEAD] = { 1289 [CPUHP_AP_IDLE_DEAD] = {
1312 .name = "idle:dead", 1290 .name = "idle:dead",
@@ -1340,6 +1318,16 @@ static struct cpuhp_step cpuhp_ap_states[] = {
1340 [CPUHP_AP_ONLINE] = { 1318 [CPUHP_AP_ONLINE] = {
1341 .name = "ap:online", 1319 .name = "ap:online",
1342 }, 1320 },
1321 /*
1322 * Handled on controll processor until the plugged processor manages
1323 * this itself.
1324 */
1325 [CPUHP_TEARDOWN_CPU] = {
1326 .name = "cpu:teardown",
1327 .startup.single = NULL,
1328 .teardown.single = takedown_cpu,
1329 .cant_stop = true,
1330 },
1343 /* Handle smpboot threads park/unpark */ 1331 /* Handle smpboot threads park/unpark */
1344 [CPUHP_AP_SMPBOOT_THREADS] = { 1332 [CPUHP_AP_SMPBOOT_THREADS] = {
1345 .name = "smpboot/threads:online", 1333 .name = "smpboot/threads:online",
@@ -1408,11 +1396,11 @@ static int cpuhp_reserve_state(enum cpuhp_state state)
1408 1396
1409 switch (state) { 1397 switch (state) {
1410 case CPUHP_AP_ONLINE_DYN: 1398 case CPUHP_AP_ONLINE_DYN:
1411 step = cpuhp_ap_states + CPUHP_AP_ONLINE_DYN; 1399 step = cpuhp_hp_states + CPUHP_AP_ONLINE_DYN;
1412 end = CPUHP_AP_ONLINE_DYN_END; 1400 end = CPUHP_AP_ONLINE_DYN_END;
1413 break; 1401 break;
1414 case CPUHP_BP_PREPARE_DYN: 1402 case CPUHP_BP_PREPARE_DYN:
1415 step = cpuhp_bp_states + CPUHP_BP_PREPARE_DYN; 1403 step = cpuhp_hp_states + CPUHP_BP_PREPARE_DYN;
1416 end = CPUHP_BP_PREPARE_DYN_END; 1404 end = CPUHP_BP_PREPARE_DYN_END;
1417 break; 1405 break;
1418 default: 1406 default: