mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-11 19:46:45 +07:00
f97f8f06a4
Provide a generic interface for setting up and tearing down percpu threads. On registration the threads for already online cpus are created and started. On deregistration (modules) the threads are stoppped. During hotplug operations the threads are created, started, parked and unparked. The datastructure for registration provides a pointer to percpu storage space and optional setup, cleanup, park, unpark functions. These functions are called when the thread state changes. Each implementation has to provide a function which is queried and returns whether the thread should run and the thread function itself. The core code handles all state transitions and avoids duplicated code in the call sites. [ paulmck: Preemption leak fix ] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20120716103948.352501068@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
#ifndef _LINUX_SMPBOOT_H
|
|
#define _LINUX_SMPBOOT_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
struct task_struct;
|
|
/* Cookie handed to the thread_fn*/
|
|
struct smpboot_thread_data;
|
|
|
|
/**
|
|
* struct smp_hotplug_thread - CPU hotplug related thread descriptor
|
|
* @store: Pointer to per cpu storage for the task pointers
|
|
* @list: List head for core management
|
|
* @thread_should_run: Check whether the thread should run or not. Called with
|
|
* preemption disabled.
|
|
* @thread_fn: The associated thread function
|
|
* @setup: Optional setup function, called when the thread gets
|
|
* operational the first time
|
|
* @cleanup: Optional cleanup function, called when the thread
|
|
* should stop (module exit)
|
|
* @park: Optional park function, called when the thread is
|
|
* parked (cpu offline)
|
|
* @unpark: Optional unpark function, called when the thread is
|
|
* unparked (cpu online)
|
|
* @thread_comm: The base name of the thread
|
|
*/
|
|
struct smp_hotplug_thread {
|
|
struct task_struct __percpu **store;
|
|
struct list_head list;
|
|
int (*thread_should_run)(unsigned int cpu);
|
|
void (*thread_fn)(unsigned int cpu);
|
|
void (*setup)(unsigned int cpu);
|
|
void (*cleanup)(unsigned int cpu, bool online);
|
|
void (*park)(unsigned int cpu);
|
|
void (*unpark)(unsigned int cpu);
|
|
const char *thread_comm;
|
|
};
|
|
|
|
int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
|
|
void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
|
|
int smpboot_thread_schedule(void);
|
|
|
|
#endif
|