smpboot.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SMPBOOT_H
  3. #define _LINUX_SMPBOOT_H
  4. #include <linux/types.h>
  5. struct task_struct;
  6. /* Cookie handed to the thread_fn*/
  7. struct smpboot_thread_data;
  8. /**
  9. * struct smp_hotplug_thread - CPU hotplug related thread descriptor
  10. * @store: Pointer to per cpu storage for the task pointers
  11. * @list: List head for core management
  12. * @thread_should_run: Check whether the thread should run or not. Called with
  13. * preemption disabled.
  14. * @thread_fn: The associated thread function
  15. * @create: Optional setup function, called when the thread gets
  16. * created (Not called from the thread context)
  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. * @selfparking: Thread is not parked by the park function.
  26. * @thread_comm: The base name of the thread
  27. */
  28. struct smp_hotplug_thread {
  29. struct task_struct * __percpu *store;
  30. struct list_head list;
  31. int (*thread_should_run)(unsigned int cpu);
  32. void (*thread_fn)(unsigned int cpu);
  33. void (*create)(unsigned int cpu);
  34. void (*setup)(unsigned int cpu);
  35. void (*cleanup)(unsigned int cpu, bool online);
  36. void (*park)(unsigned int cpu);
  37. void (*unpark)(unsigned int cpu);
  38. bool selfparking;
  39. const char *thread_comm;
  40. };
  41. int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
  42. void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
  43. #endif