Re: [PATCH v5 12/16] x86/percpu/64: Remove INIT_PER_CPU macros
From: Uros Bizjak
Date: Thu Nov 07 2024 - 09:00:03 EST
On Tue, Nov 5, 2024 at 4:58 PM Brian Gerst <brgerst@xxxxxxxxx> wrote:
>
> Now that the load and link addresses of percpu variables are the same,
> these macros are no longer necessary.
>
> Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
Reviewed-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> ---
> arch/x86/include/asm/desc.h | 1 -
> arch/x86/include/asm/percpu.h | 22 ----------------------
> arch/x86/kernel/head64.c | 2 +-
> arch/x86/kernel/irq_64.c | 1 -
> arch/x86/kernel/vmlinux.lds.S | 7 -------
> arch/x86/tools/relocs.c | 1 -
> 6 files changed, 1 insertion(+), 33 deletions(-)
>
> diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
> index 62dc9f59ea76..ec95fe44fa3a 100644
> --- a/arch/x86/include/asm/desc.h
> +++ b/arch/x86/include/asm/desc.h
> @@ -46,7 +46,6 @@ struct gdt_page {
> } __attribute__((aligned(PAGE_SIZE)));
>
> DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
> -DECLARE_INIT_PER_CPU(gdt_page);
>
> /* Provide the original GDT */
> static inline struct desc_struct *get_cpu_gdt_rw(unsigned int cpu)
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index c55a79d5feae..1ded1207528d 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -20,12 +20,6 @@
>
> #define PER_CPU_VAR(var) __percpu(var)__percpu_rel
>
> -#ifdef CONFIG_X86_64_SMP
> -# define INIT_PER_CPU_VAR(var) init_per_cpu__##var
> -#else
> -# define INIT_PER_CPU_VAR(var) var
> -#endif
> -
> #else /* !__ASSEMBLY__: */
>
> #include <linux/build_bug.h>
> @@ -97,22 +91,6 @@
> #define __percpu_arg(x) __percpu_prefix "%" #x
> #define __force_percpu_arg(x) __force_percpu_prefix "%" #x
>
> -/*
> - * Initialized pointers to per-CPU variables needed for the boot
> - * processor need to use these macros to get the proper address
> - * offset from __per_cpu_load on SMP.
> - *
> - * There also must be an entry in vmlinux_64.lds.S
> - */
> -#define DECLARE_INIT_PER_CPU(var) \
> - extern typeof(var) init_per_cpu_var(var)
> -
> -#ifdef CONFIG_X86_64_SMP
> -# define init_per_cpu_var(var) init_per_cpu__##var
> -#else
> -# define init_per_cpu_var(var) var
> -#endif
> -
> /*
> * For arch-specific code, we can use direct single-insn ops (they
> * don't give an lvalue though).
> diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
> index 4b9d4557fc94..d4398261ad81 100644
> --- a/arch/x86/kernel/head64.c
> +++ b/arch/x86/kernel/head64.c
> @@ -559,7 +559,7 @@ void early_setup_idt(void)
> */
> void __head startup_64_setup_gdt_idt(void)
> {
> - struct desc_struct *gdt = (void *)(__force unsigned long)init_per_cpu_var(gdt_page.gdt);
> + struct desc_struct *gdt = (void *)(__force unsigned long)gdt_page.gdt;
> void *handler = NULL;
>
> struct desc_ptr startup_gdt_descr = {
> diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
> index ade0043ce56e..56bdeecd8ee0 100644
> --- a/arch/x86/kernel/irq_64.c
> +++ b/arch/x86/kernel/irq_64.c
> @@ -27,7 +27,6 @@
> #include <asm/apic.h>
>
> DEFINE_PER_CPU_PAGE_ALIGNED(struct irq_stack, irq_stack_backing_store) __visible;
> -DECLARE_INIT_PER_CPU(irq_stack_backing_store);
>
> #ifdef CONFIG_VMAP_STACK
> /*
> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> index 859ff7c0dc02..fd1ecb1dbc1d 100644
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -450,13 +450,6 @@ SECTIONS
> PROVIDE(__ref_stack_chk_guard = __stack_chk_guard);
>
> #ifdef CONFIG_X86_64
> -/*
> - * Per-cpu symbols which need to be offset from __per_cpu_load
> - * for the boot processor.
> - */
> -#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x)
> -INIT_PER_CPU(gdt_page);
> -INIT_PER_CPU(irq_stack_backing_store);
>
> #ifdef CONFIG_MITIGATION_UNRET_ENTRY
> . = ASSERT((retbleed_return_thunk & 0x3f) == 0, "retbleed_return_thunk not cacheline-aligned");
> diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
> index 8d9e82748615..c3124aac7ab3 100644
> --- a/arch/x86/tools/relocs.c
> +++ b/arch/x86/tools/relocs.c
> @@ -89,7 +89,6 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
> "__initramfs_start|"
> "(jiffies|jiffies_64)|"
> #if ELF_BITS == 64
> - "init_per_cpu__.*|"
> "__end_rodata_hpage_align|"
> #endif
> "_end)$"
> --
> 2.47.0
>