Skip to contentSkip to conversation

xen/link: Move SCHEDULER_ARRAY into .rodata

PATCH In review Andrew Cooper 5 participants 8 messages Nov 12 – Nov 13 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/link: Move SCHEDULER_ARRAY into .rodata

This is a list of pointers which is only ever read.

In the ARM linker file, fix some adjacent misalignment.

---
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]>

---
 xen/arch/arm/xen.lds.S   | 6 +++---
 xen/arch/ppc/xen.lds.S   | 2 +-
 xen/arch/riscv/xen.lds.S | 2 +-
 xen/arch/x86/xen.lds.S   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/xen.lds.S +3 -3
index 613511390ff4..d1bb6c62d208 100644
@@ -51,9 +51,10 @@ SECTIONS
 
   . = ALIGN(PAGE_SIZE);
   .rodata : {
-        _srodata = .;          /* Read-only data */
+       _srodata = .;          /* Read-only data */
 
-        BUGFRAMES
+       BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -93,7 +94,6 @@ SECTIONS
   .data : {                    /* Data */
        *(.data.page_aligned)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
 
        *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -1
index 37256c8865a9..cddb70855307 100644
@@ -48,6 +48,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.rodata)
         *(.rodata.*)
@@ -84,7 +85,6 @@ SECTIONS
     DECL_SECTION(.data) {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -1
index d9375a961697..250ee3f36f4f 100644
@@ -43,6 +43,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.srodata)
         *(.srodata.*)
@@ -91,7 +92,6 @@ SECTIONS
     .data : {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.sdata .sdata.*)
xen/arch/x86/xen.lds.S +1 -1
index 8f943e11ead4..925848980219 100644
@@ -119,6 +119,7 @@ SECTIONS
        __ro_after_init_end = .;
 
        BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -297,7 +298,6 @@ SECTIONS
   DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
   } PHDR(text)
 
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 5 lines · Andrew Cooper

This is a list of pointers which is only ever read.

In the ARM linker file, fix some adjacent misalignment.

Quoted 103 lines

---
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]>

---
 xen/arch/arm/xen.lds.S   | 6 +++---
 xen/arch/ppc/xen.lds.S   | 2 +-
 xen/arch/riscv/xen.lds.S | 2 +-
 xen/arch/x86/xen.lds.S   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/xen.lds.S +3 -3
index 613511390ff4..d1bb6c62d208 100644
@@ -51,9 +51,10 @@ SECTIONS
 
   . = ALIGN(PAGE_SIZE);
   .rodata : {
-        _srodata = .;          /* Read-only data */
+       _srodata = .;          /* Read-only data */
 
-        BUGFRAMES
+       BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -93,7 +94,6 @@ SECTIONS
   .data : {                    /* Data */
        *(.data.page_aligned)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
 
        *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -1
index 37256c8865a9..cddb70855307 100644
@@ -48,6 +48,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.rodata)
         *(.rodata.*)
@@ -84,7 +85,6 @@ SECTIONS
     DECL_SECTION(.data) {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -1
index d9375a961697..250ee3f36f4f 100644
@@ -43,6 +43,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.srodata)
         *(.srodata.*)
@@ -91,7 +92,6 @@ SECTIONS
     .data : {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.sdata .sdata.*)
xen/arch/x86/xen.lds.S +1 -1
index 8f943e11ead4..925848980219 100644
@@ -119,6 +119,7 @@ SECTIONS
        __ro_after_init_end = .;
 
        BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -297,7 +298,6 @@ SECTIONS
   DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
   } PHDR(text)
Signature · 1 line
WBR, Volodymyr
#2 lore raw
In reply to Andrew Cooper
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

~Michal

Quoted 108 lines

In the ARM linker file, fix some adjacent misalignment.

---
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]>

---
 xen/arch/arm/xen.lds.S   | 6 +++---
 xen/arch/ppc/xen.lds.S   | 2 +-
 xen/arch/riscv/xen.lds.S | 2 +-
 xen/arch/x86/xen.lds.S   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/xen.lds.S +3 -3
index 613511390ff4..d1bb6c62d208 100644
@@ -51,9 +51,10 @@ SECTIONS
 
   . = ALIGN(PAGE_SIZE);
   .rodata : {
-        _srodata = .;          /* Read-only data */
+       _srodata = .;          /* Read-only data */
 
-        BUGFRAMES
+       BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -93,7 +94,6 @@ SECTIONS
   .data : {                    /* Data */
        *(.data.page_aligned)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
 
        *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -1
index 37256c8865a9..cddb70855307 100644
@@ -48,6 +48,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.rodata)
         *(.rodata.*)
@@ -84,7 +85,6 @@ SECTIONS
     DECL_SECTION(.data) {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -1
index d9375a961697..250ee3f36f4f 100644
@@ -43,6 +43,7 @@ SECTIONS
         _srodata = .;          /* Read-only data */
 
         BUGFRAMES
+        SCHEDULER_ARRAY
 
         *(.srodata)
         *(.srodata.*)
@@ -91,7 +92,6 @@ SECTIONS
     .data : {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.sdata .sdata.*)
xen/arch/x86/xen.lds.S +1 -1
index 8f943e11ead4..925848980219 100644
@@ -119,6 +119,7 @@ SECTIONS
        __ro_after_init_end = .;
 
        BUGFRAMES
+       SCHEDULER_ARRAY
 
        *(.rodata)
        *(.rodata.*)
@@ -297,7 +298,6 @@ SECTIONS
   DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
 
-       SCHEDULER_ARRAY
        HYPFS_PARAM
   } PHDR(text)
 
#3 lore raw
Quoted 6 lines · Michal
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

The same happens a few lines below if the scheduler's global_init() fails.

Neither NULL assignment can trigger today (both global_init()
implementations return 0 and all in-tree schedulers provide the
hooks), but I think the writes need dropping first, and the entries want to become "const struct sched_ops *const" (both in REGISTER_SCHEDULER() and the __{start,end}_schedulers_array declarations) so the compiler enforces the property. It would also be nice to rename .data.schedulers to .rodata.schedulers while moving it.

The linker script placement itself looks fine to me.

~ Oleksii

Quoted 110 lines
Quoted 109 lines

In the ARM linker file, fix some adjacent misalignment.

---
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]>

