[PATCH 5/6] alpha: invalidate the local context in flush_tlb_mm()
From: Magnus Lindholm
Date: Sun Aug 09 2026 - 04:57:24 EST
The SMP flush_tlb_mm() only touches the calling CPU when the mm is its
active_mm:
if (mm == current->active_mm) {
flush_tlb_current(mm);
...
}
smp_call_function(ipi_flush_tlb_mm, mm, 1);
If it is not, nothing happens locally at all: smp_call_function() does not
call back into the caller. mm->context[cpu] is left valid, so this CPU
may later reuse the old ASN, and any translations it still holds for MM
stay usable.
Callers reach this regularly - counting the branch gave 2934 such calls
over a fork-heavy workload and 632 while otherwise idle.
Add the missing else. The UP implementation in asm/tlbflush.h already has
exactly this shape:
if (mm == current->active_mm)
flush_tlb_current(mm);
else
flush_tlb_other(mm);
Unlike flush_tlb_page(), the active_mm test itself is valid here:
flush_tlb_current() calls __load_new_mm_context(), which allocates and
loads a fresh context rather than relying on a targeted tbi() to operate
on whatever ASN happened to be loaded beforehand.
Signed-off-by: Magnus Lindholm <linmag7@xxxxxxxxx>
---
arch/alpha/kernel/smp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index d167b3ba1303..f501a91001cc 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -649,6 +649,13 @@ flush_tlb_mm(struct mm_struct *mm)
preempt_enable();
return;
}
+ } else {
+ /*
+ * smp_call_function() below does not call back into this
+ * CPU, so this is the only chance to retire what it holds
+ * for MM. The UP implementation already does this.
+ */
+ flush_tlb_other(mm);
}
smp_call_function(ipi_flush_tlb_mm, mm, 1);
--
2.53.0