diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2016-09-05 09:28:36 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-05 09:32:58 -0400 |
commit | 3c1627e999e45e292d5d7ea3751ed86a6383ee2c (patch) | |
tree | ecd2a59d95cb06b211d9a2f046bdbf880e2ebca0 | |
parent | 01b41159066531cc8d664362ff0cd89dd137bbfa (diff) |
cpu/hotplug: Replace anon union
Some compilers are unhappy with the anon union in the state array. Replace
it with a named union.
While at it align the state array initializers proper and add the missing
name tags.
Fixes: cf392d10b69e "cpu/hotplug: Add multi instance support"
Reported-by: Ingo Molnar <mingo@kernel.org>
Reported-by: Fenguang Wu <fengguang.wu@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: rt@linutronix.de
-rw-r--r-- | kernel/cpu.c | 145 |
1 files changed, 74 insertions, 71 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index c90f839c5b86..2409ed717a3f 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -73,15 +73,15 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state); | |||
73 | struct cpuhp_step { | 73 | struct cpuhp_step { |
74 | const char *name; | 74 | const char *name; |
75 | union { | 75 | union { |
76 | int (*startup)(unsigned int cpu); | 76 | int (*single)(unsigned int cpu); |
77 | int (*startup_multi)(unsigned int cpu, | 77 | int (*multi)(unsigned int cpu, |
78 | struct hlist_node *node); | 78 | struct hlist_node *node); |
79 | }; | 79 | } startup; |
80 | union { | 80 | union { |
81 | int (*teardown)(unsigned int cpu); | 81 | int (*single)(unsigned int cpu); |
82 | int (*teardown_multi)(unsigned int cpu, | 82 | int (*multi)(unsigned int cpu, |
83 | struct hlist_node *node); | 83 | struct hlist_node *node); |
84 | }; | 84 | } teardown; |
85 | struct hlist_head list; | 85 | struct hlist_head list; |
86 | bool skip_onerr; | 86 | bool skip_onerr; |
87 | bool cant_stop; | 87 | bool cant_stop; |
@@ -127,7 +127,7 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state, | |||
127 | int ret, cnt; | 127 | int ret, cnt; |
128 | 128 | ||
129 | if (!step->multi_instance) { | 129 | if (!step->multi_instance) { |
130 | cb = bringup ? step->startup : step->teardown; | 130 | cb = bringup ? step->startup.single : step->teardown.single; |
131 | if (!cb) | 131 | if (!cb) |
132 | return 0; | 132 | return 0; |
133 | trace_cpuhp_enter(cpu, st->target, state, cb); | 133 | trace_cpuhp_enter(cpu, st->target, state, cb); |
@@ -135,7 +135,7 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state, | |||
135 | trace_cpuhp_exit(cpu, st->state, state, ret); | 135 | trace_cpuhp_exit(cpu, st->state, state, ret); |
136 | return ret; | 136 | return ret; |
137 | } | 137 | } |
138 | cbm = bringup ? step->startup_multi : step->teardown_multi; | 138 | cbm = bringup ? step->startup.multi : step->teardown.multi; |
139 | if (!cbm) | 139 | if (!cbm) |
140 | return 0; | 140 | return 0; |
141 | 141 | ||
@@ -160,7 +160,7 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state, | |||
160 | return 0; | 160 | return 0; |
161 | err: | 161 | err: |
162 | /* Rollback the instances if one failed */ | 162 | /* Rollback the instances if one failed */ |
163 | cbm = !bringup ? step->startup_multi : step->teardown_multi; | 163 | cbm = !bringup ? step->startup.multi : step->teardown.multi; |
164 | if (!cbm) | 164 | if (!cbm) |
165 | return ret; | 165 | return ret; |
166 | 166 | ||
@@ -1256,40 +1256,40 @@ core_initcall(cpu_hotplug_pm_sync_init); | |||
1256 | static struct cpuhp_step cpuhp_bp_states[] = { | 1256 | static struct cpuhp_step cpuhp_bp_states[] = { |
1257 | [CPUHP_OFFLINE] = { | 1257 | [CPUHP_OFFLINE] = { |
1258 | .name = "offline", | 1258 | .name = "offline", |
1259 | .startup = NULL, | 1259 | .startup.single = NULL, |
1260 | .teardown = NULL, | 1260 | .teardown.single = NULL, |
1261 | }, | 1261 | }, |
1262 | #ifdef CONFIG_SMP | 1262 | #ifdef CONFIG_SMP |
1263 | [CPUHP_CREATE_THREADS]= { | 1263 | [CPUHP_CREATE_THREADS]= { |
1264 | .name = "threads:create", | 1264 | .name = "threads:create", |
1265 | .startup = smpboot_create_threads, | 1265 | .startup.single = smpboot_create_threads, |
1266 | .teardown = NULL, | 1266 | .teardown.single = NULL, |
1267 | .cant_stop = true, | 1267 | .cant_stop = true, |
1268 | }, | 1268 | }, |
1269 | [CPUHP_PERF_PREPARE] = { | 1269 | [CPUHP_PERF_PREPARE] = { |
1270 | .name = "perf prepare", | 1270 | .name = "perf:prepare", |
1271 | .startup = perf_event_init_cpu, | 1271 | .startup.single = perf_event_init_cpu, |
1272 | .teardown = perf_event_exit_cpu, | 1272 | .teardown.single = perf_event_exit_cpu, |
1273 | }, | 1273 | }, |
1274 | [CPUHP_WORKQUEUE_PREP] = { | 1274 | [CPUHP_WORKQUEUE_PREP] = { |
1275 | .name = "workqueue prepare", | 1275 | .name = "workqueue:prepare", |
1276 | .startup = workqueue_prepare_cpu, | 1276 | .startup.single = workqueue_prepare_cpu, |
1277 | .teardown = NULL, | 1277 | .teardown.single = NULL, |
1278 | }, | 1278 | }, |
1279 | [CPUHP_HRTIMERS_PREPARE] = { | 1279 | [CPUHP_HRTIMERS_PREPARE] = { |
1280 | .name = "hrtimers prepare", | 1280 | .name = "hrtimers:prepare", |
1281 | .startup = hrtimers_prepare_cpu, | 1281 | .startup.single = hrtimers_prepare_cpu, |
1282 | .teardown = hrtimers_dead_cpu, | 1282 | .teardown.single = hrtimers_dead_cpu, |
1283 | }, | 1283 | }, |
1284 | [CPUHP_SMPCFD_PREPARE] = { | 1284 | [CPUHP_SMPCFD_PREPARE] = { |
1285 | .name = "SMPCFD prepare", | 1285 | .name = "SMPCFD:prepare", |
1286 | .startup = smpcfd_prepare_cpu, | 1286 | .startup.single = smpcfd_prepare_cpu, |
1287 | .teardown = smpcfd_dead_cpu, | 1287 | .teardown.single = smpcfd_dead_cpu, |
1288 | }, | 1288 | }, |
1289 | [CPUHP_RCUTREE_PREP] = { | 1289 | [CPUHP_RCUTREE_PREP] = { |
1290 | .name = "RCU-tree prepare", | 1290 | .name = "RCU-tree:prepare", |
1291 | .startup = rcutree_prepare_cpu, | 1291 | .startup.single = rcutree_prepare_cpu, |
1292 | .teardown = rcutree_dead_cpu, | 1292 | .teardown.single = rcutree_dead_cpu, |
1293 | }, | 1293 | }, |
1294 | /* | 1294 | /* |
1295 | * Preparatory and dead notifiers. Will be replaced once the notifiers | 1295 | * Preparatory and dead notifiers. Will be replaced once the notifiers |
@@ -1297,8 +1297,8 @@ static struct cpuhp_step cpuhp_bp_states[] = { | |||
1297 | */ | 1297 | */ |
1298 | [CPUHP_NOTIFY_PREPARE] = { | 1298 | [CPUHP_NOTIFY_PREPARE] = { |
1299 | .name = "notify:prepare", | 1299 | .name = "notify:prepare", |
1300 | .startup = notify_prepare, | 1300 | .startup.single = notify_prepare, |
1301 | .teardown = notify_dead, | 1301 | .teardown.single = notify_dead, |
1302 | .skip_onerr = true, | 1302 | .skip_onerr = true, |
1303 | .cant_stop = true, | 1303 | .cant_stop = true, |
1304 | }, | 1304 | }, |
@@ -1308,20 +1308,21 @@ static struct cpuhp_step cpuhp_bp_states[] = { | |||
1308 | * otherwise a RCU stall occurs. | 1308 | * otherwise a RCU stall occurs. |
1309 | */ | 1309 | */ |
1310 | [CPUHP_TIMERS_DEAD] = { | 1310 | [CPUHP_TIMERS_DEAD] = { |
1311 | .name = "timers dead", | 1311 | .name = "timers:dead", |
1312 | .startup = NULL, | 1312 | .startup.single = NULL, |
1313 | .teardown = timers_dead_cpu, | 1313 | .teardown.single = timers_dead_cpu, |
1314 | }, | 1314 | }, |
1315 | /* Kicks the plugged cpu into life */ | 1315 | /* Kicks the plugged cpu into life */ |
1316 | [CPUHP_BRINGUP_CPU] = { | 1316 | [CPUHP_BRINGUP_CPU] = { |
1317 | .name = "cpu:bringup", | 1317 | .name = "cpu:bringup", |
1318 | .startup = bringup_cpu, | 1318 | .startup.single = bringup_cpu, |
1319 | .teardown = NULL, | 1319 | .teardown.single = NULL, |
1320 | .cant_stop = true, | 1320 | .cant_stop = true, |
1321 | }, | 1321 | }, |
1322 | [CPUHP_AP_SMPCFD_DYING] = { | 1322 | [CPUHP_AP_SMPCFD_DYING] = { |
1323 | .startup = NULL, | 1323 | .name = "SMPCFD:dying", |
1324 | .teardown = smpcfd_dying_cpu, | 1324 | .startup.single = NULL, |
1325 | .teardown.single = smpcfd_dying_cpu, | ||
1325 | }, | 1326 | }, |
1326 | /* | 1327 | /* |
1327 | * Handled on controll processor until the plugged processor manages | 1328 | * Handled on controll processor until the plugged processor manages |
@@ -1329,8 +1330,8 @@ static struct cpuhp_step cpuhp_bp_states[] = { | |||
1329 | */ | 1330 | */ |
1330 | [CPUHP_TEARDOWN_CPU] = { | 1331 | [CPUHP_TEARDOWN_CPU] = { |
1331 | .name = "cpu:teardown", | 1332 | .name = "cpu:teardown", |
1332 | .startup = NULL, | 1333 | .startup.single = NULL, |
1333 | .teardown = takedown_cpu, | 1334 | .teardown.single = takedown_cpu, |
1334 | .cant_stop = true, | 1335 | .cant_stop = true, |
1335 | }, | 1336 | }, |
1336 | #else | 1337 | #else |
@@ -1356,22 +1357,23 @@ static struct cpuhp_step cpuhp_ap_states[] = { | |||
1356 | /* First state is scheduler control. Interrupts are disabled */ | 1357 | /* First state is scheduler control. Interrupts are disabled */ |
1357 | [CPUHP_AP_SCHED_STARTING] = { | 1358 | [CPUHP_AP_SCHED_STARTING] = { |
1358 | .name = "sched:starting", | 1359 | .name = "sched:starting", |
1359 | .startup = sched_cpu_starting, | 1360 | .startup.single = sched_cpu_starting, |
1360 | .teardown = sched_cpu_dying, | 1361 | .teardown.single = sched_cpu_dying, |
1361 | }, | 1362 | }, |
1362 | [CPUHP_AP_RCUTREE_DYING] = { | 1363 | [CPUHP_AP_RCUTREE_DYING] = { |
1363 | .startup = NULL, | 1364 | .name = "RCU-tree:dying", |
1364 | .teardown = rcutree_dying_cpu, | 1365 | .startup.single = NULL, |
1366 | .teardown.single = rcutree_dying_cpu, | ||
1365 | }, | 1367 | }, |
1366 | /* | 1368 | /* |
1367 | * Low level startup/teardown notifiers. Run with interrupts | 1369 | * Low level startup.single/teardown notifiers. Run with interrupts |
1368 | * disabled. Will be removed once the notifiers are converted to | 1370 | * disabled. Will be removed once the notifiers are converted to |
1369 | * states. | 1371 | * states. |
1370 | */ | 1372 | */ |
1371 | [CPUHP_AP_NOTIFY_STARTING] = { | 1373 | [CPUHP_AP_NOTIFY_STARTING] = { |
1372 | .name = "notify:starting", | 1374 | .name = "notify:starting", |
1373 | .startup = notify_starting, | 1375 | .startup.single = notify_starting, |
1374 | .teardown = notify_dying, | 1376 | .teardown.single = notify_dying, |
1375 | .skip_onerr = true, | 1377 | .skip_onerr = true, |
1376 | .cant_stop = true, | 1378 | .cant_stop = true, |
1377 | }, | 1379 | }, |
@@ -1383,23 +1385,23 @@ static struct cpuhp_step cpuhp_ap_states[] = { | |||
1383 | /* Handle smpboot threads park/unpark */ | 1385 | /* Handle smpboot threads park/unpark */ |
1384 | [CPUHP_AP_SMPBOOT_THREADS] = { | 1386 | [CPUHP_AP_SMPBOOT_THREADS] = { |
1385 | .name = "smpboot:threads", | 1387 | .name = "smpboot:threads", |
1386 | .startup = smpboot_unpark_threads, | 1388 | .startup.single = smpboot_unpark_threads, |
1387 | .teardown = NULL, | 1389 | .teardown.single = NULL, |
1388 | }, | 1390 | }, |
1389 | [CPUHP_AP_PERF_ONLINE] = { | 1391 | [CPUHP_AP_PERF_ONLINE] = { |
1390 | .name = "perf online", | 1392 | .name = "perf:online", |
1391 | .startup = perf_event_init_cpu, | 1393 | .startup.single = perf_event_init_cpu, |
1392 | .teardown = perf_event_exit_cpu, | 1394 | .teardown.single = perf_event_exit_cpu, |
1393 | }, | 1395 | }, |
1394 | [CPUHP_AP_WORKQUEUE_ONLINE] = { | 1396 | [CPUHP_AP_WORKQUEUE_ONLINE] = { |
1395 | .name = "workqueue online", | 1397 | .name = "workqueue:online", |
1396 | .startup = workqueue_online_cpu, | 1398 | .startup.single = workqueue_online_cpu, |
1397 | .teardown = workqueue_offline_cpu, | 1399 | .teardown.single = workqueue_offline_cpu, |
1398 | }, | 1400 | }, |
1399 | [CPUHP_AP_RCUTREE_ONLINE] = { | 1401 | [CPUHP_AP_RCUTREE_ONLINE] = { |
1400 | .name = "RCU-tree online", | 1402 | .name = "RCU-tree:online", |
1401 | .startup = rcutree_online_cpu, | 1403 | .startup.single = rcutree_online_cpu, |
1402 | .teardown = rcutree_offline_cpu, | 1404 | .teardown.single = rcutree_offline_cpu, |
1403 | }, | 1405 | }, |
1404 | 1406 | ||
1405 | /* | 1407 | /* |
@@ -1408,8 +1410,8 @@ static struct cpuhp_step cpuhp_ap_states[] = { | |||
1408 | */ | 1410 | */ |
1409 | [CPUHP_AP_NOTIFY_ONLINE] = { | 1411 | [CPUHP_AP_NOTIFY_ONLINE] = { |
1410 | .name = "notify:online", | 1412 | .name = "notify:online", |
1411 | .startup = notify_online, | 1413 | .startup.single = notify_online, |
1412 | .teardown = notify_down_prepare, | 1414 | .teardown.single = notify_down_prepare, |
1413 | .skip_onerr = true, | 1415 | .skip_onerr = true, |
1414 | }, | 1416 | }, |
1415 | #endif | 1417 | #endif |
@@ -1421,16 +1423,16 @@ static struct cpuhp_step cpuhp_ap_states[] = { | |||
1421 | /* Last state is scheduler control setting the cpu active */ | 1423 | /* Last state is scheduler control setting the cpu active */ |
1422 | [CPUHP_AP_ACTIVE] = { | 1424 | [CPUHP_AP_ACTIVE] = { |
1423 | .name = "sched:active", | 1425 | .name = "sched:active", |
1424 | .startup = sched_cpu_activate, | 1426 | .startup.single = sched_cpu_activate, |
1425 | .teardown = sched_cpu_deactivate, | 1427 | .teardown.single = sched_cpu_deactivate, |
1426 | }, | 1428 | }, |
1427 | #endif | 1429 | #endif |
1428 | 1430 | ||
1429 | /* CPU is fully up and running. */ | 1431 | /* CPU is fully up and running. */ |
1430 | [CPUHP_ONLINE] = { | 1432 | [CPUHP_ONLINE] = { |
1431 | .name = "online", | 1433 | .name = "online", |
1432 | .startup = NULL, | 1434 | .startup.single = NULL, |
1433 | .teardown = NULL, | 1435 | .teardown.single = NULL, |
1434 | }, | 1436 | }, |
1435 | }; | 1437 | }; |
1436 | 1438 | ||
@@ -1453,8 +1455,8 @@ static void cpuhp_store_callbacks(enum cpuhp_state state, | |||
1453 | 1455 | ||
1454 | mutex_lock(&cpuhp_state_mutex); | 1456 | mutex_lock(&cpuhp_state_mutex); |
1455 | sp = cpuhp_get_step(state); | 1457 | sp = cpuhp_get_step(state); |
1456 | sp->startup = startup; | 1458 | sp->startup.single = startup; |
1457 | sp->teardown = teardown; | 1459 | sp->teardown.single = teardown; |
1458 | sp->name = name; | 1460 | sp->name = name; |
1459 | sp->multi_instance = multi_instance; | 1461 | sp->multi_instance = multi_instance; |
1460 | INIT_HLIST_HEAD(&sp->list); | 1462 | INIT_HLIST_HEAD(&sp->list); |
@@ -1463,7 +1465,7 @@ static void cpuhp_store_callbacks(enum cpuhp_state state, | |||
1463 | 1465 | ||
1464 | static void *cpuhp_get_teardown_cb(enum cpuhp_state state) | 1466 | static void *cpuhp_get_teardown_cb(enum cpuhp_state state) |
1465 | { | 1467 | { |
1466 | return cpuhp_get_step(state)->teardown; | 1468 | return cpuhp_get_step(state)->teardown.single; |
1467 | } | 1469 | } |
1468 | 1470 | ||
1469 | /* | 1471 | /* |
@@ -1476,7 +1478,8 @@ static int cpuhp_issue_call(int cpu, enum cpuhp_state state, bool bringup, | |||
1476 | struct cpuhp_step *sp = cpuhp_get_step(state); | 1478 | struct cpuhp_step *sp = cpuhp_get_step(state); |
1477 | int ret; | 1479 | int ret; |
1478 | 1480 | ||
1479 | if ((bringup && !sp->startup) || (!bringup && !sp->teardown)) | 1481 | if ((bringup && !sp->startup.single) || |
1482 | (!bringup && !sp->teardown.single)) | ||
1480 | return 0; | 1483 | return 0; |
1481 | /* | 1484 | /* |
1482 | * The non AP bound callbacks can fail on bringup. On teardown | 1485 | * The non AP bound callbacks can fail on bringup. On teardown |
@@ -1554,7 +1557,7 @@ int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, | |||
1554 | 1557 | ||
1555 | get_online_cpus(); | 1558 | get_online_cpus(); |
1556 | 1559 | ||
1557 | if (!invoke || !sp->startup_multi) | 1560 | if (!invoke || !sp->startup.multi) |
1558 | goto add_node; | 1561 | goto add_node; |
1559 | 1562 | ||
1560 | /* | 1563 | /* |
@@ -1570,7 +1573,7 @@ int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, | |||
1570 | 1573 | ||
1571 | ret = cpuhp_issue_call(cpu, state, true, node); | 1574 | ret = cpuhp_issue_call(cpu, state, true, node); |
1572 | if (ret) { | 1575 | if (ret) { |
1573 | if (sp->teardown_multi) | 1576 | if (sp->teardown.multi) |
1574 | cpuhp_rollback_install(cpu, state, node); | 1577 | cpuhp_rollback_install(cpu, state, node); |
1575 | goto err; | 1578 | goto err; |
1576 | } | 1579 | } |