Commit 7d7e499f authored by Thomas Gleixner's avatar Thomas Gleixner

smpboot: Allow selfparking per cpu threads

The stop machine threads are still killed when a cpu goes offline. The
reason is that the thread is used to bring the cpu down, so it can't
be parked along with the other per cpu threads.

Allow a per cpu thread to be excluded from automatic parking, so it
can park itself once it's done

Add a create callback function as well.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Arjan van de Veen <arjan@infradead.org>
Cc: Paul Turner <pjt@google.com>
Cc: Richard Weinberger <rw@linutronix.de>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130131120741.553993267@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 211b0cdc
...@@ -14,6 +14,8 @@ struct smpboot_thread_data; ...@@ -14,6 +14,8 @@ struct smpboot_thread_data;
* @thread_should_run: Check whether the thread should run or not. Called with * @thread_should_run: Check whether the thread should run or not. Called with
* preemption disabled. * preemption disabled.
* @thread_fn: The associated thread function * @thread_fn: The associated thread function
* @create: Optional setup function, called when the thread gets
* created (Not called from the thread context)
* @setup: Optional setup function, called when the thread gets * @setup: Optional setup function, called when the thread gets
* operational the first time * operational the first time
* @cleanup: Optional cleanup function, called when the thread * @cleanup: Optional cleanup function, called when the thread
...@@ -22,6 +24,7 @@ struct smpboot_thread_data; ...@@ -22,6 +24,7 @@ struct smpboot_thread_data;
* parked (cpu offline) * parked (cpu offline)
* @unpark: Optional unpark function, called when the thread is * @unpark: Optional unpark function, called when the thread is
* unparked (cpu online) * unparked (cpu online)
* @selfparking: Thread is not parked by the park function.
* @thread_comm: The base name of the thread * @thread_comm: The base name of the thread
*/ */
struct smp_hotplug_thread { struct smp_hotplug_thread {
...@@ -29,10 +32,12 @@ struct smp_hotplug_thread { ...@@ -29,10 +32,12 @@ struct smp_hotplug_thread {
struct list_head list; struct list_head list;
int (*thread_should_run)(unsigned int cpu); int (*thread_should_run)(unsigned int cpu);
void (*thread_fn)(unsigned int cpu); void (*thread_fn)(unsigned int cpu);
void (*create)(unsigned int cpu);
void (*setup)(unsigned int cpu); void (*setup)(unsigned int cpu);
void (*cleanup)(unsigned int cpu, bool online); void (*cleanup)(unsigned int cpu, bool online);
void (*park)(unsigned int cpu); void (*park)(unsigned int cpu);
void (*unpark)(unsigned int cpu); void (*unpark)(unsigned int cpu);
bool selfparking;
const char *thread_comm; const char *thread_comm;
}; };
......
...@@ -183,9 +183,10 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) ...@@ -183,9 +183,10 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
kfree(td); kfree(td);
return PTR_ERR(tsk); return PTR_ERR(tsk);
} }
get_task_struct(tsk); get_task_struct(tsk);
*per_cpu_ptr(ht->store, cpu) = tsk; *per_cpu_ptr(ht->store, cpu) = tsk;
if (ht->create)
ht->create(cpu);
return 0; return 0;
} }
...@@ -225,7 +226,7 @@ static void smpboot_park_thread(struct smp_hotplug_thread *ht, unsigned int cpu) ...@@ -225,7 +226,7 @@ static void smpboot_park_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
{ {
struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu); struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu);
if (tsk) if (tsk && !ht->selfparking)
kthread_park(tsk); kthread_park(tsk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment