Messages in this thread Patch in this message | | | From | Chris Metcalf <> | Subject | [PATCH] smpboot: dynamically allocate the cpumask | Date | Fri, 1 May 2015 16:00:47 -0400 |
| |
Frederic Weisbecker observed that we'd be better off to dynamically allocate the cpumask associated with smpboot threads to save memory.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com> --- (Dropped a bunch of people off the cc's)
I figured since Andrew had already taken the previous v10 patchset into the -mm tree, it was better to just submit this as a followup patch. I can also argue that since it doesn't fix a bug per se, just improves memory usage, it seems OK to have as a follow-on patch.
That said, I can respin a v11 patch 1/3 instead to give a new single patch for smpboot; Andrew, just let me know if you'd prefer that.
include/linux/smpboot.h | 2 +- kernel/smpboot.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h index 7c42153edfac..da3c593f9845 100644 --- a/include/linux/smpboot.h +++ b/include/linux/smpboot.h @@ -43,7 +43,7 @@ struct smp_hotplug_thread { void (*park)(unsigned int cpu); void (*unpark)(unsigned int cpu); void (*pre_unpark)(unsigned int cpu); - struct cpumask cpumask; + cpumask_var_t cpumask; bool selfparking; const char *thread_comm; }; diff --git a/kernel/smpboot.c b/kernel/smpboot.c index 209750ab7031..5e46c2a75d59 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -232,7 +232,7 @@ void smpboot_unpark_threads(unsigned int cpu) mutex_lock(&smpboot_threads_lock); list_for_each_entry(cur, &hotplug_threads, list) - if (cpumask_test_cpu(cpu, &cur->cpumask)) + if (cpumask_test_cpu(cpu, cur->cpumask)) smpboot_unpark_thread(cur, cpu); mutex_unlock(&smpboot_threads_lock); } @@ -260,7 +260,7 @@ static void smpboot_destroy_threads(struct smp_hotplug_thread *ht) unsigned int cpu; /* Unpark any threads that were voluntarily parked. */ - for_each_cpu_not(cpu, &ht->cpumask) { + for_each_cpu_not(cpu, ht->cpumask) { if (cpu_online(cpu)) { struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu); if (tsk) @@ -291,7 +291,10 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread) unsigned int cpu; int ret = 0; - cpumask_copy(&plug_thread->cpumask, cpu_possible_mask); + if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL)) + return -ENOMEM; + cpumask_copy(plug_thread->cpumask, cpu_possible_mask); + get_online_cpus(); mutex_lock(&smpboot_threads_lock); for_each_online_cpu(cpu) { @@ -324,6 +327,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread) smpboot_destroy_threads(plug_thread); mutex_unlock(&smpboot_threads_lock); put_online_cpus(); + free_cpumask_var(plug_thread->cpumask); } EXPORT_SYMBOL_GPL(smpboot_unregister_percpu_thread); @@ -338,7 +342,7 @@ EXPORT_SYMBOL_GPL(smpboot_unregister_percpu_thread); int smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread, const struct cpumask *new) { - struct cpumask *old = &plug_thread->cpumask; + struct cpumask *old = plug_thread->cpumask; cpumask_var_t tmp; unsigned int cpu; -- 2.1.2
| |