[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250221005345.2156760-8-riel@surriel.com>
Date: Thu, 20 Feb 2025 19:53:06 -0500
From: Rik van Riel <riel@...riel.com>
To: x86@...nel.org
Cc: linux-kernel@...r.kernel.org,
bp@...en8.de,
peterz@...radead.org,
dave.hansen@...ux.intel.com,
zhengqi.arch@...edance.com,
nadav.amit@...il.com,
thomas.lendacky@....com,
kernel-team@...a.com,
linux-mm@...ck.org,
akpm@...ux-foundation.org,
jackmanb@...gle.com,
jannh@...gle.com,
mhklinux@...look.com,
andrew.cooper3@...rix.com,
Manali.Shukla@....com,
Rik van Riel <riel@...riel.com>
Subject: [PATCH v12 07/16] x86/mm: use INVLPGB in flush_tlb_all
The flush_tlb_all() function is not used a whole lot, but we might
as well use broadcast TLB flushing there, too.
Signed-off-by: Rik van Riel <riel@...riel.com>
Tested-by: Manali Shukla <Manali.Shukla@....com>
Tested-by: Brendan Jackman <jackmanb@...gle.com>
Tested-by: Michael Kelley <mhklinux@...look.com>
---
arch/x86/mm/tlb.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 59396a3c6e9c..2d7ed0fda61f 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1065,6 +1065,16 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
}
+static bool broadcast_flush_tlb_all(void)
+{
+ if (!cpu_feature_enabled(X86_FEATURE_INVLPGB))
+ return false;
+
+ guard(preempt)();
+ invlpgb_flush_all();
+ return true;
+}
+
static void do_flush_tlb_all(void *info)
{
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED);
@@ -1074,6 +1084,12 @@ static void do_flush_tlb_all(void *info)
void flush_tlb_all(void)
{
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH);
+
+ /* First try (faster) hardware-assisted TLB invalidation. */
+ if (broadcast_flush_tlb_all())
+ return;
+
+ /* Fall back to the IPI-based invalidation. */
on_each_cpu(do_flush_tlb_all, NULL, 1);
}
--
2.47.1
Powered by blists - more mailing lists