22
22
* AP_ACTIVE AP_ACTIVE
23
23
*/
24
24
25
+ /*
26
+ * CPU hotplug states. The state machine invokes the installed state
27
+ * startup callbacks sequentially from CPUHP_OFFLINE + 1 to CPUHP_ONLINE
28
+ * during a CPU online operation. During a CPU offline operation the
29
+ * installed teardown callbacks are invoked in the reverse order from
30
+ * CPU_ONLINE - 1 down to CPUHP_OFFLINE.
31
+ *
32
+ * The state space has three sections: PREPARE, STARTING and ONLINE.
33
+ *
34
+ * PREPARE: The callbacks are invoked on a control CPU before the
35
+ * hotplugged CPU is started up or after the hotplugged CPU has died.
36
+ *
37
+ * STARTING: The callbacks are invoked on the hotplugged CPU from the low level
38
+ * hotplug startup/teardown code with interrupts disabled.
39
+ *
40
+ * ONLINE: The callbacks are invoked on the hotplugged CPU from the per CPU
41
+ * hotplug thread with interrupts and preemption enabled.
42
+ *
43
+ * Adding explicit states to this enum is only necessary when:
44
+ *
45
+ * 1) The state is within the STARTING section
46
+ *
47
+ * 2) The state has ordering constraints vs. other states in the
48
+ * same section.
49
+ *
50
+ * If neither #1 nor #2 apply, please use the dynamic state space when
51
+ * setting up a state by using CPUHP_PREPARE_DYN or CPUHP_PREPARE_ONLINE
52
+ * for the @state argument of the setup function.
53
+ *
54
+ * See Documentation/core-api/cpu_hotplug.rst for further information and
55
+ * examples.
56
+ */
25
57
enum cpuhp_state {
26
58
CPUHP_INVALID = -1 ,
59
+
60
+ /* PREPARE section invoked on a control CPU */
27
61
CPUHP_OFFLINE = 0 ,
28
62
CPUHP_CREATE_THREADS ,
29
63
CPUHP_PERF_PREPARE ,
@@ -95,6 +129,11 @@ enum cpuhp_state {
95
129
CPUHP_BP_PREPARE_DYN ,
96
130
CPUHP_BP_PREPARE_DYN_END = CPUHP_BP_PREPARE_DYN + 20 ,
97
131
CPUHP_BRINGUP_CPU ,
132
+
133
+ /*
134
+ * STARTING section invoked on the hotplugged CPU in low level
135
+ * bringup and teardown code.
136
+ */
98
137
CPUHP_AP_IDLE_DEAD ,
99
138
CPUHP_AP_OFFLINE ,
100
139
CPUHP_AP_SCHED_STARTING ,
@@ -155,6 +194,8 @@ enum cpuhp_state {
155
194
CPUHP_AP_ARM_CACHE_B15_RAC_DYING ,
156
195
CPUHP_AP_ONLINE ,
157
196
CPUHP_TEARDOWN_CPU ,
197
+
198
+ /* Online section invoked on the hotplugged CPU from the hotplug thread */
158
199
CPUHP_AP_ONLINE_IDLE ,
159
200
CPUHP_AP_SCHED_WAIT_EMPTY ,
160
201
CPUHP_AP_SMPBOOT_THREADS ,
@@ -216,14 +257,15 @@ int __cpuhp_setup_state_cpuslocked(enum cpuhp_state state, const char *name,
216
257
int (* teardown )(unsigned int cpu ),
217
258
bool multi_instance );
218
259
/**
219
- * cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks
260
+ * cpuhp_setup_state - Setup hotplug state callbacks with calling the @startup
261
+ * callback
220
262
* @state: The state for which the calls are installed
221
263
* @name: Name of the callback (will be used in debug output)
222
- * @startup: startup callback function
223
- * @teardown: teardown callback function
264
+ * @startup: startup callback function or NULL if not required
265
+ * @teardown: teardown callback function or NULL if not required
224
266
*
225
- * Installs the callback functions and invokes the startup callback on
226
- * the present cpus which have already reached the @state.
267
+ * Installs the callback functions and invokes the @ startup callback on
268
+ * the online cpus which have already reached the @state.
227
269
*/
228
270
static inline int cpuhp_setup_state (enum cpuhp_state state ,
229
271
const char * name ,
@@ -233,6 +275,18 @@ static inline int cpuhp_setup_state(enum cpuhp_state state,
233
275
return __cpuhp_setup_state (state , name , true, startup , teardown , false);
234
276
}
235
277
278
+ /**
279
+ * cpuhp_setup_state_cpuslocked - Setup hotplug state callbacks with calling
280
+ * @startup callback from a cpus_read_lock()
281
+ * held region
282
+ * @state: The state for which the calls are installed
283
+ * @name: Name of the callback (will be used in debug output)
284
+ * @startup: startup callback function or NULL if not required
285
+ * @teardown: teardown callback function or NULL if not required
286
+ *
287
+ * Same as cpuhp_setup_state() except that it must be invoked from within a
288
+ * cpus_read_lock() held region.
289
+ */
236
290
static inline int cpuhp_setup_state_cpuslocked (enum cpuhp_state state ,
237
291
const char * name ,
238
292
int (* startup )(unsigned int cpu ),
@@ -244,14 +298,14 @@ static inline int cpuhp_setup_state_cpuslocked(enum cpuhp_state state,
244
298
245
299
/**
246
300
* cpuhp_setup_state_nocalls - Setup hotplug state callbacks without calling the
247
- * callbacks
301
+ * @startup callback
248
302
* @state: The state for which the calls are installed
249
303
* @name: Name of the callback.
250
- * @startup: startup callback function
251
- * @teardown: teardown callback function
304
+ * @startup: startup callback function or NULL if not required
305
+ * @teardown: teardown callback function or NULL if not required
252
306
*
253
- * Same as @ cpuhp_setup_state except that no calls are executed are invoked
254
- * during installation of this callback . NOP if SMP=n or HOTPLUG_CPU=n.
307
+ * Same as cpuhp_setup_state() except that the @startup callback is not
308
+ * invoked during installation. NOP if SMP=n or HOTPLUG_CPU=n.
255
309
*/
256
310
static inline int cpuhp_setup_state_nocalls (enum cpuhp_state state ,
257
311
const char * name ,
@@ -262,6 +316,19 @@ static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state,
262
316
false);
263
317
}
264
318
319
+ /**
320
+ * cpuhp_setup_state_nocalls_cpuslocked - Setup hotplug state callbacks without
321
+ * invoking the @startup callback from
322
+ * a cpus_read_lock() held region
323
+ * callbacks
324
+ * @state: The state for which the calls are installed
325
+ * @name: Name of the callback.
326
+ * @startup: startup callback function or NULL if not required
327
+ * @teardown: teardown callback function or NULL if not required
328
+ *
329
+ * Same as cpuhp_setup_state_nocalls() except that it must be invoked from
330
+ * within a cpus_read_lock() held region.
331
+ */
265
332
static inline int cpuhp_setup_state_nocalls_cpuslocked (enum cpuhp_state state ,
266
333
const char * name ,
267
334
int (* startup )(unsigned int cpu ),
@@ -275,13 +342,13 @@ static inline int cpuhp_setup_state_nocalls_cpuslocked(enum cpuhp_state state,
275
342
* cpuhp_setup_state_multi - Add callbacks for multi state
276
343
* @state: The state for which the calls are installed
277
344
* @name: Name of the callback.
278
- * @startup: startup callback function
279
- * @teardown: teardown callback function
345
+ * @startup: startup callback function or NULL if not required
346
+ * @teardown: teardown callback function or NULL if not required
280
347
*
281
348
* Sets the internal multi_instance flag and prepares a state to work as a multi
282
349
* instance callback. No callbacks are invoked at this point. The callbacks are
283
350
* invoked once an instance for this state are registered via
284
- * @ cpuhp_state_add_instance or @ cpuhp_state_add_instance_nocalls.
351
+ * cpuhp_state_add_instance() or cpuhp_state_add_instance_nocalls()
285
352
*/
286
353
static inline int cpuhp_setup_state_multi (enum cpuhp_state state ,
287
354
const char * name ,
@@ -306,9 +373,10 @@ int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state,
306
373
* @state: The state for which the instance is installed
307
374
* @node: The node for this individual state.
308
375
*
309
- * Installs the instance for the @state and invokes the startup callback on
310
- * the present cpus which have already reached the @state. The @state must have
311
- * been earlier marked as multi-instance by @cpuhp_setup_state_multi.
376
+ * Installs the instance for the @state and invokes the registered startup
377
+ * callback on the online cpus which have already reached the @state. The
378
+ * @state must have been earlier marked as multi-instance by
379
+ * cpuhp_setup_state_multi().
312
380
*/
313
381
static inline int cpuhp_state_add_instance (enum cpuhp_state state ,
314
382
struct hlist_node * node )
@@ -322,15 +390,27 @@ static inline int cpuhp_state_add_instance(enum cpuhp_state state,
322
390
* @state: The state for which the instance is installed
323
391
* @node: The node for this individual state.
324
392
*
325
- * Installs the instance for the @state The @state must have been earlier
326
- * marked as multi-instance by @cpuhp_setup_state_multi.
393
+ * Installs the instance for the @state. The @state must have been earlier
394
+ * marked as multi-instance by cpuhp_setup_state_multi. NOP if SMP=n or
395
+ * HOTPLUG_CPU=n.
327
396
*/
328
397
static inline int cpuhp_state_add_instance_nocalls (enum cpuhp_state state ,
329
398
struct hlist_node * node )
330
399
{
331
400
return __cpuhp_state_add_instance (state , node , false);
332
401
}
333
402
403
+ /**
404
+ * cpuhp_state_add_instance_nocalls_cpuslocked - Add an instance for a state
405
+ * without invoking the startup
406
+ * callback from a cpus_read_lock()
407
+ * held region.
408
+ * @state: The state for which the instance is installed
409
+ * @node: The node for this individual state.
410
+ *
411
+ * Same as cpuhp_state_add_instance_nocalls() except that it must be
412
+ * invoked from within a cpus_read_lock() held region.
413
+ */
334
414
static inline int
335
415
cpuhp_state_add_instance_nocalls_cpuslocked (enum cpuhp_state state ,
336
416
struct hlist_node * node )
@@ -346,7 +426,7 @@ void __cpuhp_remove_state_cpuslocked(enum cpuhp_state state, bool invoke);
346
426
* @state: The state for which the calls are removed
347
427
*
348
428
* Removes the callback functions and invokes the teardown callback on
349
- * the present cpus which have already reached the @state.
429
+ * the online cpus which have already reached the @state.
350
430
*/
351
431
static inline void cpuhp_remove_state (enum cpuhp_state state )
352
432
{
@@ -355,14 +435,22 @@ static inline void cpuhp_remove_state(enum cpuhp_state state)
355
435
356
436
/**
357
437
* cpuhp_remove_state_nocalls - Remove hotplug state callbacks without invoking
358
- * teardown
438
+ * the teardown callback
359
439
* @state: The state for which the calls are removed
360
440
*/
361
441
static inline void cpuhp_remove_state_nocalls (enum cpuhp_state state )
362
442
{
363
443
__cpuhp_remove_state (state , false);
364
444
}
365
445
446
+ /**
447
+ * cpuhp_remove_state_nocalls_cpuslocked - Remove hotplug state callbacks without invoking
448
+ * teardown from a cpus_read_lock() held region.
449
+ * @state: The state for which the calls are removed
450
+ *
451
+ * Same as cpuhp_remove_state nocalls() except that it must be invoked
452
+ * from within a cpus_read_lock() held region.
453
+ */
366
454
static inline void cpuhp_remove_state_nocalls_cpuslocked (enum cpuhp_state state )
367
455
{
368
456
__cpuhp_remove_state_cpuslocked (state , false);
@@ -390,8 +478,8 @@ int __cpuhp_state_remove_instance(enum cpuhp_state state,
390
478
* @state: The state from which the instance is removed
391
479
* @node: The node for this individual state.
392
480
*
393
- * Removes the instance and invokes the teardown callback on the present cpus
394
- * which have already reached the @state.
481
+ * Removes the instance and invokes the teardown callback on the online cpus
482
+ * which have already reached @state.
395
483
*/
396
484
static inline int cpuhp_state_remove_instance (enum cpuhp_state state ,
397
485
struct hlist_node * node )
0 commit comments