xref: /linux-6.15/include/linux/cpuhotplug.h (revision 56d06fa2)
1 #ifndef __CPUHOTPLUG_H
2 #define __CPUHOTPLUG_H
3 
4 enum cpuhp_state {
5 	CPUHP_OFFLINE,
6 	CPUHP_CREATE_THREADS,
7 	CPUHP_NOTIFY_PREPARE,
8 	CPUHP_BRINGUP_CPU,
9 	CPUHP_AP_IDLE_DEAD,
10 	CPUHP_AP_OFFLINE,
11 	CPUHP_AP_NOTIFY_STARTING,
12 	CPUHP_AP_ONLINE,
13 	CPUHP_TEARDOWN_CPU,
14 	CPUHP_AP_ONLINE_IDLE,
15 	CPUHP_AP_SMPBOOT_THREADS,
16 	CPUHP_AP_NOTIFY_ONLINE,
17 	CPUHP_AP_ONLINE_DYN,
18 	CPUHP_AP_ONLINE_DYN_END		= CPUHP_AP_ONLINE_DYN + 30,
19 	CPUHP_ONLINE,
20 };
21 
22 int __cpuhp_setup_state(enum cpuhp_state state,	const char *name, bool invoke,
23 			int (*startup)(unsigned int cpu),
24 			int (*teardown)(unsigned int cpu));
25 
26 /**
27  * cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks
28  * @state:	The state for which the calls are installed
29  * @name:	Name of the callback (will be used in debug output)
30  * @startup:	startup callback function
31  * @teardown:	teardown callback function
32  *
33  * Installs the callback functions and invokes the startup callback on
34  * the present cpus which have already reached the @state.
35  */
36 static inline int cpuhp_setup_state(enum cpuhp_state state,
37 				    const char *name,
38 				    int (*startup)(unsigned int cpu),
39 				    int (*teardown)(unsigned int cpu))
40 {
41 	return __cpuhp_setup_state(state, name, true, startup, teardown);
42 }
43 
44 /**
45  * cpuhp_setup_state_nocalls - Setup hotplug state callbacks without calling the
46  *			       callbacks
47  * @state:	The state for which the calls are installed
48  * @name:	Name of the callback.
49  * @startup:	startup callback function
50  * @teardown:	teardown callback function
51  *
52  * Same as @cpuhp_setup_state except that no calls are executed are invoked
53  * during installation of this callback. NOP if SMP=n or HOTPLUG_CPU=n.
54  */
55 static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state,
56 					    const char *name,
57 					    int (*startup)(unsigned int cpu),
58 					    int (*teardown)(unsigned int cpu))
59 {
60 	return __cpuhp_setup_state(state, name, false, startup, teardown);
61 }
62 
63 void __cpuhp_remove_state(enum cpuhp_state state, bool invoke);
64 
65 /**
66  * cpuhp_remove_state - Remove hotplug state callbacks and invoke the teardown
67  * @state:	The state for which the calls are removed
68  *
69  * Removes the callback functions and invokes the teardown callback on
70  * the present cpus which have already reached the @state.
71  */
72 static inline void cpuhp_remove_state(enum cpuhp_state state)
73 {
74 	__cpuhp_remove_state(state, true);
75 }
76 
77 /**
78  * cpuhp_remove_state_nocalls - Remove hotplug state callbacks without invoking
79  *				teardown
80  * @state:	The state for which the calls are removed
81  */
82 static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state)
83 {
84 	__cpuhp_remove_state(state, false);
85 }
86 
87 #ifdef CONFIG_SMP
88 void cpuhp_online_idle(enum cpuhp_state state);
89 #else
90 static inline void cpuhp_online_idle(enum cpuhp_state state) { }
91 #endif
92 
93 #endif
94