Skip to content

Commit

Permalink
smpboot: allow passing the cpumask on per-cpu thread registration
Browse files Browse the repository at this point in the history
It makes the registration cheaper and simpler for the smpboot per-cpu
kthread users that don't need to always update the cpumask after threads
creation.

[[email protected]: fix for allow passing the cpumask on per-cpu thread registration]
Signed-off-by: Frederic Weisbecker <[email protected]>
Reviewed-by: Chris Metcalf <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ulrich Obergfell <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fweisbec authored and torvalds committed Sep 4, 2015
1 parent 3dd08c0 commit 230ec93
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
11 changes: 10 additions & 1 deletion include/linux/smpboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ struct smp_hotplug_thread {
const char *thread_comm;
};

int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread,
const struct cpumask *cpumask);

static inline int
smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
{
return smpboot_register_percpu_thread_cpumask(plug_thread,
cpu_possible_mask);
}

void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread,
const struct cpumask *);
Expand Down
14 changes: 9 additions & 5 deletions kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,22 @@ static void smpboot_destroy_threads(struct smp_hotplug_thread *ht)
}

/**
* smpboot_register_percpu_thread - Register a per_cpu thread related to hotplug
* smpboot_register_percpu_thread_cpumask - Register a per_cpu thread related
* to hotplug
* @plug_thread: Hotplug thread descriptor
* @cpumask: The cpumask where threads run
*
* Creates and starts the threads on all online cpus.
*/
int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread,
const struct cpumask *cpumask)
{
unsigned int cpu;
int ret = 0;

if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL))
return -ENOMEM;
cpumask_copy(plug_thread->cpumask, cpu_possible_mask);
cpumask_copy(plug_thread->cpumask, cpumask);

get_online_cpus();
mutex_lock(&smpboot_threads_lock);
Expand All @@ -296,15 +299,16 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
free_cpumask_var(plug_thread->cpumask);
goto out;
}
smpboot_unpark_thread(plug_thread, cpu);
if (cpumask_test_cpu(cpu, cpumask))
smpboot_unpark_thread(plug_thread, cpu);
}
list_add(&plug_thread->list, &hotplug_threads);
out:
mutex_unlock(&smpboot_threads_lock);
put_online_cpus();
return ret;
}
EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread);
EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread_cpumask);

/**
* smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug
Expand Down
9 changes: 3 additions & 6 deletions kernel/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,12 @@ static int watchdog_enable_all_cpus(void)
int err = 0;

if (!watchdog_running) {
err = smpboot_register_percpu_thread(&watchdog_threads);
err = smpboot_register_percpu_thread_cpumask(&watchdog_threads,
&watchdog_cpumask);
if (err)
pr_err("Failed to create watchdog threads, disabled\n");
else {
if (smpboot_update_cpumask_percpu_thread(
&watchdog_threads, &watchdog_cpumask))
pr_err("Failed to set cpumask for watchdog threads\n");
else
watchdog_running = 1;
}
} else {
/*
* Enable/disable the lockup detectors or
Expand Down

0 comments on commit 230ec93

Please sign in to comment.