diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2015-09-04 18:45:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-04 19:54:41 -0400 |
commit | 230ec93909f00678401cb2d63b8b95f1dea68e40 (patch) | |
tree | 1eb01a44e0d66d76306f598d595a4bdaccd21b64 | |
parent | 3dd08c0c918f9bf058572ddbf26e7d6fb5674a5c (diff) |
smpboot: allow passing the cpumask on per-cpu thread registration
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.
[sfr@canb.auug.org.au: fix for allow passing the cpumask on per-cpu thread registration]
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/smpboot.h | 11 | ||||
-rw-r--r-- | kernel/smpboot.c | 14 | ||||
-rw-r--r-- | kernel/watchdog.c | 9 |
3 files changed, 22 insertions, 12 deletions
diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h index da3c593f9845..e6109a6cd8f6 100644 --- a/include/linux/smpboot.h +++ b/include/linux/smpboot.h | |||
@@ -48,7 +48,16 @@ struct smp_hotplug_thread { | |||
48 | const char *thread_comm; | 48 | const char *thread_comm; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread); | 51 | int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread, |
52 | const struct cpumask *cpumask); | ||
53 | |||
54 | static inline int | ||
55 | smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) | ||
56 | { | ||
57 | return smpboot_register_percpu_thread_cpumask(plug_thread, | ||
58 | cpu_possible_mask); | ||
59 | } | ||
60 | |||
52 | void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread); | 61 | void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread); |
53 | int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread, | 62 | int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread, |
54 | const struct cpumask *); | 63 | const struct cpumask *); |
diff --git a/kernel/smpboot.c b/kernel/smpboot.c index 60aa858a6a07..a818cbc73e14 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c | |||
@@ -273,19 +273,22 @@ static void smpboot_destroy_threads(struct smp_hotplug_thread *ht) | |||
273 | } | 273 | } |
274 | 274 | ||
275 | /** | 275 | /** |
276 | * smpboot_register_percpu_thread - Register a per_cpu thread related to hotplug | 276 | * smpboot_register_percpu_thread_cpumask - Register a per_cpu thread related |
277 | * to hotplug | ||
277 | * @plug_thread: Hotplug thread descriptor | 278 | * @plug_thread: Hotplug thread descriptor |
279 | * @cpumask: The cpumask where threads run | ||
278 | * | 280 | * |
279 | * Creates and starts the threads on all online cpus. | 281 | * Creates and starts the threads on all online cpus. |
280 | */ | 282 | */ |
281 | int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) | 283 | int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread, |
284 | const struct cpumask *cpumask) | ||
282 | { | 285 | { |
283 | unsigned int cpu; | 286 | unsigned int cpu; |
284 | int ret = 0; | 287 | int ret = 0; |
285 | 288 | ||
286 | if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL)) | 289 | if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL)) |
287 | return -ENOMEM; | 290 | return -ENOMEM; |
288 | cpumask_copy(plug_thread->cpumask, cpu_possible_mask); | 291 | cpumask_copy(plug_thread->cpumask, cpumask); |
289 | 292 | ||
290 | get_online_cpus(); | 293 | get_online_cpus(); |
291 | mutex_lock(&smpboot_threads_lock); | 294 | mutex_lock(&smpboot_threads_lock); |
@@ -296,7 +299,8 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) | |||
296 | free_cpumask_var(plug_thread->cpumask); | 299 | free_cpumask_var(plug_thread->cpumask); |
297 | goto out; | 300 | goto out; |
298 | } | 301 | } |
299 | smpboot_unpark_thread(plug_thread, cpu); | 302 | if (cpumask_test_cpu(cpu, cpumask)) |
303 | smpboot_unpark_thread(plug_thread, cpu); | ||
300 | } | 304 | } |
301 | list_add(&plug_thread->list, &hotplug_threads); | 305 | list_add(&plug_thread->list, &hotplug_threads); |
302 | out: | 306 | out: |
@@ -304,7 +308,7 @@ out: | |||
304 | put_online_cpus(); | 308 | put_online_cpus(); |
305 | return ret; | 309 | return ret; |
306 | } | 310 | } |
307 | EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread); | 311 | EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread_cpumask); |
308 | 312 | ||
309 | /** | 313 | /** |
310 | * smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug | 314 | * smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug |
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index a6ffa43f2993..e5bb86fb0ea5 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -713,15 +713,12 @@ static int watchdog_enable_all_cpus(void) | |||
713 | int err = 0; | 713 | int err = 0; |
714 | 714 | ||
715 | if (!watchdog_running) { | 715 | if (!watchdog_running) { |
716 | err = smpboot_register_percpu_thread(&watchdog_threads); | 716 | err = smpboot_register_percpu_thread_cpumask(&watchdog_threads, |
717 | &watchdog_cpumask); | ||
717 | if (err) | 718 | if (err) |
718 | pr_err("Failed to create watchdog threads, disabled\n"); | 719 | pr_err("Failed to create watchdog threads, disabled\n"); |
719 | else { | 720 | else |
720 | if (smpboot_update_cpumask_percpu_thread( | ||
721 | &watchdog_threads, &watchdog_cpumask)) | ||
722 | pr_err("Failed to set cpumask for watchdog threads\n"); | ||
723 | watchdog_running = 1; | 721 | watchdog_running = 1; |
724 | } | ||
725 | } else { | 722 | } else { |
726 | /* | 723 | /* |
727 | * Enable/disable the lockup detectors or | 724 | * Enable/disable the lockup detectors or |