mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
x86/mm: Factor out flush_tlb_info initialization
get_flush_tlb_info() has two responsibilities: it reserves the per-CPU flush_tlb_info storage and it initializes the fields that describe the flush operation. The per-CPU storage also carries the DEBUG_VM reentrancy check and the matching put_flush_tlb_info() lifetime rules. Moving flush_tlb_info back to caller-provided storage requires the same field initialization without tying the caller to the per-CPU object. Leaving the field setup embedded in get_flush_tlb_info() would either keep those callers tied to the per-CPU object or duplicate the initialization logic. Split the field setup into init_flush_tlb_info(). Keep the per-CPU storage selection, DEBUG_VM reentrancy check and put_flush_tlb_info() lifetime rules in get_flush_tlb_info(). No functional change intended. Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://patch.msgid.link/20260709122933.4021501-11-zhouchuyi@bytedance.com
This commit is contained in:
parent
1aac65f3e6
commit
33c179b502
|
|
@ -1379,10 +1379,33 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct flush_tlb_info, flush_tlb_info);
|
|||
static DEFINE_PER_CPU(unsigned int, flush_tlb_info_idx);
|
||||
#endif
|
||||
|
||||
static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned int stride_shift, bool freed_tables,
|
||||
u64 new_tlb_gen)
|
||||
static void init_flush_tlb_info(struct flush_tlb_info *info, struct mm_struct *mm,
|
||||
unsigned long start, unsigned long end,
|
||||
unsigned int stride_shift, bool freed_tables,
|
||||
u64 new_tlb_gen)
|
||||
{
|
||||
/*
|
||||
* If the number of flushes is so large that a full flush
|
||||
* would be faster, do a full flush.
|
||||
*/
|
||||
if ((end - start) >> stride_shift > tlb_single_page_flush_ceiling) {
|
||||
start = 0;
|
||||
end = TLB_FLUSH_ALL;
|
||||
}
|
||||
|
||||
info->start = start;
|
||||
info->end = end;
|
||||
info->mm = mm;
|
||||
info->stride_shift = stride_shift;
|
||||
info->freed_tables = freed_tables;
|
||||
info->new_tlb_gen = new_tlb_gen;
|
||||
info->initiating_cpu = smp_processor_id();
|
||||
info->trim_cpumask = 0;
|
||||
}
|
||||
|
||||
static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm, unsigned long start,
|
||||
unsigned long end, unsigned int stride_shift,
|
||||
bool freed_tables, u64 new_tlb_gen)
|
||||
{
|
||||
struct flush_tlb_info *info = this_cpu_ptr(&flush_tlb_info);
|
||||
|
||||
|
|
@ -1395,24 +1418,7 @@ static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm,
|
|||
BUG_ON(this_cpu_inc_return(flush_tlb_info_idx) != 1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the number of flushes is so large that a full flush
|
||||
* would be faster, do a full flush.
|
||||
*/
|
||||
if ((end - start) >> stride_shift > tlb_single_page_flush_ceiling) {
|
||||
start = 0;
|
||||
end = TLB_FLUSH_ALL;
|
||||
}
|
||||
|
||||
info->start = start;
|
||||
info->end = end;
|
||||
info->mm = mm;
|
||||
info->stride_shift = stride_shift;
|
||||
info->freed_tables = freed_tables;
|
||||
info->new_tlb_gen = new_tlb_gen;
|
||||
info->initiating_cpu = smp_processor_id();
|
||||
info->trim_cpumask = 0;
|
||||
|
||||
init_flush_tlb_info(info, mm, start, end, stride_shift, freed_tables, new_tlb_gen);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user