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 RESEND v3 5/5] x86/mm: Re-enable preemption before waiting for kernel TLB flushes
Date: Tue, 10 Nov 2026 16:28:06 +0800 [thread overview]
Message-ID: <7d7ddfa8e7dfe4e3d8923545929b632688442fb0.1794235715.git.zhouchuyi@bytedance.com> (raw)
In-Reply-To: <cover.1794235715.git.zhouchuyi@bytedance.com>
flush_tlb_kernel_range() uses on_each_cpu() to synchronously flush
kernel mappings on all online CPUs when using the IPI backend.
The synchronous wait can become longer as the number of online CPUs
grows, and a remote CPU with interrupts disabled can further delay
completion. Preemption remains disabled throughout this wait, delaying
higher-priority tasks on the initiating CPU. The outer guard prevents
the SMP layer from making its final completion wait preemptible.
The flush_tlb_info descriptor is allocated on the caller's stack and
remains valid until on_each_cpu() returns. The SMP layer protects CPU
selection, IPI queueing and local callback execution, so the kernel
flush caller does not need to remain pinned while waiting for remote
completion.
INVLPGB requires separate protection: TLBSYNC only waits for operations
issued on the same CPU. Disable preemption inside
invlpgb_kernel_range_flush() across the broadcast loop and TLBSYNC.
The full-flush helper invlpgb_flush_all() already provides this
protection.
Remove the outer preemption guard from flush_tlb_kernel_range() so the
IPI completion wait can be preempted when the caller's context allows
it. Keep both flush backends synchronous.
Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/x86/mm/tlb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 97a53a6ce50d..1631ef370e91 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1474,6 +1474,9 @@ static void invlpgb_kernel_range_flush(struct flush_tlb_info *info)
{
unsigned long addr, nr;
+ /* Keep the INVLPGB operations and TLBSYNC on the same CPU. */
+ guard(preempt)();
+
for (addr = info->start; addr < info->end; addr += nr << PAGE_SHIFT) {
nr = (info->end - addr) >> PAGE_SHIFT;
@@ -1515,8 +1518,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
.end = end,
};
- guard(preempt)();
-
if (tlb_range_exceeds_ceiling(start, end, PAGE_SHIFT))
flush_tlb_all();
else
prev parent reply other threads:[~2026-11-10 8:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:28 [PATCH RESEND v3 0/5] x86/mm: Allow preemption while " Chuyi Zhou
2026-11-10 8:28 ` [PATCH RESEND v3 1/5] x86/mm: Account for remote kernel TLB flush requests Chuyi Zhou
2026-11-10 8:28 ` [PATCH RESEND v3 2/5] x86/mm: Share the full TLB flush dispatch Chuyi Zhou
2026-11-10 8:28 ` [PATCH RESEND v3 3/5] x86/mm: Extract the TLB range flush threshold check Chuyi Zhou
2026-11-10 8:28 ` [PATCH RESEND v3 4/5] x86/mm: Initialize kernel TLB flush requests directly Chuyi Zhou
2026-11-10 8:28 ` Chuyi Zhou [this message]
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=7d7ddfa8e7dfe4e3d8923545929b632688442fb0.1794235715.git.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®