[PATCH v2 2/2] xen/sched: rename scheduler registration symbols

Furkan Caliskan <[email protected]> Tue, 4 Aug 2026 08:53:27 +0300
Newsgroups gmane.comp.emulators.xen.devel
Message-ID <[email protected]>
REGISTER_SCHEDULER(), schedulers[], NUM_SCHEDULERS, and the
per-arch SCHEDULER_ARRAY linker macro now register and hold
struct sched_ops instances rather than struct scheduler ones,
but still carry names describing the old type.

Rename them to match the current behaviour.
No functional change.

Signed-off-by: Furkan Caliskan <[email protected]>
---
 xen/arch/arm/xen.lds.S      |  2 +-
 xen/arch/ppc/xen.lds.S      |  2 +-
 xen/arch/riscv/xen.lds.S    |  2 +-
 xen/arch/x86/xen.lds.S      |  2 +-
 xen/common/sched/arinc653.c |  2 +-
 xen/common/sched/core.c     | 33 +++++++++++++++++----------------
 xen/common/sched/credit.c   |  2 +-
 xen/common/sched/credit2.c  |  2 +-
 xen/common/sched/null.c     |  2 +-
 xen/common/sched/private.h  |  4 ++--
 xen/common/sched/rt.c       |  2 +-
 xen/include/xen/xen.lds.h   | 10 +++++-----
 12 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 2d5f1c516d..07bf875599 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -93,7 +93,7 @@ SECTIONS
   .data : {                    /* Data */
        *(.data.page_aligned)
 
-       SCHEDULER_ARRAY
+       SCHED_OPS_ARRAY
        HYPFS_PARAM
 
        *(.data .data.*)
diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
index d0f2ed43f1..1f4e200693 100644
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -84,7 +84,7 @@ SECTIONS
     DECL_SECTION(.data) {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
+        SCHED_OPS_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
index 65f136dce9..97f2db1dfd 100644
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -89,7 +89,7 @@ SECTIONS
     .data : {                    /* Data */
         *(.data.page_aligned)
 
-        SCHEDULER_ARRAY
+        SCHED_OPS_ARRAY
         HYPFS_PARAM
 
         *(.data .data.*)
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index b9e888e596..0f506ff1f6 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -306,7 +306,7 @@ SECTIONS
   DECL_SECTION(.data.read_mostly) {
        *(.data.read_mostly)
 
-       SCHEDULER_ARRAY
+       SCHED_OPS_ARRAY
        HYPFS_PARAM
   } PHDR(text)
 
diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c
index 746963806e..efcaa44089 100644
--- a/xen/common/sched/arinc653.c
+++ b/xen/common/sched/arinc653.c
@@ -736,7 +736,7 @@ static const struct sched_ops sched_arinc653_def = {
     .dump_cpu_state = NULL,
 };
 
-REGISTER_SCHEDULER(sched_arinc653_def);
+REGISTER_SCHED_OPS(sched_arinc653_def);
 
 /*
  * Local variables:
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 5cdae0415c..8e938a3810 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -87,9 +87,9 @@ DEFINE_PER_CPU(cpumask_t, cpumask_scratch);
 /* How many urgent vcpus. */
 DEFINE_PER_CPU(atomic_t, sched_urgent_count);
 
-extern const struct sched_ops *__start_schedulers_array[], *__end_schedulers_array[];
-#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array)
-#define schedulers __start_schedulers_array
+extern const struct sched_ops *__start_sched_ops_array[], *__end_sched_ops_array[];
+#define NUM_SCHED_OPS (__end_sched_ops_array - __start_sched_ops_array)
+#define sched_ops_array __start_sched_ops_array
 
 static struct scheduler __read_mostly operations;
 
@@ -2996,9 +2996,9 @@ static inline
 const struct sched_ops *__init sched_ops_get_by_name(const char* sched_name)
 {
     unsigned int i;
-    for ( i = 0; i < NUM_SCHEDULERS; i++ )
-        if ( schedulers[i] && !strcmp(schedulers[i]->opt_name, sched_name) )
-            return schedulers[i];
+    for ( i = 0; i < NUM_SCHED_OPS; i++ )
+        if ( sched_ops_array[i] && !strcmp(sched_ops_array[i]->opt_name, sched_name) )
+            return sched_ops_array[i];
 
     return NULL;
 }
@@ -3018,14 +3018,14 @@ void __init scheduler_init(void)
 
     scheduler_enable();
 
-    for ( i = 0; i < NUM_SCHEDULERS; i++)
+    for ( i = 0; i < NUM_SCHED_OPS; i++)
     {
 #define sched_test_func(f)                               \
-        if ( !schedulers[i]->f )                         \
+        if ( !sched_ops_array[i]->f )                    \
         {                                                \
             printk("scheduler %s misses .%s, dropped\n", \
-                   schedulers[i]->opt_name, #f);         \
-            schedulers[i] = NULL;                        \
+                   sched_ops_array[i]->opt_name, #f);    \
+            sched_ops_array[i] = NULL;                   \
         }
 
         sched_test_func(init);
@@ -3038,11 +3038,12 @@ void __init scheduler_init(void)
 
 #undef sched_test_func
 
-        if ( schedulers[i]->global_init && schedulers[i]->global_init() < 0 )
+        if ( sched_ops_array[i]->global_init &&
+             sched_ops_array[i]->global_init() < 0 )
         {
             printk("scheduler %s failed initialization, dropped\n",
-                   schedulers[i]->opt_name);
-            schedulers[i] = NULL;
+                   sched_ops_array[i]->opt_name);
+            sched_ops_array[i] = NULL;
         }
     }
 
@@ -3412,8 +3413,8 @@ struct scheduler *scheduler_alloc(unsigned int sched_id)
     int ret;
     struct scheduler *sched;
 
-    for ( i = 0; i < NUM_SCHEDULERS; i++ )
-        if ( schedulers[i] && schedulers[i]->sched_id == sched_id )
+    for ( i = 0; i < NUM_SCHED_OPS; i++ )
+        if ( sched_ops_array[i] && sched_ops_array[i]->sched_id == sched_id )
             goto found;
 
     return ERR_PTR(-ENOENT);
@@ -3421,7 +3422,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id)
  found:
     if ( (sched = xzalloc(struct scheduler)) == NULL )
         return ERR_PTR(-ENOMEM);
-    sched->ops = schedulers[i];
+    sched->ops = sched_ops_array[i];
 
     if ( (ret = sched_init(sched)) != 0 )
     {
diff --git a/xen/common/sched/credit.c b/xen/common/sched/credit.c
index 8df746bf6b..995cf097b5 100644
--- a/xen/common/sched/credit.c
+++ b/xen/common/sched/credit.c
@@ -2315,4 +2315,4 @@ static const struct sched_ops sched_credit_def = {
     .move_timers    = csched_move_timers,
 };
 
-REGISTER_SCHEDULER(sched_credit_def);
+REGISTER_SCHED_OPS(sched_credit_def);
diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c
index 4949606881..9bcc90004a 100644
--- a/xen/common/sched/credit2.c
+++ b/xen/common/sched/credit2.c
@@ -4268,4 +4268,4 @@ static const struct sched_ops sched_credit2_def = {
     .free_domdata   = csched2_free_domdata,
 };
 
-REGISTER_SCHEDULER(sched_credit2_def);
+REGISTER_SCHED_OPS(sched_credit2_def);
diff --git a/xen/common/sched/null.c b/xen/common/sched/null.c
index b3c6651fb1..5194c8216c 100644
--- a/xen/common/sched/null.c
+++ b/xen/common/sched/null.c
@@ -1067,4 +1067,4 @@ static const struct sched_ops sched_null_def = {
     .dump_settings  = null_dump,
 };
 
-REGISTER_SCHEDULER(sched_null_def);
+REGISTER_SCHED_OPS(sched_null_def);
diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h
index 0c5181891c..c03063befe 100644
--- a/xen/common/sched/private.h
+++ b/xen/common/sched/private.h
@@ -547,8 +547,8 @@ static inline void sched_unit_unpause(const struct sched_unit *unit)
         vcpu_unpause(v);
 }
 
-#define REGISTER_SCHEDULER(x) static const struct sched_ops *x##_entry \
-  __used_section(".data.schedulers") = &(x)
+#define REGISTER_SCHED_OPS(x) static const struct sched_ops *x##_entry \
+  __used_section(".data.sched_ops") = &(x)
 
 struct cpupool
 {
diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c
index 0e9f04ea72..8b4f05e2d1 100644
--- a/xen/common/sched/rt.c
+++ b/xen/common/sched/rt.c
@@ -1645,4 +1645,4 @@ static const struct sched_ops sched_rtds_def = {
     .move_timers    = rt_move_timers,
 };
 
-REGISTER_SCHEDULER(sched_rtds_def);
+REGISTER_SCHED_OPS(sched_rtds_def);
diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index ea11e3fb62..fc44d28734 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -173,11 +173,11 @@
        _edevice = .;        \
   } :text
 
-#define SCHEDULER_ARRAY              \
-       . = ALIGN(POINTER_ALIGN);     \
-       __start_schedulers_array = .; \
-       *(.data.schedulers)           \
-       __end_schedulers_array = .;
+#define SCHED_OPS_ARRAY             \
+       . = ALIGN(POINTER_ALIGN);    \
+       __start_sched_ops_array = .; \
+       *(.data.sched_ops)           \
+       __end_sched_ops_array = .;
 
 #ifdef CONFIG_HYPFS
 #define HYPFS_PARAM              \
-- 
2.34.1