Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc: Account mm_cpumask and active_cpus in init_mm

init_mm mm_cpumask and context.active_cpus is not maintained at boot
and hotplug. This seems to be harmless because init_mm does not have a
userspace and so never gets user TLBs flushed, but it looks odd and it
prevents some sanity checks being added.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230524060821.148015-2-npiggin@gmail.com

authored by

Nicholas Piggin and committed by
Michael Ellerman
c3c2e937 ab481817

+18 -1
+5 -1
arch/powerpc/kernel/setup-common.c
··· 969 969 klp_init_thread_info(&init_task); 970 970 971 971 setup_initial_init_mm(_stext, _etext, _edata, _end); 972 - 972 + /* sched_init() does the mmgrab(&init_mm) for the primary CPU */ 973 + VM_WARN_ON(cpumask_test_cpu(smp_processor_id(), mm_cpumask(&init_mm))); 974 + cpumask_set_cpu(smp_processor_id(), mm_cpumask(&init_mm)); 975 + inc_mm_active_cpus(&init_mm); 973 976 mm_iommu_init(&init_mm); 977 + 974 978 irqstack_early_init(); 975 979 exc_lvl_early_init(); 976 980 emergency_stack_init();
+12
arch/powerpc/kernel/smp.c
··· 47 47 #include <asm/smp.h> 48 48 #include <asm/time.h> 49 49 #include <asm/machdep.h> 50 + #include <asm/mmu_context.h> 50 51 #include <asm/cputhreads.h> 51 52 #include <asm/cputable.h> 52 53 #include <asm/mpic.h> ··· 1617 1616 1618 1617 mmgrab_lazy_tlb(&init_mm); 1619 1618 current->active_mm = &init_mm; 1619 + VM_WARN_ON(cpumask_test_cpu(smp_processor_id(), mm_cpumask(&init_mm))); 1620 + cpumask_set_cpu(cpu, mm_cpumask(&init_mm)); 1621 + inc_mm_active_cpus(&init_mm); 1620 1622 1621 1623 smp_store_cpu_info(cpu); 1622 1624 set_dec(tb_ticks_per_jiffy); ··· 1755 1751 1756 1752 void __cpu_die(unsigned int cpu) 1757 1753 { 1754 + /* 1755 + * This could perhaps be a generic call in idlea_task_dead(), but 1756 + * that requires testing from all archs, so first put it here to 1757 + */ 1758 + VM_WARN_ON_ONCE(!cpumask_test_cpu(cpu, mm_cpumask(&init_mm))); 1759 + dec_mm_active_cpus(&init_mm); 1760 + cpumask_clear_cpu(cpu, mm_cpumask(&init_mm)); 1761 + 1758 1762 if (smp_ops->cpu_die) 1759 1763 smp_ops->cpu_die(cpu); 1760 1764 }
+1
arch/powerpc/mm/mmu_context.c
··· 47 47 48 48 /* Mark this context has been used on the new CPU */ 49 49 if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) { 50 + VM_WARN_ON_ONCE(next == &init_mm); 50 51 cpumask_set_cpu(smp_processor_id(), mm_cpumask(next)); 51 52 inc_mm_active_cpus(next); 52 53