The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Magnus Lindholm <linmag7@gmail.com>
To: richard.henderson@linaro.org, mattst88@gmail.com,
	linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Cc: glaubitz@physik.fu-berlin.de, mcree@orcon.net.nz,
	ink@unseen.parts, macro@orcam.me.uk,
	Magnus Lindholm <linmag7@gmail.com>
Subject: [PATCH 5/6] alpha: invalidate the local context in flush_tlb_mm()
Date: Sun,  9 Aug 2026 10:49:37 +0200	[thread overview]
Message-ID: <20260809085208.3262799-6-linmag7@gmail.com> (raw)
In-Reply-To: <20260809085208.3262799-1-linmag7@gmail.com>

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@gmail.com>
---
 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


  parent reply	other threads:[~2026-08-09  8:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09  8:49 [PATCH 0/6] alpha: fix stale TLB translations breaking copy-on-write and writeback Magnus Lindholm
2026-08-09  8:49 ` [PATCH 1/6] alpha: run check_mmu_context() from finish_arch_post_lock_switch() Magnus Lindholm
2026-08-10  2:37   ` Matt Turner
2026-08-10  2:40     ` Matt Turner
2026-08-10  6:15       ` Magnus Lindholm
2026-08-09  8:49 ` [PATCH 2/6] alpha: only use a targeted tbi() when the target mm is really current Magnus Lindholm
2026-08-09  8:49 ` [PATCH 3/6] alpha: fix the local TLB invalidate in flush_tlb_page() Magnus Lindholm
2026-08-10  2:43   ` Matt Turner
2026-08-10  6:26     ` Magnus Lindholm
2026-08-09  8:49 ` [PATCH 4/6] alpha: only use a targeted tbi() when the target mm is really current (UP) Magnus Lindholm
2026-08-10  2:45   ` Matt Turner
2026-08-10  6:42     ` Magnus Lindholm
2026-08-09  8:49 ` Magnus Lindholm [this message]
2026-08-09  8:49 ` [PATCH 6/6] alpha: invalidate the local context in flush_icache_user_page() Magnus Lindholm
2026-08-10  3:03   ` Matt Turner
2026-08-10  6:11     ` Magnus Lindholm
2026-08-10  2:35 ` [PATCH 0/6] alpha: fix stale TLB translations breaking copy-on-write and writeback Matt Turner
2026-08-10  7:24   ` Magnus Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260809085208.3262799-6-linmag7@gmail.com \
    --to=linmag7@gmail.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=ink@unseen.parts \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=mattst88@gmail.com \
    --cc=mcree@orcon.net.nz \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox