Skip to content

Commit 230ec93

Browse files
fweisbectorvalds
authored andcommitted
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>
1 parent 3dd08c0 commit 230ec93

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎include/linux/smpboot.h‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ struct smp_hotplug_thread {
4848
const char *thread_comm;
4949
};
5050

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+
5261
void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
5362
int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread,
5463
const struct cpumask *);

‎kernel/smpboot.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,22 @@ static void smpboot_destroy_threads(struct smp_hotplug_thread *ht)
273273
}
274274

275275
/**
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
277278
* @plug_thread: Hotplug thread descriptor
279+
* @cpumask: The cpumask where threads run
278280
*
279281
* Creates and starts the threads on all online cpus.
280282
*/
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)
282285
{
283286
unsigned int cpu;
284287
int ret = 0;
285288

286289
if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL))
287290
return -ENOMEM;
288-
cpumask_copy(plug_thread->cpumask, cpu_possible_mask);
291+
cpumask_copy(plug_thread->cpumask, cpumask);
289292

290293
get_online_cpus();
291294
mutex_lock(&smpboot_threads_lock);
@@ -296,15 +299,16 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
296299
free_cpumask_var(plug_thread->cpumask);
297300
goto out;
298301
}
299-
smpboot_unpark_thread(plug_thread, cpu);
302+
if (cpumask_test_cpu(cpu, cpumask))
303+
smpboot_unpark_thread(plug_thread, cpu);
300304
}
301305
list_add(&plug_thread->list, &hotplug_threads);
302306
out:
303307
mutex_unlock(&smpboot_threads_lock);
304308
put_online_cpus();
305309
return ret;
306310
}
307-
EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread);
311+
EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread_cpumask);
308312

309313
/**
310314
* smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug

‎kernel/watchdog.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,15 +713,12 @@ static int watchdog_enable_all_cpus(void)
713713
int err = 0;
714714

715715
if (!watchdog_running) {
716-
err = smpboot_register_percpu_thread(&watchdog_threads);
716+
err = smpboot_register_percpu_thread_cpumask(&watchdog_threads,
717+
&watchdog_cpumask);
717718
if (err)
718719
pr_err("Failed to create watchdog threads, disabled\n");
719-
else {
720-
if (smpboot_update_cpumask_percpu_thread(
721-
&watchdog_threads, &watchdog_cpumask))
722-
pr_err("Failed to set cpumask for watchdog threads\n");
720+
else
723721
watchdog_running = 1;
724-
}
725722
} else {
726723
/*
727724
* Enable/disable the lockup detectors or

0 commit comments

Comments
 (0)