Skip to content

Commit 954fc7a

Browse files
bysuibp3tk0v
authored andcommitted
x86/mm: Hide mm_free_global_asid() definition under CONFIG_BROADCAST_TLB_FLUSH
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> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Rik van Riel <riel@surriel.com> Link: https://patch.msgid.link/b262a8ec8076fb26bb692aaf113848b1e6f40e40.1768448079.git.houwenlong.hwl@antgroup.com
1 parent 8a4e92b commit 954fc7a

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

arch/x86/include/asm/mmu_context.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ static inline void mm_reset_untag_mask(struct mm_struct *mm)
139139
#define enter_lazy_tlb enter_lazy_tlb
140140
extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk);
141141

142-
#define mm_init_global_asid mm_init_global_asid
143142
extern void mm_init_global_asid(struct mm_struct *mm);
144-
145143
extern void mm_free_global_asid(struct mm_struct *mm);
146144

147145
/*

arch/x86/include/asm/tlbflush.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,12 @@ static inline bool mm_in_asid_transition(struct mm_struct *mm)
292292

293293
return mm && READ_ONCE(mm->context.asid_transition);
294294
}
295+
296+
extern void mm_free_global_asid(struct mm_struct *mm);
295297
#else
296298
static inline u16 mm_global_asid(struct mm_struct *mm) { return 0; }
297299
static inline void mm_init_global_asid(struct mm_struct *mm) { }
300+
static inline void mm_free_global_asid(struct mm_struct *mm) { }
298301
static inline void mm_assign_global_asid(struct mm_struct *mm, u16 asid) { }
299302
static inline void mm_clear_asid_transition(struct mm_struct *mm) { }
300303
static inline bool mm_in_asid_transition(struct mm_struct *mm) { return false; }

arch/x86/mm/tlb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ static void use_global_asid(struct mm_struct *mm)
401401
mm_assign_global_asid(mm, asid);
402402
}
403403

404+
#ifdef CONFIG_BROADCAST_TLB_FLUSH
404405
void mm_free_global_asid(struct mm_struct *mm)
405406
{
406407
if (!cpu_feature_enabled(X86_FEATURE_INVLPGB))
@@ -412,13 +413,12 @@ void mm_free_global_asid(struct mm_struct *mm)
412413
guard(raw_spinlock_irqsave)(&global_asid_lock);
413414

414415
/* The global ASID can be re-used only after flush at wrap-around. */
415-
#ifdef CONFIG_BROADCAST_TLB_FLUSH
416416
__set_bit(mm->context.global_asid, global_asid_freed);
417417

418418
mm->context.global_asid = 0;
419419
global_asid_available++;
420-
#endif
421420
}
421+
#endif
422422

423423
/*
424424
* Is the mm transitioning from a CPU-local ASID to a global ASID?

0 commit comments

Comments
 (0)