mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chuyi Zhou" <zhouchuyi@bytedance.com>
To: <tglx@kernel.org>, <mingo@redhat.com>, <luto@kernel.org>,
	 <peterz@infradead.org>, <paulmck@kernel.org>,
	<muchun.song@linux.dev>,  <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <pbonzini@redhat.com>,
	 <bigeasy@linutronix.de>, <clrkwllms@kernel.org>,
	<rostedt@goodmis.org>,  <nadav.amit@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, "Chuyi Zhou" <zhouchuyi@bytedance.com>
Subject: [PATCH 2/5] x86/mm: Share the full TLB flush dispatch
Date: Mon, 21 Sep 2026 17:53:56 +0800	[thread overview]
Message-ID: <20260921095359.3784458-3-zhouchuyi@bytedance.com> (raw)
In-Reply-To: <20260921095359.3784458-1-zhouchuyi@bytedance.com>

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

  parent reply	other threads:[~2026-09-21  9:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  9:53 [PATCH 0/5] x86/mm: Allow preemption while waiting for kernel TLB flushes Chuyi Zhou
2026-09-21  9:53 ` [PATCH 1/5] x86/mm: Account for remote kernel TLB flush requests Chuyi Zhou
2026-09-21  9:53 ` Chuyi Zhou [this message]
2026-09-23  9:17   ` [PATCH 2/5] x86/mm: Share the full TLB flush dispatch Sebastian Andrzej Siewior
2026-09-23  9:25     ` Chuyi Zhou
2026-09-21  9:53 ` [PATCH 3/5] x86/mm: Extract the TLB range flush threshold check Chuyi Zhou
2026-09-21  9:53 ` [PATCH 4/5] x86/mm: Decouple kernel TLB flushes from flush_tlb_info Chuyi Zhou
2026-09-23  9:28   ` Sebastian Andrzej Siewior
2026-09-23 10:43     ` Chuyi Zhou
2026-09-23 10:50       ` Sebastian Andrzej Siewior
2026-09-23 10:54         ` Chuyi Zhou
2026-09-21  9:59 ` [PATCH 5/5] x86/mm: Re-enable preemption before waiting for kernel TLB flushes Chuyi Zhou

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=20260921095359.3784458-3-zhouchuyi@bytedance.com \
    --to=zhouchuyi@bytedance.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=clrkwllms@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=muchun.song@linux.dev \
    --cc=nadav.amit@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.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

all inboxes | Powered by JetHome®