diff mbox series

[v2,1/2] xen: introduce common macros for per-CPU sections defintion

Message ID 27aba3aae7f4a5d4694ab141dca325d7231f2f66.1727185495.git.oleksii.kurochko@gmail.com (mailing list archive)
State New
Headers show
Series Move percpu code to common | expand

Commit Message

Oleksii Kurochko Sept. 24, 2024, 4:42 p.m. UTC
Introduce PERCPU_BSS macro which manages:
 * Alignment of the section start
 * Insertion of per-CPU data sections
 * Alignment and start/end markers for per-CPU data
This change simplifies the linker script maintenance and ensures a unified
approach for per-CPU sections across different architectures.

Refactor the linker scripts for Arm, PPC, and x86 architectures by using
the common macro PERCPU_BSS defined in xen/xen.lds.h to handle per-CPU
data sections.

No functional changes.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in V2:
 - rename PERCPU_SECTION to PERCPU_BSS
 - update the commit message
 - add Acked-by: Julien Grall <jgrall@amazon.com>
 - add Acked-by: Jan Beulich <jbeulich@suse.com>
---

 xen/arch/arm/xen.lds.S    |  9 +--------
 xen/arch/ppc/xen.lds.S    |  9 +--------
 xen/arch/x86/xen.lds.S    |  9 +--------
 xen/include/xen/xen.lds.h | 10 ++++++++++
 4 files changed, 13 insertions(+), 24 deletions(-)

Comments

Andrew Cooper Sept. 24, 2024, 5:01 p.m. UTC | #1
On 24/09/2024 5:42 pm, Oleksii Kurochko wrote:
> Introduce PERCPU_BSS macro which manages:
>  * Alignment of the section start
>  * Insertion of per-CPU data sections
>  * Alignment and start/end markers for per-CPU data
> This change simplifies the linker script maintenance and ensures a unified
> approach for per-CPU sections across different architectures.
>
> Refactor the linker scripts for Arm, PPC, and x86 architectures by using
> the common macro PERCPU_BSS defined in xen/xen.lds.h to handle per-CPU
> data sections.
>
> No functional changes.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> Acked-by: Julien Grall <jgrall@amazon.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> ---
> Changes in V2:
>  - rename PERCPU_SECTION to PERCPU_BSS
>  - update the commit message
>  - add Acked-by: Julien Grall <jgrall@amazon.com>
>  - add Acked-by: Jan Beulich <jbeulich@suse.com>
> ---
>
>  xen/arch/arm/xen.lds.S    |  9 +--------
>  xen/arch/ppc/xen.lds.S    |  9 +--------
>  xen/arch/x86/xen.lds.S    |  9 +--------
>  xen/include/xen/xen.lds.h | 10 ++++++++++
>  4 files changed, 13 insertions(+), 24 deletions(-)

Aren't you missing a hunk in riscv/xen.lds.S ?

~Andrew
Oleksii Kurochko Sept. 25, 2024, 9:23 a.m. UTC | #2
On Tue, 2024-09-24 at 18:01 +0100, Andrew Cooper wrote:
> On 24/09/2024 5:42 pm, Oleksii Kurochko wrote:
> > Introduce PERCPU_BSS macro which manages:
> >  * Alignment of the section start
> >  * Insertion of per-CPU data sections
> >  * Alignment and start/end markers for per-CPU data
> > This change simplifies the linker script maintenance and ensures a
> > unified
> > approach for per-CPU sections across different architectures.
> > 
> > Refactor the linker scripts for Arm, PPC, and x86 architectures by
> > using
> > the common macro PERCPU_BSS defined in xen/xen.lds.h to handle per-
> > CPU
> > data sections.
> > 
> > No functional changes.
> > 
> > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> > Acked-by: Julien Grall <jgrall@amazon.com>
> > Acked-by: Jan Beulich <jbeulich@suse.com>
> > ---
> > Changes in V2:
> >  - rename PERCPU_SECTION to PERCPU_BSS
> >  - update the commit message
> >  - add Acked-by: Julien Grall <jgrall@amazon.com>
> >  - add Acked-by: Jan Beulich <jbeulich@suse.com>
> > ---
> > 
> >  xen/arch/arm/xen.lds.S    |  9 +--------
> >  xen/arch/ppc/xen.lds.S    |  9 +--------
> >  xen/arch/x86/xen.lds.S    |  9 +--------
> >  xen/include/xen/xen.lds.h | 10 ++++++++++
> >  4 files changed, 13 insertions(+), 24 deletions(-)
> 
> Aren't you missing a hunk in riscv/xen.lds.S ?
I thought it would be better to add a hunk in riscv when
percpu_init_areas() will be called in RISC-V's start_xen().

