diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2012-07-16 06:42:36 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2012-08-13 11:01:07 -0400 |
commit | f97f8f06a49febbc3cb3635172efbe64ddc79700 (patch) | |
tree | 7917324eb3e1c36963a8c60c6a5601708b3ef208 /include/linux | |
parent | 2a1d446019f9a5983ec5a335b95e8593fdb6fa2e (diff) |
smpboot: Provide infrastructure for percpu hotplug threads
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>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/smpboot.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h new file mode 100644 index 000000000000..e0106d8581d3 --- /dev/null +++ b/include/linux/smpboot.h | |||
@@ -0,0 +1,43 @@ | |||
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 | ||