[PATCH 5/6] alpha: invalidate the local context in flush_tlb_mm()

Magnus Lindholm <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.ports.alpha
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.