smpboot.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _LINUX_SMPBOOT_H
  2. #define _LINUX_SMPBOOT_H
  3. #include <linux/types.h>
  4. struct task_struct;
  5. /* Cookie handed to the thread_fn*/
  6. struct smpboot_thread_data;
  7. /**
  8. * struct smp_hotplug_thread - CPU hotplug related thread descriptor
  9. * @store: Pointer to per cpu storage for the task pointers
  10. * @list: List head for core management
  11. * @thread_should_run: Check whether the thread should run or not. Called with
  12. * preemption disabled.
  13. * @thread_fn: The associated thread function
  14. * @create: Optional setup function, called when the thread gets
  15. * created (Not called from the thread context)
  16. * @setup: Optional setup function, called when the thread gets
  17. * operational the first time
  18. * @cleanup: Optional cleanup function, called when the thread
  19. * should stop (module exit)
  20. * @park: Optional park function, called when the thread is
  21. * parked (cpu offline)
  22. * @unpark: Optional unpark function, called when the thread is
  23. * unparked (cpu online)
  24. * @cpumask: Internal state. To update which threads are unparked,
  25. * call smpboot_update_cpumask_percpu_thread().
  26. * @selfparking: Thread is not parked by the park function.
  27. * @thread_comm: The base name of the thread
  28. */
  29. struct smp_hotplug_thread {
  30. struct task_struct __percpu **store;
  31. struct list_head list;
  32. int (*thread_should_run)(unsigned int cpu);
  33. void (*thread_fn)(unsigned int cpu);
  34. void (*create)(unsigned int cpu);
  35. void (*setup)(unsigned int cpu);
  36. void (*cleanup)(unsigned int cpu, bool online);
  37. void (*park)(unsigned int cpu);
  38. void (*unpark)(unsigned int cpu);
  39. cpumask_var_t cpumask;
  40. bool selfparking;
  41. const char *thread_comm;
  42. };
  43. int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread,
  44. const struct cpumask *cpumask);
  45. static inline int
  46. smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
  47. {
  48. return smpboot_register_percpu_thread_cpumask(plug_thread,
  49. cpu_possible_mask);
  50. }
  51. void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
  52. int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread,
  53. const struct cpumask *);
  54. #endif