From: Christoph Lameter (Ampere) Date: Thu, 7 Dec 2023 04:11:49 +0000 (-0800) Subject: ARM64: Revive cpu tracking in mm_struct X-Git-Url: https://gentwo.org/gitweb/?a=commitdiff_plain;h=699cfefdfd493bdb590232a1a20f14cb6b7f041b;p=linux%2F.git ARM64: Revive cpu tracking in mm_struct ARM64 used to have the ability to track which cpu has used an address space (mm_struct). The cpumask stored in the mm_struct is currently unused. So what is needed is still there from the core kernel. Revert the removal patch and update it to work with the current kernel source. Signed-off-by: Christoph Lameter (Ampere) --- diff --git a/arch/arm64/include/asm/tlbbatch.h b/arch/arm64/include/asm/tlbbatch.h index fedb0b87b8db..3d4d04b38e3c 100644 --- a/arch/arm64/include/asm/tlbbatch.h +++ b/arch/arm64/include/asm/tlbbatch.h @@ -3,10 +3,11 @@ #define _ARCH_ARM64_TLBBATCH_H struct arch_tlbflush_unmap_batch { - /* - * For arm64, HW can do tlb shootdown, so we don't - * need to record cpumask for sending IPI - */ + /* + * Each bit set is a CPU that potentially has a TLB entry for one of + * the PFNs being flushed.. + */ + struct cpumask cpumask; }; #endif /* _ARCH_ARM64_TLBBATCH_H */ diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 417a8a86b2db..fb9b9c56a1a8 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -369,6 +369,7 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) init_bootcpu_ops(); smp_init_cpus(); + cpumask_set_cpu(smp_processor_id(), mm_cpumask(&init_mm)); smp_build_mpidr_hash(); /* Init percpu seeds for random tags after cpus are set up. */ diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index defbab84e9e5..175e93caaf72 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -213,6 +213,7 @@ asmlinkage notrace void secondary_start_kernel(void) */ mmgrab(mm); current->active_mm = mm; + cpumask_set_cpu(cpu, mm_cpumask(mm)); /* * TTBR0 is only used for the identity mapping at this stage. Make it @@ -321,6 +322,11 @@ int __cpu_disable(void) */ irq_migrate_all_off_this_cpu(); + /* + * Remove this CPU from the vm mask set of all processes + */ + clear_tasks_mm_cpumask(cpu); + return 0; } diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index 5a06d05251eb..71c7a2ac6add 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -209,6 +209,7 @@ static u64 new_context(struct mm_struct *mm) set_asid: __set_bit(asid, asid_map); cur_idx = asid; + cpumask_clear(mm_cpumask(mm)); return asid2ctxid(asid, generation); } @@ -261,6 +262,7 @@ void check_and_switch_context(struct mm_struct *mm) switch_mm_fastpath: arm64_apply_bp_hardening(); + cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); /* * Defer TTBR0_EL1 setting for user threads to uaccess_enable() when