~ Oleksii
Jan Beulich Sept. 25, 2024, 9:56 a.m. UTC | #3
On 25.09.2024 11:23, oleksii.kurochko@gmail.com wrote:
> On Tue, 2024-09-24 at 18:01 +0100, Andrew Cooper wrote:
>> On 24/09/2024 5:42 pm, Oleksii Kurochko wrote:
>>> Introduce PERCPU_BSS macro which manages:
>>>  * Alignment of the section start
>>>  * Insertion of per-CPU data sections
>>>  * Alignment and start/end markers for per-CPU data
>>> This change simplifies the linker script maintenance and ensures a
>>> unified
>>> approach for per-CPU sections across different architectures.
>>>
>>> Refactor the linker scripts for Arm, PPC, and x86 architectures by
>>> using
>>> the common macro PERCPU_BSS defined in xen/xen.lds.h to handle per-
>>> CPU
>>> data sections.
>>>
>>> No functional changes.
>>>
>>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>>> Acked-by: Julien Grall <jgrall@amazon.com>
>>> Acked-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>> Changes in V2:
>>>  - rename PERCPU_SECTION to PERCPU_BSS
>>>  - update the commit message
>>>  - add Acked-by: Julien Grall <jgrall@amazon.com>
>>>  - add Acked-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>>
>>>  xen/arch/arm/xen.lds.S    |  9 +--------
>>>  xen/arch/ppc/xen.lds.S    |  9 +--------
>>>  xen/arch/x86/xen.lds.S    |  9 +--------
>>>  xen/include/xen/xen.lds.h | 10 ++++++++++
>>>  4 files changed, 13 insertions(+), 24 deletions(-)
>>
>> Aren't you missing a hunk in riscv/xen.lds.S ?
> I thought it would be better to add a hunk in riscv when
> percpu_init_areas() will be called in RISC-V's start_xen().

But you have the constructs you're replacing for the other architectures
in RISC-V's xen.lds.S as well. They shouldn't stay around. It was actually
an oversight of mine, so to retain my ack you will need to replace that
too.

Jan
Andrew Cooper Sept. 25, 2024, 9:58 a.m. UTC | #4
On 25/09/2024 10:23 am, oleksii.kurochko@gmail.com wrote:
> On Tue, 2024-09-24 at 18:01 +0100, Andrew Cooper wrote:
>> On 24/09/2024 5:42 pm, Oleksii Kurochko wrote:
>>> Introduce PERCPU_BSS macro which manages:
>>>  * Alignment of the section start
>>>  * Insertion of per-CPU data sections
>>>  * Alignment and start/end markers for per-CPU data
>>> This change simplifies the linker script maintenance and ensures a
>>> unified
>>> approach for per-CPU sections across different architectures.
>>>
>>> Refactor the linker scripts for Arm, PPC, and x86 architectures by
>>> using
>>> the common macro PERCPU_BSS defined in xen/xen.lds.h to handle per-
>>> CPU
>>> data sections.
>>>
>>> No functional changes.
>>>
>>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
>>> Acked-by: Julien Grall <jgrall@amazon.com>
>>> Acked-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>> Changes in V2:
>>>  - rename PERCPU_SECTION to PERCPU_BSS
>>>  - update the commit message
>>>  - add Acked-by: Julien Grall <jgrall@amazon.com>
>>>  - add Acked-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>>
>>>  xen/arch/arm/xen.lds.S    |  9 +--------
>>>  xen/arch/ppc/xen.lds.S    |  9 +--------
>>>  xen/arch/x86/xen.lds.S    |  9 +--------
>>>  xen/include/xen/xen.lds.h | 10 ++++++++++
>>>  4 files changed, 13 insertions(+), 24 deletions(-)
>> Aren't you missing a hunk in riscv/xen.lds.S ?
> I thought it would be better to add a hunk in riscv when
> percpu_init_areas() will be called in RISC-V's start_xen().

If you didn't have the old form already, I'd agree.  But right now this
leaves RISC-V being the odd-architecture-out.

I can fix it on commit, to save another posting, if you're happy?

