xref: /linux-6.15/include/linux/smpboot.h (revision d4645d30)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f97f8f06SThomas Gleixner #ifndef _LINUX_SMPBOOT_H
3f97f8f06SThomas Gleixner #define _LINUX_SMPBOOT_H
4f97f8f06SThomas Gleixner 
5f97f8f06SThomas Gleixner #include <linux/types.h>
6f97f8f06SThomas Gleixner 
7f97f8f06SThomas Gleixner struct task_struct;
8f97f8f06SThomas Gleixner /* Cookie handed to the thread_fn*/
9f97f8f06SThomas Gleixner struct smpboot_thread_data;
10f97f8f06SThomas Gleixner 
11f97f8f06SThomas Gleixner /**
12f97f8f06SThomas Gleixner  * struct smp_hotplug_thread - CPU hotplug related thread descriptor
13f97f8f06SThomas Gleixner  * @store:		Pointer to per cpu storage for the task pointers
14f97f8f06SThomas Gleixner  * @list:		List head for core management
15f97f8f06SThomas Gleixner  * @thread_should_run:	Check whether the thread should run or not. Called with
16f97f8f06SThomas Gleixner  *			preemption disabled.
17f97f8f06SThomas Gleixner  * @thread_fn:		The associated thread function
187d7e499fSThomas Gleixner  * @create:		Optional setup function, called when the thread gets
197d7e499fSThomas Gleixner  *			created (Not called from the thread context)
20f97f8f06SThomas Gleixner  * @setup:		Optional setup function, called when the thread gets
21f97f8f06SThomas Gleixner  *			operational the first time
22f97f8f06SThomas Gleixner  * @cleanup:		Optional cleanup function, called when the thread
23f97f8f06SThomas Gleixner  *			should stop (module exit)
24f97f8f06SThomas Gleixner  * @park:		Optional park function, called when the thread is
25f97f8f06SThomas Gleixner  *			parked (cpu offline)
26f97f8f06SThomas Gleixner  * @unpark:		Optional unpark function, called when the thread is
27f97f8f06SThomas Gleixner  *			unparked (cpu online)
287d7e499fSThomas Gleixner  * @selfparking:	Thread is not parked by the park function.
29f97f8f06SThomas Gleixner  * @thread_comm:	The base name of the thread
30f97f8f06SThomas Gleixner  */
31f97f8f06SThomas Gleixner struct smp_hotplug_thread {
32*d4645d30SSebastian Andrzej Siewior 	struct task_struct		* __percpu *store;
33f97f8f06SThomas Gleixner 	struct list_head		list;
34f97f8f06SThomas Gleixner 	int				(*thread_should_run)(unsigned int cpu);
35f97f8f06SThomas Gleixner 	void				(*thread_fn)(unsigned int cpu);
367d7e499fSThomas Gleixner 	void				(*create)(unsigned int cpu);
37f97f8f06SThomas Gleixner 	void				(*setup)(unsigned int cpu);
38f97f8f06SThomas Gleixner 	void				(*cleanup)(unsigned int cpu, bool online);
39f97f8f06SThomas Gleixner 	void				(*park)(unsigned int cpu);
40f97f8f06SThomas Gleixner 	void				(*unpark)(unsigned int cpu);
417d7e499fSThomas Gleixner 	bool				selfparking;
42f97f8f06SThomas Gleixner 	const char			*thread_comm;
43f97f8f06SThomas Gleixner };
44f97f8f06SThomas Gleixner 
45167a8867SPeter Zijlstra int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
46230ec939SFrederic Weisbecker 
47f97f8f06SThomas Gleixner void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
48f97f8f06SThomas Gleixner 
49f97f8f06SThomas Gleixner #endif
50