xref: /linux-6.15/include/linux/smpboot.h (revision 8fdff1dc)
1 #ifndef _LINUX_SMPBOOT_H
2 #define _LINUX_SMPBOOT_H
3 
4 #include <linux/types.h>
5 
6 struct task_struct;
7 /* Cookie handed to the thread_fn*/
8 struct smpboot_thread_data;
9 
10 /**
11  * struct smp_hotplug_thread - CPU hotplug related thread descriptor
12  * @store:		Pointer to per cpu storage for the task pointers
13  * @list:		List head for core management
14  * @thread_should_run:	Check whether the thread should run or not. Called with
15  *			preemption disabled.
16  * @thread_fn:		The associated thread function
17  * @setup:		Optional setup function, called when the thread gets
18  *			operational the first time
19  * @cleanup:		Optional cleanup function, called when the thread
20  *			should stop (module exit)
21  * @park:		Optional park function, called when the thread is
22  *			parked (cpu offline)
23  * @unpark:		Optional unpark function, called when the thread is
24  *			unparked (cpu online)
25  * @thread_comm:	The base name of the thread
26  */
27 struct smp_hotplug_thread {
28 	struct task_struct __percpu	**store;
29 	struct list_head		list;
30 	int				(*thread_should_run)(unsigned int cpu);
31 	void				(*thread_fn)(unsigned int cpu);
32 	void				(*setup)(unsigned int cpu);
33 	void				(*cleanup)(unsigned int cpu, bool online);
34 	void				(*park)(unsigned int cpu);
35 	void				(*unpark)(unsigned int cpu);
36 	const char			*thread_comm;
37 };
38 
39 int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
40 void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
41 int smpboot_thread_schedule(void);
42 
43 #endif
44