diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2023-05-24 09:08:20 +0300 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-08-02 15:22:19 +0300 |
commit | 177255afb40548fdf504384b361d18d6cbe35d1e (patch) | |
tree | ab5cb870847432c97bbeec5e16e22ee59204cbb4 /arch/powerpc/mm | |
parent | f74b2a6c01a0b319070ccee7dea0cc4dad694041 (diff) | |
download | linux-177255afb40548fdf504384b361d18d6cbe35d1e.tar.xz |
powerpc: Add mm_cpumask warning when context switching
When context switching away from an mm, add a CONFIG_DEBUG_VM warning
check to ensure this CPU is still set in the mask. This could catch
bugs where the mask is improperly trimmed while the CPU is still using
the mm.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230524060821.148015-4-npiggin@gmail.com
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/mmu_context.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/mm/mmu_context.c b/arch/powerpc/mm/mmu_context.c index 894468975a44..b24c19078eb1 100644 --- a/arch/powerpc/mm/mmu_context.c +++ b/arch/powerpc/mm/mmu_context.c @@ -43,12 +43,13 @@ static inline void switch_mm_pgdir(struct task_struct *tsk, void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk) { + int cpu = smp_processor_id(); bool new_on_cpu = false; /* Mark this context has been used on the new CPU */ - if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) { + if (!cpumask_test_cpu(cpu, mm_cpumask(next))) { VM_WARN_ON_ONCE(next == &init_mm); - cpumask_set_cpu(smp_processor_id(), mm_cpumask(next)); + cpumask_set_cpu(cpu, mm_cpumask(next)); inc_mm_active_cpus(next); /* @@ -101,6 +102,8 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, * sub architectures. Out of line for now */ switch_mmu_context(prev, next, tsk); + + VM_WARN_ON_ONCE(!cpumask_test_cpu(cpu, mm_cpumask(prev))); } #ifndef CONFIG_PPC_BOOK3S_64 |