Skip to content

Commit

Permalink
smpboot: Allow selfparking per cpu threads
Browse files Browse the repository at this point in the history
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: Thomas Gleixner <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: Paul McKenney <[email protected]>
Cc: Srivatsa S. Bhat <[email protected]>
Cc: Arjan van de Veen <[email protected]>
Cc: Paul Turner <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Magnus Damm <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
KAGA-KOKO committed Feb 14, 2013
1 parent 211b0cd commit 7d7e499
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/linux/smpboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct smpboot_thread_data;
* @thread_should_run: Check whether the thread should run or not. Called with
* preemption disabled.
* @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
* operational the first time
* @cleanup: Optional cleanup function, called when the thread
Expand All @@ -22,17 +24,20 @@ struct smpboot_thread_data;
* parked (cpu offline)
* @unpark: Optional unpark function, called when the thread is
* unparked (cpu online)
* @selfparking: Thread is not parked by the park function.
* @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 (*create)(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);
bool selfparking;
const char *thread_comm;
};

Expand Down
5 changes: 3 additions & 2 deletions kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
kfree(td);
return PTR_ERR(tsk);
}

get_task_struct(tsk);
*per_cpu_ptr(ht->store, cpu) = tsk;
if (ht->create)
ht->create(cpu);
return 0;
}

Expand Down Expand Up @@ -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);

if (tsk)
if (tsk && !ht->selfparking)
kthread_park(tsk);
}

Expand Down

0 comments on commit 7d7e499

Please sign in to comment.