]> Gentwo Git Trees - linux/.git/commitdiff
ARM64: Revive cpu tracking in mm_struct
authorChristoph Lameter (Ampere) <cl@linux.com>
Thu, 7 Dec 2023 04:11:49 +0000 (20:11 -0800)
committerChristoph Lameter (Ampere) <cl@linux.com>
Wed, 20 Dec 2023 15:20:52 +0000 (07:20 -0800)
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) <cl@linux.com>
arch/arm64/include/asm/tlbbatch.h
arch/arm64/kernel/setup.c
arch/arm64/kernel/smp.c
arch/arm64/mm/context.c

index fedb0b87b8db45dbb5228f41c587efbcff9ef004..3d4d04b38e3cac44b4bb870cbfa4eacf3c0ceabc 100644 (file)
@@ -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 */
index 417a8a86b2db595b5741b77a6c362502bb2f3617..fb9b9c56a1a810c8e1f2b3731d91bbf0806ce885 100644 (file)
@@ -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. */
index defbab84e9e5c7968cabe030e28ef261c9507fb7..175e93caaf72ccbcf7497e87378e1ece80c819a4 100644 (file)
@@ -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;
 }
 
index 5a06d05251ebf4aecca186c9f3ea5ccdf9716828..71c7a2ac6adddff593024a155a40ed930d930db6 100644 (file)
@@ -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