mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/mm: Hide mm_free_global_asid() definition under 'CONFIG_BROADCAST_TLB_FLUSH'
@ 2026-01-14 13:21 Hou Wenlong
  2026-01-14 15:09 ` Rik van Riel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hou Wenlong @ 2026-01-14 13:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: Hou Wenlong, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Andy Lutomirski,
	Peter Zijlstra, Rik van Riel, Andrew Morton, Will Deacon,
	Ryan Roberts, Jann Horn, Barry Song

When 'CONFIG_BROADCAST_TLB_FLUSH' is not enabled, mm_free_global_asid()
remains a globally visible symbol and generates a useless function call
to it in destroy_context(). Therefore, hide the mm_free_global_asid()
definition under 'CONFIG_BROADCAST_TLB_FLUSH' and provide a static
inline empty version when it is not enabled to remove the function call.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
 arch/x86/include/asm/mmu_context.h | 5 -----
 arch/x86/include/asm/tlbflush.h    | 3 +++
 arch/x86/mm/tlb.c                  | 4 ++--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 73bf3b1b44e8..fa99293dcd91 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -139,11 +139,6 @@ static inline void mm_reset_untag_mask(struct mm_struct *mm)
 #define enter_lazy_tlb enter_lazy_tlb
 extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk);
 
-#define mm_init_global_asid mm_init_global_asid
-extern void mm_init_global_asid(struct mm_struct *mm);
-
-extern void mm_free_global_asid(struct mm_struct *mm);
-
 /*
  * Init a new mm.  Used on mm copies, like at fork()
  * and on mm's that are brand-new, like at execve().
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 00daedfefc1b..5114bf50c911 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -292,9 +292,12 @@ static inline bool mm_in_asid_transition(struct mm_struct *mm)
 
 	return mm && READ_ONCE(mm->context.asid_transition);
 }
+
+extern void mm_free_global_asid(struct mm_struct *mm);
 #else
 static inline u16 mm_global_asid(struct mm_struct *mm) { return 0; }
 static inline void mm_init_global_asid(struct mm_struct *mm) { }
+static inline void mm_free_global_asid(struct mm_struct *mm) { }
 static inline void mm_assign_global_asid(struct mm_struct *mm, u16 asid) { }
 static inline void mm_clear_asid_transition(struct mm_struct *mm) { }
 static inline bool mm_in_asid_transition(struct mm_struct *mm) { return false; }
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index f5b93e01e347..621e09d049cb 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -401,6 +401,7 @@ static void use_global_asid(struct mm_struct *mm)
 	mm_assign_global_asid(mm, asid);
 }
 
+#ifdef CONFIG_BROADCAST_TLB_FLUSH
 void mm_free_global_asid(struct mm_struct *mm)
 {
 	if (!cpu_feature_enabled(X86_FEATURE_INVLPGB))
@@ -412,13 +413,12 @@ void mm_free_global_asid(struct mm_struct *mm)
 	guard(raw_spinlock_irqsave)(&global_asid_lock);
 
 	/* The global ASID can be re-used only after flush at wrap-around. */
-#ifdef CONFIG_BROADCAST_TLB_FLUSH
 	__set_bit(mm->context.global_asid, global_asid_freed);
 
 	mm->context.global_asid = 0;
 	global_asid_available++;
-#endif
 }
+#endif
 
 /*
  * Is the mm transitioning from a CPU-local ASID to a global ASID?
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-16 20:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-14 13:21 [PATCH] x86/mm: Hide mm_free_global_asid() definition under 'CONFIG_BROADCAST_TLB_FLUSH' Hou Wenlong
2026-01-14 15:09 ` Rik van Riel
2026-01-14 19:28 ` Borislav Petkov
2026-01-15  3:28   ` Hou Wenlong
2026-01-15  3:38 ` [PATCH v2] " Hou Wenlong
2026-01-15  9:15   ` Borislav Petkov
2026-01-16  3:47     ` Hou Wenlong
2026-01-16 20:47       ` Borislav Petkov

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®