Skip to contentSkip to conversation

powerpc: Set nr_cpu_ids early and use it to free PACAs

PATCH New Benjamin Herrenschmidt 1 participant 1 message Apr 1, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Set nr_cpu_ids early and use it to free PACAs

From: Ryan Grimm <[email protected]>

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

---
 arch/powerpc/kernel/paca.c         |    2 +-
 arch/powerpc/kernel/setup-common.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)
arch/powerpc/kernel/paca.c +1 -1
index f4adf89..10f0aad 100644
@@ -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;
arch/powerpc/kernel/setup-common.c +3 -0
index 9d4882a..21f30cb 100644
@@ -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 */