---
  xen/arch/arm/xen.lds.S   | 6 +++---
  xen/arch/ppc/xen.lds.S   | 2 +-
  xen/arch/riscv/xen.lds.S | 2 +-
  xen/arch/x86/xen.lds.S   | 2 +-
  4 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/xen.lds.S +3 -3
index 613511390ff4..d1bb6c62d208 100644
@@ -51,9 +51,10 @@ SECTIONS
 
    . = ALIGN(PAGE_SIZE);
    .rodata : {
-        _srodata = .;          /* Read-only data */
+       _srodata = .;          /* Read-only data */
 
-        BUGFRAMES
+       BUGFRAMES
+       SCHEDULER_ARRAY
 
         *(.rodata)
         *(.rodata.*)
@@ -93,7 +94,6 @@ SECTIONS
    .data : {                    /* Data */
         *(.data.page_aligned)
 
-       SCHEDULER_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -1
index 37256c8865a9..cddb70855307 100644
@@ -48,6 +48,7 @@ SECTIONS
          _srodata = .;          /* Read-only data */
 
          BUGFRAMES
+        SCHEDULER_ARRAY
 
          *(.rodata)
          *(.rodata.*)
@@ -84,7 +85,6 @@ SECTIONS
      DECL_SECTION(.data) {                    /* Data */
          *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
          HYPFS_PARAM
 
          *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -1
index d9375a961697..250ee3f36f4f 100644
@@ -43,6 +43,7 @@ SECTIONS
          _srodata = .;          /* Read-only data */
 
          BUGFRAMES
+        SCHEDULER_ARRAY
 
          *(.srodata)
          *(.srodata.*)
@@ -91,7 +92,6 @@ SECTIONS
      .data : {                    /* Data */
          *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
          HYPFS_PARAM
 
          *(.sdata .sdata.*)
xen/arch/x86/xen.lds.S +1 -1
index 8f943e11ead4..925848980219 100644
@@ -119,6 +119,7 @@ SECTIONS
         __ro_after_init_end = .;
 
         BUGFRAMES
+       SCHEDULER_ARRAY
 
         *(.rodata)
         *(.rodata.*)
@@ -297,7 +298,6 @@ SECTIONS
    DECL_SECTION(.data.read_mostly) {
         *(.data.read_mostly)
 
-       SCHEDULER_ARRAY
         HYPFS_PARAM
    } PHDR(text)
 
#4 lore raw
In reply to Orzel, Michal
Quoted 5 lines · Michal
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

Lovely, sorry I misread the const on the name there.

sched_test_func() on the other hand can be delete.  We can force those checks at compiletime.

But, there's the global init case.  None of the current global init hooks do anything except return 0, but I suppose in principle that may want to stay.

I suppose I'll keep SCHEDULER_ARRAY in read_mostly for now.

~Andrew

#5 lore raw
Quoted 7 lines · Andrew Cooper
Quoted 5 lines · Michal
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

Quoted 8 lines

Lovely, sorry I misread the const on the name there.

sched_test_func() on the other hand can be delete.  We can force those checks at compiletime.

But, there's the global init case.  None of the current global init hooks do anything except return 0, but I suppose in principle that may want to stay.

This can easily be handled per-scheduler:

- make .global_init return void
- in case a global_init hook fails, let it set a static variable in the scheduler, resulting in any .init() call for that scheduler to fail

This will avoid any need to NULL a scheduler in the array (assuming sched_test_func() has been removed, too).

Juergen

#6 lore raw
Quoted 17 lines · Juergen Gross
Quoted 7 lines · Andrew Cooper
Quoted 5 lines · Michal
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

Quoted 8 lines

Lovely, sorry I misread the const on the name there.

sched_test_func() on the other hand can be delete.  We can force those checks at compiletime.

But, there's the global init case.  None of the current global init hooks do anything except return 0, but I suppose in principle that may want to stay.

Quoted 8 lines

This can easily be handled per-scheduler:

- make .global_init return void
- in case a global_init hook fails, let it set a static variable in the scheduler, resulting in any .init() call for that scheduler to fail

This will avoid any need to NULL a scheduler in the array (assuming sched_test_func() has been removed, too).

Thinking more about it: this scheme would even allow to drop the .global_init hook completely. If a scheduler needs that, call it from the .init hook the first time that is being called. As there are never concurrent calls of .init (only called either at boot for the default scheduler, or under cpupool_lock), there is no need for more than a simple per-scheduler variable telling that the global init function has been called and indicating a possible failure of it.

Juergen

#7 lore raw
In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper
Quoted 4 lines · Michal
Quoted 1 line · Andrew Cooper

This is a list of pointers which is only ever read.

I think that's not true. See sched_test_func() macro in scheduler_init() that assigns NULL in case the scheduler does not implement the required hook.

Lovely, sorry I misread the const on the name there.

Quoted 8 lines

sched_test_func() on the other hand can be delete.  We can force those checks at compiletime.

But, there's the global init case.  None of the current global init hooks do anything except return 0, but I suppose in principle that may want to stay.

I suppose I'll keep SCHEDULER_ARRAY in read_mostly for now.

Actually no.  They should be in ro_after_init.

~Andrew