~Andrew
Oleksii Kurochko Sept. 25, 2024, 10:11 a.m. UTC | #5
On Wed, 2024-09-25 at 10:58 +0100, Andrew Cooper wrote:
> On 25/09/2024 10:23 am, oleksii.kurochko@gmail.com wrote:
> > On Tue, 2024-09-24 at 18:01 +0100, Andrew Cooper wrote:
> > > On 24/09/2024 5:42 pm, Oleksii Kurochko wrote:
> > > > Introduce PERCPU_BSS macro which manages:
> > > >  * Alignment of the section start
> > > >  * Insertion of per-CPU data sections
> > > >  * Alignment and start/end markers for per-CPU data
> > > > This change simplifies the linker script maintenance and
> > > > ensures a
> > > > unified
> > > > approach for per-CPU sections across different architectures.
> > > > 
> > > > Refactor the linker scripts for Arm, PPC, and x86 architectures
> > > > by
> > > > using
> > > > the common macro PERCPU_BSS defined in xen/xen.lds.h to handle
> > > > per-
> > > > CPU
> > > > data sections.
> > > > 
> > > > No functional changes.
> > > > 
> > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> > > > Acked-by: Julien Grall <jgrall@amazon.com>
> > > > Acked-by: Jan Beulich <jbeulich@suse.com>
> > > > ---
> > > > Changes in V2:
> > > >  - rename PERCPU_SECTION to PERCPU_BSS
> > > >  - update the commit message
> > > >  - add Acked-by: Julien Grall <jgrall@amazon.com>
> > > >  - add Acked-by: Jan Beulich <jbeulich@suse.com>
> > > > ---
> > > > 
> > > >  xen/arch/arm/xen.lds.S    |  9 +--------
> > > >  xen/arch/ppc/xen.lds.S    |  9 +--------
> > > >  xen/arch/x86/xen.lds.S    |  9 +--------
> > > >  xen/include/xen/xen.lds.h | 10 ++++++++++
> > > >  4 files changed, 13 insertions(+), 24 deletions(-)
> > > Aren't you missing a hunk in riscv/xen.lds.S ?
> > I thought it would be better to add a hunk in riscv when
> > percpu_init_areas() will be called in RISC-V's start_xen().
> 
> If you didn't have the old form already, I'd agree.  But right now
> this
> leaves RISC-V being the odd-architecture-out.
Oh, I just missed that I had them already. I am just confused with my
another patch series connected to DT device tree info section.

> 
> I can fix it on commit, to save another posting, if you're happy?
I would be happy with that. Thanks.


~ Oleksii
diff mbox series

Patch

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index bd884664ad..0987052f1a 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -198,14 +198,7 @@  SECTIONS
        __bss_start = .;
        *(.bss.stack_aligned)
        *(.bss.page_aligned)
-       . = ALIGN(PAGE_SIZE);
-       __per_cpu_start = .;
-       *(.bss.percpu.page_aligned)
-       *(.bss.percpu)
-       . = ALIGN(SMP_CACHE_BYTES);
-       *(.bss.percpu.read_mostly)
-       . = ALIGN(SMP_CACHE_BYTES);
-       __per_cpu_data_end = .;
+       PERCPU_BSS
        *(.bss .bss.*)
        . = ALIGN(POINTER_ALIGN);
        __bss_end = .;
diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
index 38cd857187..0c4b94814b 100644
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -148,14 +148,7 @@  SECTIONS
         __bss_start = .;
         *(.bss.stack_aligned)
         *(.bss.page_aligned)
-        . = ALIGN(PAGE_SIZE);
-        __per_cpu_start = .;
-        *(.bss.percpu.page_aligned)
-        *(.bss.percpu)
-        . = ALIGN(SMP_CACHE_BYTES);
-        *(.bss.percpu.read_mostly)
-        . = ALIGN(SMP_CACHE_BYTES);
-        __per_cpu_data_end = .;
+        PERCPU_BSS
         *(.bss .bss.*)
         . = ALIGN(POINTER_ALIGN);
         __bss_end = .;
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index d48de67cfd..b60d2f0d82 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -321,14 +321,7 @@  SECTIONS
   DECL_SECTION(.bss) {
        __bss_start = .;
        *(.bss.page_aligned*)
-       . = ALIGN(PAGE_SIZE);
-       __per_cpu_start = .;
-       *(.bss.percpu.page_aligned)
-       *(.bss.percpu)
-       . = ALIGN(SMP_CACHE_BYTES);
-       *(.bss.percpu.read_mostly)
-       . = ALIGN(SMP_CACHE_BYTES);
-       __per_cpu_data_end = .;
+       PERCPU_BSS
        *(.bss .bss.*)
        . = ALIGN(POINTER_ALIGN);
        __bss_end = .;
diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index a17810bb28..24b8900ffe 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -151,6 +151,16 @@ 
 #define LOCK_PROFILE_DATA
 #endif
 
+#define PERCPU_BSS                 \
+       . = ALIGN(PAGE_SIZE);       \
+       __per_cpu_start = .;        \
+       *(.bss.percpu.page_aligned) \
+       *(.bss.percpu)              \
+       . = ALIGN(SMP_CACHE_BYTES); \
+       *(.bss.percpu.read_mostly)  \
+       . = ALIGN(SMP_CACHE_BYTES); \
+       __per_cpu_data_end = .;     \
+
 #ifdef CONFIG_HAS_VPCI
 #define VPCI_ARRAY               \
        . = ALIGN(POINTER_ALIGN); \