[PATCH v2 10/21] arm64: percpu: Specialise set_my_cpu_offset() for the primary CPU
Jinjie Ruan
ruanjinjie at huawei.com
Thu Oct 8 01:12:28 PDT 2026
在 2026/9/19 0:13, Will Deacon 写道:
> set_my_cpu_offset() is only called from smp_prepare_boot_cpu() which
> runs once on the primary CPU and before alternatives have been applied.
>
> Rework the function so that it operates only on the boot CPU offset,
> drop the unused alternative code sequence and internalise it into smp.c
> alongside its only caller.
>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> arch/arm64/include/asm/percpu.h | 8 --------
> arch/arm64/kernel/smp.c | 8 +++++++-
> 2 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
> index b57b2bb00967..3dc7291b16e9 100644
> --- a/arch/arm64/include/asm/percpu.h
> +++ b/arch/arm64/include/asm/percpu.h
> @@ -12,14 +12,6 @@
> #include <asm/stack_pointer.h>
> #include <asm/sysreg.h>
>
> -static inline void set_my_cpu_offset(unsigned long off)
> -{
> - asm volatile(ALTERNATIVE("msr tpidr_el1, %0",
> - "msr tpidr_el2, %0",
> - ARM64_HAS_VIRT_HOST_EXTN)
> - :: "r" (off) : "memory");
> -}
> -
> static inline unsigned long __hyp_my_cpu_offset(void)
> {
> /*
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index a61dc3016a11..702dee8d0db5 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -446,6 +446,12 @@ void __init smp_cpus_done(unsigned int max_cpus)
> mark_linear_text_alias_ro();
> }
>
> +static void __init set_boot_cpu_offset(void)
> +{
> + asm volatile("msr tpidr_el1, %0"
> + :: "r" (per_cpu_offset(0)) : "memory");
> +}
Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> +
> void __init smp_prepare_boot_cpu(void)
> {
> /*
> @@ -453,7 +459,7 @@ void __init smp_prepare_boot_cpu(void)
> * setup_per_cpu_areas(), and CPU0's boot time per-cpu area will be
> * freed shortly, so we must move over to the runtime per-cpu area.
> */
> - set_my_cpu_offset(per_cpu_offset(smp_processor_id()));
> + set_boot_cpu_offset();
>
> cpuinfo_store_boot_cpu();
> setup_boot_cpu_features();
--
Best regards,
Jinjie
More information about the linux-arm-kernel
mailing list