[PATCH 2/5] x86/mm: Share the full TLB flush dispatch

From: Chuyi Zhou

Date: Mon Sep 21 2026 - 06:23:05 EST


flush_tlb_all() and kernel_tlb_flush_all() select the same INVLPGB or
IPI backend and account for the same sender-side event. Keeping two
implementations duplicates the backend selection and accounting.

Use kernel_tlb_flush_all() for both the public full-flush interface and
kernel ranges promoted to a full flush. Drop its unused flush_tlb_info
argument and keep the event accounting in the shared helper so each
request is counted once.

Signed-off-by: Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx>
---
arch/x86/mm/tlb.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index da7c408f921c..5e9d1689f605 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1445,7 +1445,7 @@ static void do_flush_tlb_all(void *info)
__flush_tlb_all();
}

-void flush_tlb_all(void)
+static void kernel_tlb_flush_all(void)
{
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH);

@@ -1457,6 +1457,11 @@ void flush_tlb_all(void)
on_each_cpu(do_flush_tlb_all, NULL, 1);
}

+void flush_tlb_all(void)
+{
+ kernel_tlb_flush_all();
+}
+
/* Flush an arbitrarily large range of memory with INVLPGB. */
static void invlpgb_kernel_range_flush(struct flush_tlb_info *info)
{
@@ -1486,16 +1491,6 @@ static void do_kernel_range_flush(void *info)
flush_tlb_one_kernel(addr);
}

-static void kernel_tlb_flush_all(struct flush_tlb_info *info)
-{
- count_vm_tlb_event(NR_TLB_REMOTE_FLUSH);
-
- if (cpu_feature_enabled(X86_FEATURE_INVLPGB))
- invlpgb_flush_all();
- else
- on_each_cpu(do_flush_tlb_all, NULL, 1);
-}
-
static void kernel_tlb_flush_range(struct flush_tlb_info *info)
{
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH);
@@ -1515,7 +1510,7 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
TLB_GENERATION_INVALID);

if (info.end == TLB_FLUSH_ALL)
- kernel_tlb_flush_all(&info);
+ kernel_tlb_flush_all();
else
kernel_tlb_flush_range(&info);
}
--
2.20.1