arch/x86/include/asm/mmu_context.h | 2 -- arch/x86/include/asm/tlbflush.h | 3 +++ arch/x86/mm/tlb.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
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.
Reviewed-by: Rik van Riel <riel@surriel.com>
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
v1->v2:
Keep the declarations of mm_init_global_asid() and mm_free_global_asid()
in 'asm/mmu_context.h' to fix the compilation failure of module
building.
---
arch/x86/include/asm/mmu_context.h | 2 --
arch/x86/include/asm/tlbflush.h | 3 +++
arch/x86/mm/tlb.c | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 73bf3b1b44e8..1acafb1c6a93 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -139,9 +139,7 @@ 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);
/*
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?
base-commit: 6e0e1737f35b9d3d071bba15dd36ae5ce3a5d292
--
2.31.1
On Thu, Jan 15, 2026 at 11:38:34AM +0800, Hou Wenlong wrote:
> 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.
>
> Reviewed-by: Rik van Riel <riel@surriel.com>
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> ---
> v1->v2:
> Keep the declarations of mm_init_global_asid() and mm_free_global_asid()
> in 'asm/mmu_context.h' to fix the compilation failure of module
> building.
> ---
> arch/x86/include/asm/mmu_context.h | 2 --
> arch/x86/include/asm/tlbflush.h | 3 +++
> arch/x86/mm/tlb.c | 4 ++--
> 3 files changed, 5 insertions(+), 4 deletions(-)
Did you run the build tests I asked you to do before you sent this?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
On Thu, Jan 15, 2026 at 10:15:06AM +0100, Borislav Petkov wrote: > On Thu, Jan 15, 2026 at 11:38:34AM +0800, Hou Wenlong wrote: > > 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. > > > > Reviewed-by: Rik van Riel <riel@surriel.com> > > Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com> > > --- > > v1->v2: > > Keep the declarations of mm_init_global_asid() and mm_free_global_asid() > > in 'asm/mmu_context.h' to fix the compilation failure of module > > building. > > --- > > arch/x86/include/asm/mmu_context.h | 2 -- > > arch/x86/include/asm/tlbflush.h | 3 +++ > > arch/x86/mm/tlb.c | 4 ++-- > > 3 files changed, 5 insertions(+), 4 deletions(-) > > Did you run the build tests I asked you to do before you sent this? > Honestly, I did not run all the tests you asked. I admit that my attitude was somewhat hasty and not thorough. I sincerely apologize for the trouble this has caused you and for taking up your time. After testing the configuration you provided, I analyzed my code modifications and noticed that the definition of 'mm_free_global_asid()' is included under '#ifndef module' and is only called in destroy_context(). Therefore, I checked all the places where destroy_context() is called and found that it is only called in 'kernel/fork.c', which is not invoked in a module (and the original mm_free_global_asid() was not exported either). To save time, I only tested 'allyesconfig' and my test configuration with module compilation under 'x86_64' and 'i386', and since I did not encounter any issues, I went ahead and sent the patch. I realize now that I did not conduct a complete set of tests. Upon carefully comparing the configuration you provided, I found that the GCC versions are different (mine is 12.2.0 and yours is 13.3.0), and I am using the tip/master branch from the 12th, which also does not match your '6.19-rc3'. After a full night of testing (using the tip/master branch and the '6.19-rc5' tag), I still did not find any issues; it may be related to the compiler. I will try using GCC 13.3.0 to see if that makes a difference and will conduct more randconfig tests. Finally, I apologize once again for taking up your time and thank you for your kind reply. Here is the script I used for testing: ``` # 64-bit make clean LOCALVERSION="" make allnoconfig LOCALVERSION="" make -j32 make clean LOCALVERSION="" make defconfig LOCALVERSION="" make -j32 make clean LOCALVERSION="" make allmodconfig LOCALVERSION="" make -j32 make clean LOCALVERSION="" make allyesconfig LOCALVERSION="" make -j32 # 32-bit make clean LOCALVERSION="" make allnoconfig ARCH=i386 LOCALVERSION="" make -j32 ARCH=i386 make clean LOCALVERSION="" make defconfig ARCH=i386 LOCALVERSION="" make -j32 ARCH=i386 make clean LOCALVERSION="" make allmodconfig ARCH=i386 LOCALVERSION="" make -j32 ARCH=i386 make clean LOCALVERSION="" make allyesconfig ARCH=i386 LOCALVERSION="" make -j32 ARCH=i386 ``` Thanks! > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette
On Fri, Jan 16, 2026 at 11:47:22AM +0800, Hou Wenlong wrote:
> Honestly, I did not run all the tests you asked. I admit that my
> attitude was somewhat hasty and not thorough. I sincerely apologize for
> the trouble this has caused you and for taking up your time.
Thanks for being honest - I appreciate that greatly.
> After testing the configuration you provided, I analyzed my code
> modifications and noticed that the definition of 'mm_free_global_asid()' is
> included under '#ifndef module' and is only called in destroy_context().
> Therefore, I checked all the places where destroy_context() is called and
> found that it is only called in 'kernel/fork.c', which is not invoked in
> a module (and the original mm_free_global_asid() was not exported either).
> To save time, I only tested 'allyesconfig' and my test configuration with
> module compilation under 'x86_64' and 'i386', and since I did not encounter
> any issues, I went ahead and sent the patch. I realize now that I did not
> conduct a complete set of tests.
Yes, that's the thing. Sometimes even visual analysis escapes one weird
configuration which we cannot think about. That's why we try to run a full
battery of build tests, especially when code is changing around ifdeffery
and/or in header files.
And note that you can simply say that you don't have the resources to run
those tests - that's perfectly fine, I can do that. All I'd like to hear is
what you did and didn't test so that I can help. We're a community and usually
help each other where we can. :-)
> Upon carefully comparing the configuration you provided, I found that
> the GCC versions are different (mine is 12.2.0 and yours is 13.3.0), and
> I am using the tip/master branch from the 12th, which also does not
> match your '6.19-rc3'. After a full night of testing (using the tip/master
> branch and the '6.19-rc5' tag), I still did not find any issues; it may be
> related to the compiler. I will try using GCC 13.3.0 to see if that
> makes a difference and will conduct more randconfig tests.
Thanks, that's helpful.
I'll run your v2 through my tests too and if it passes, I'll queue it.
Thanks again for the honest and thorough explanation!
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
© 2016 - 2026 Red Hat, Inc.