powerpc: Set nr_cpu_ids early and use it to free PACAs
authorRyan Grimm <grimm@us.ibm.com>
Thu, 31 Mar 2011 19:33:02 +0000 (19:33 +0000)
committerSteve Conklin <sconklin@canonical.com>
Fri, 15 Jul 2011 17:20:49 +0000 (12:20 -0500)
BugLink: http://bugs.launchpad.net/bugs/793702

commit c1854e00727f50f7ac99e98d26ece04c087ef785 upstream.

Without this, "holes" in the CPU numbering can cause us to
free too many PACAs

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

arch/powerpc/kernel/paca.c
arch/powerpc/kernel/setup-common.c

index f4adf89..10f0aad 100644 (file)
@@ -203,7 +203,7 @@ void __init free_unused_pacas(void)
 {
        int new_size;
 
-       new_size = PAGE_ALIGN(sizeof(struct paca_struct) * num_possible_cpus());
+       new_size = PAGE_ALIGN(sizeof(struct paca_struct) * nr_cpu_ids);
 
        if (new_size >= paca_size)
                return;
index 9d4882a..21f30cb 100644 (file)
@@ -509,6 +509,9 @@ void __init smp_setup_cpu_maps(void)
         */
        cpu_init_thread_core_maps(nthreads);
 
+       /* Now that possible cpus are set, set nr_cpu_ids for later use */
+       nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
+
        free_unused_pacas();
 }
 #endif /* CONFIG_SMP */