xen/link: Don't separate .data.read_mostly from .data
PATCH 1/1 xen/link: Don't separate .data.read_mostly from .data
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Baptiste Le Duc <[email protected]>
CC: Timothy Pearson <[email protected]>
CC: Ross Lagerwall <[email protected]>
This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
--- xen/arch/arm/xen.lds.S | 8 +++----- xen/arch/ppc/xen.lds.S | 8 +++----- xen/arch/riscv/xen.lds.S | 7 ++----- xen/arch/x86/xen.lds.S | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)
xen/arch/arm/xen.lds.S +3 -5
@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(SMP_CACHE_BYTES); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :text
xen/arch/ppc/xen.lds.S +3 -5
@@ -77,16 +77,14 @@ SECTIONS __ro_after_init_end = .; } :text - DECL_SECTION(.data.read_mostly) { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); DECL_SECTION(.data) { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :text
xen/arch/riscv/xen.lds.S +2 -5
@@ -84,16 +84,13 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) *(.sdata .sdata.*) *(.data .data.*) CONSTRUCTORS
xen/arch/x86/xen.lds.S +1 -3
@@ -295,13 +295,11 @@ SECTIONS __2M_rwdata_start = .; /* Start of 2M superpages, mapped RW. */ . = ALIGN(SMP_CACHE_BYTES); - DECL_SECTION(.data.read_mostly) { + DECL_SECTION(.data) { *(.data.read_mostly) HYPFS_PARAM - } PHDR(text) - DECL_SECTION(.data) { *(.data.page_aligned) *(.data .data.*) } PHDR(text)
base-commit: 4263fe42b736596cfa5bfec661f2f55f02759aa7
prerequisite-patch-id: 680071148129321ffaf7bd7435d031904014f556
Signature · 1 line
2.39.5
Hi Andrew,
Quoted 42 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Baptiste Le Duc <[email protected]>
CC: Timothy Pearson <[email protected]>
CC: Ross Lagerwall <[email protected]>This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
--- xen/arch/arm/xen.lds.S | 8 +++----- xen/arch/ppc/xen.lds.S | 8 +++----- xen/arch/riscv/xen.lds.S | 7 ++----- xen/arch/x86/xen.lds.S | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)xen/arch/arm/xen.lds.S +0
-2@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly)
xen/arch/arm/xen.lds.S SECTIONS · line 95
Quoted 10 lines
xen/arch/arm/xen.lds.S +2
-3- } :text - . = ALIGN(SMP_CACHE_BYTES); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned)
A small question: why are you moving data.page_aligned? I don't think that this can cause issues, but I want to understand the reason.
Quoted 73 lines
xen/arch/arm/xen.lds.S +1
-0+ *(.data .data.*) CONSTRUCTORS } :textxen/arch/ppc/xen.lds.S +3
-5@@ -77,16 +77,14 @@ SECTIONS __ro_after_init_end = .; } :text - DECL_SECTION(.data.read_mostly) { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); DECL_SECTION(.data) { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :textxen/arch/riscv/xen.lds.S +2
-5@@ -84,16 +84,13 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) *(.sdata .sdata.*) *(.data .data.*) CONSTRUCTORSxen/arch/x86/xen.lds.S +1
-3@@ -295,13 +295,11 @@ SECTIONS __2M_rwdata_start = .; /* Start of 2M superpages, mapped RW. */ . = ALIGN(SMP_CACHE_BYTES); - DECL_SECTION(.data.read_mostly) { + DECL_SECTION(.data) { *(.data.read_mostly) HYPFS_PARAM - } PHDR(text) - DECL_SECTION(.data) { *(.data.page_aligned) *(.data .data.*) } PHDR(text)base-commit:
4263fe42b736596cfa5bfec661f2f55f02759aa7
prerequisite-patch-id:680071148129321ffaf7bd7435d031904014f556
Signature · 1 line
WBR, Volodymyr
Quoted 21 lines · Volodymyr Babchuk
Hi Andrew,
Quoted 17 lines · Andrew Cooper
xen/arch/arm/xen.lds.S +1
-5@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(SMP_CACHE_BYTES); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly)
Quoted 5 lines
xen/arch/arm/xen.lds.S SECTIONS · line 95
Quoted 3 lines
xen/arch/arm/xen.lds.S +1
-0HYPFS_PARAM + *(.data.page_aligned)A small question: why are you moving data.page_aligned? I don't think that this can cause issues, but I want to understand the reason.
Because HYPFS_DATA is read_mostly too.
~Andrew
Quoted 3 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Why "error" though? Our linking scripts were, aiui, originally derived from Linux'es, where the section (and many others) was also separate back at the time. It just so happened that folding of various output sections never has gone as far as also dealing with this one.
Quoted 5 lines
Simply place .data.read_mostly in .data.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Preferably with the description adjusted a little:
Jan
Quoted 112 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Baptiste Le Duc <[email protected]>
CC: Timothy Pearson <[email protected]>
CC: Ross Lagerwall <[email protected]>This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
--- xen/arch/arm/xen.lds.S | 8 +++----- xen/arch/ppc/xen.lds.S | 8 +++----- xen/arch/riscv/xen.lds.S | 7 ++----- xen/arch/x86/xen.lds.S | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)xen/arch/arm/xen.lds.S +3
-5@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(SMP_CACHE_BYTES); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :textxen/arch/ppc/xen.lds.S +3
-5@@ -77,16 +77,14 @@ SECTIONS __ro_after_init_end = .; } :text - DECL_SECTION(.data.read_mostly) { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); DECL_SECTION(.data) { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :textxen/arch/riscv/xen.lds.S +2
-5@@ -84,16 +84,13 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) *(.sdata .sdata.*) *(.data .data.*) CONSTRUCTORSxen/arch/x86/xen.lds.S +0
-1@@ -295,13 +295,11 @@ SECTIONS __2M_rwdata_start = .; /* Start of 2M superpages, mapped RW. */ . = ALIGN(SMP_CACHE_BYTES); - DECL_SECTION(.data.read_mostly) {
xen/arch/x86/xen.lds.S SECTIONS · line 305
Quoted 10 lines
xen/arch/x86/xen.lds.S +1
-2+ DECL_SECTION(.data) { *(.data.read_mostly) HYPFS_PARAM - } PHDR(text) - DECL_SECTION(.data) { *(.data.page_aligned) *(.data .data.*) } PHDR(text)
The ordering is preserved, but the alignment between the two isn't. Today the ALIGN() before .data sits between .data.read_mostly and regular .data. After this patch it sits before .data.read_mostly, and the only thing separating it from *(.sdata/.data) is *(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm with CONFIG_MPU. So the tail of .data.read_mostly will share a cache line with ordinary .data, which is the false sharing __read_mostly is meant to avoid (IIUC).
Could you add ". = ALIGN(SMP_CACHE_BYTES);" after HYPFS_PARAM, so the separation doesn't depend on whether an arch has any .data.page_aligned?
~ Oleksii
Quoted 115 lines · Oleksii Kurochko
Quoted 103 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Baptiste Le Duc <[email protected]>
CC: Timothy Pearson <[email protected]>
CC: Ross Lagerwall <[email protected]>This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
---
xen/arch/arm/xen.lds.S | 8 +++----- xen/arch/ppc/xen.lds.S | 8 +++-----xen/arch/riscv/xen.lds.S| 7 ++----- xen/arch/x86/xen.lds.S | 4 +---4 files changed, 9 insertions(+), 18 deletions(-)xen/arch/arm/xen.lds.S +0
-3@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(SMP_CACHE_BYTES);.data : { /* Data */
- *(.data.page_aligned)
+ *(.data.read_mostly)
HYPFS_PARAM
+ *(.data.page_aligned)
+
*(.data .data.*)
CONSTRUCTORS
} :textxen/arch/ppc/xen.lds.S +0
-3@@ -77,16 +77,14 @@ SECTIONS __ro_after_init_end = .; } :text - DECL_SECTION(.data.read_mostly) { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE);
DECL_SECTION(.data){ /* Data */ - *(.data.page_aligned)
+ *(.data.read_mostly)
HYPFS_PARAM
+ *(.data.page_aligned)
+
*(.data .data.*)
CONSTRUCTORS
} :textxen/arch/riscv/xen.lds.S +0
-3@@ -84,16 +84,13 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE);.data : { /* Data */
- *(.data.page_aligned)
+ *(.data.read_mostly)
HYPFS_PARAM
+ *(.data.page_aligned)
*(.sdata .sdata.*)
*(.data .data.*)
CONSTRUCTORSxen/arch/x86/xen.lds.S +0
-0@@ -295,13 +295,11 @@ SECTIONS
__2M_rwdata_start= .; /* Start of 2M superpages, mapped RW. */
. =ALIGN(SMP_CACHE_BYTES);
-DECL_SECTION(.data.read_mostly){Quoted 8 lines
+
DECL_SECTION(.data){
*(.data.read_mostly)
HYPFS_PARAM
- } PHDR(text)
-DECL_SECTION(.data){
*(.data.page_aligned)
*(.data .data.*)
} PHDR(text)
Quoted 8 lines
The ordering is preserved, but the alignment between the two isn't. Today the
ALIGN()before .data sits between .data.read_mostly and regular .data. After this patch it sits before .data.read_mostly, and the only thing separating it from *(.sdata/.data) is *(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm withCONFIG_MPU. So the tail of .data.read_mostly will share a cache line with ordinary .data, which is the false sharing__read_mostlyis meant to avoid (IIUC).
__read_mostly is indeed meant to reduce false sharing, but this patch does not introduce any.
HYPFS_PARAM should have been read_mostly to begin with, and page alignment is greater th cache alignment so there's no sharing there either.
~Andrew
Oleksii Kurochko
Reviewed-byQuoted 125 lines · Andrew Cooper
Quoted 115 lines · Oleksii Kurochko
Quoted 103 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Baptiste Le Duc <[email protected]>
CC: Timothy Pearson <[email protected]>
CC: Ross Lagerwall <[email protected]>This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
--- xen/arch/arm/xen.lds.S | 8 +++----- xen/arch/ppc/xen.lds.S | 8 +++----- xen/arch/riscv/xen.lds.S | 7 ++----- xen/arch/x86/xen.lds.S | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-)xen/arch/arm/xen.lds.S +2
-4@@ -86,16 +86,14 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(SMP_CACHE_BYTES); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :textxen/arch/ppc/xen.lds.S +2
-4@@ -77,16 +77,14 @@ SECTIONS __ro_after_init_end = .; } :text - DECL_SECTION(.data.read_mostly) { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); DECL_SECTION(.data) { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) + *(.data .data.*) CONSTRUCTORS } :textxen/arch/riscv/xen.lds.S +1
-4@@ -84,16 +84,13 @@ SECTIONS __ro_after_init_end = .; } : text - .data.read_mostly : { - *(.data.read_mostly) - } :text - . = ALIGN(PAGE_SIZE); .data : { /* Data */ - *(.data.page_aligned) + *(.data.read_mostly) HYPFS_PARAM + *(.data.page_aligned) *(.sdata .sdata.*) *(.data .data.*) CONSTRUCTORSxen/arch/x86/xen.lds.S +0
-0@@ -295,13 +295,11 @@ SECTIONS __2M_rwdata_start = .; /* Start of 2M superpages, mappedRW. */
. =ALIGN(SMP_CACHE_BYTES);
-DECL_SECTION(.data.read_mostly){Quoted 8 lines
+
DECL_SECTION(.data){
*(.data.read_mostly)
HYPFS_PARAM
- } PHDR(text)
-DECL_SECTION(.data){
*(.data.page_aligned)
*(.data .data.*)
} PHDR(text)Quoted 8 lines
The ordering is preserved, but the alignment between the two isn't. Today the
ALIGN()before .data sits between .data.read_mostly and regular .data. After this patch it sits before .data.read_mostly, and the only thing separating it from *(.sdata/.data) is *(.data.page_aligned), which has no inputs on RISC-V, PPC or Arm withCONFIG_MPU. So the tail of .data.read_mostly will share a cache line with ordinary .data, which is the false sharing__read_mostlyis meant to avoid (IIUC).
Quoted 5 lines
__read_mostlyis indeed meant to reduce false sharing, but this patch does not introduce any.
HYPFS_PARAMshould have beenread_mostlyto begin with, and page alignment is greater th cache alignment so there's no sharing there either.
Thanks for clarifying. Then:
~ Oleksii
Quoted 6 lines · Andrew Cooper
This appears to be an error in x86 which got copied into all other architectures. .data.read_mostly is an internal detail, and none of the similar sections get exposed externally.
Simply place .data.read_mostly in .data.
Quoted 8 lines
No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
This is to simplfy the script checking that xen.efi's section attributes/alignments are correct for UEFI SecureBoot.
This is worth moving to the commit message to explain why the change is made. Also "simplify". Also, also stating the rearrangement of .data.page_aligned and HYPFS_PARAM is worth adding.
With that:
Thanks,
Jason