Skip to content

Commit 177255a

Browse files
npigginmpe
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent f74b2a6 commit 177255a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/powerpc/mm/mmu_context.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ static inline void switch_mm_pgdir(struct task_struct *tsk,
4343
void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
4444
struct task_struct *tsk)
4545
{
46+
int cpu = smp_processor_id();
4647
bool new_on_cpu = false;
4748

4849
/* Mark this context has been used on the new CPU */
49-
if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) {
50+
if (!cpumask_test_cpu(cpu, mm_cpumask(next))) {
5051
VM_WARN_ON_ONCE(next == &init_mm);
51-
cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
52+
cpumask_set_cpu(cpu, mm_cpumask(next));
5253
inc_mm_active_cpus(next);
5354

5455
/*
@@ -101,6 +102,8 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
101102
* sub architectures. Out of line for now
102103
*/
103104
switch_mmu_context(prev, next, tsk);
105+
106+
VM_WARN_ON_ONCE(!cpumask_test_cpu(cpu, mm_cpumask(prev)));
104107
}
105108

106109
#ifndef CONFIG_PPC_BOOK3S_64

0 commit comments

Comments
 (0)