xen/sched: split scheduler vtable from scheduler
cover xen/sched: split scheduler vtable from scheduler
Each struct scheduler currently doubles as both a scheduler backend's static vtable (name, opt_name, sched_id and every function pointer) and the per-cpupool runtime object that scheduler_alloc() allocates. Because these are the same type, scheduler_alloc() memcpy()s the entire vtable into a fresh heap allocation for every cpupool it creates. With N cpupools running the same scheduler, this duplicates N copies of identical function pointers and identifying fields that never differ between instances - the only fields that are genuinely per-cpupool are sched_data and cpupool.
This series splits the vtable out into its own type, struct sched_ops, so it can be shared by every cpupool using a given scheduler instead of copied per cpupool. struct scheduler is left holding only what is actually per-instance: a pointer to the shared sched_ops, plus sched_data and cpupool.
The series is structured as introduce/migrate/remove, so that every commit builds and boots on its own:
- The first patch adds struct sched_ops, REGISTER_SCHED_OPS(), and a sched_ops_array[] alongside the existing schedulers[], extending every lookup path (scheduler_alloc(), sched_get_by_name(), scheduler_init()) to search both arrays. This is purely additive - no scheduler uses it yet.
- The next five patches each migrate one scheduler backend (credit, credit2, rtds, arinc653, null) from struct scheduler to struct sched_ops. Each is small, mechanical, and independently bisectable, with no behavioral difference, since scheduler_alloc() builds an identical runtime struct scheduler regardless of which array a match is found in.
- The final patch removes the old schedulers[] and REGISTER_SCHEDULER() path now that nothing uses it, shrinks struct scheduler down to { ops, sched_data, cpupool }, and updates every accessor in private.h accordingly.
Furkan Caliskan (7):
xen/sched: introduce struct sched_ops as a shared scheduler vtable xen/sched: credit: migrate to new sched_ops
xen/sched: credit2: migrate to new sched_ops
xen/sched: rtds: migrate to new sched_ops
xen/sched: arinc653: migrate to new sched_ops
xen/sched: null: migrate to new sched_ops
xen/sched: remove old scheduler registration, shrink struct scheduler
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 | 11 +--- xen/common/sched/core.c | 80 ++++++++++++++++------------- xen/common/sched/cpupool.c | 6 +-- xen/common/sched/credit.c | 5 +- xen/common/sched/credit2.c | 5 +- xen/common/sched/null.c | 5 +- xen/common/sched/private.h | 100 +++++++++++++++++++----------------- xen/common/sched/rt.c | 5 +- xen/include/xen/xen.lds.h | 8 +-- 13 files changed, 116 insertions(+), 117 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/7 xen/sched: introduce struct sched_ops as a shared scheduler vtable
struct scheduler currently serves two purposes: it is the static vtable a scheduler backend defines (name, opt_name, sched_id, and all its function pointers), and it is also the per-cpupool runtime object scheduler_alloc() allocates. Being the same type forces scheduler_alloc() to memcpy() the whole vtable into a fresh allocation per cpupool, duplicating identical function pointers across every cpupool using the same scheduler.
Introduce struct sched_ops to hold just the compile-time-constant identity and dispatch table, with no per-cpupool state, plus REGISTER_SCHED_OPS() and a sched_ops_array[] alongside the existing schedulers[]. scheduler_alloc(), sched_get_by_name(), and scheduler_init() are extended to also search sched_ops_array[], using a new sched_ops_to_scheduler() helper to build an identical flat struct scheduler regardless of which array a match came from.
struct scheduler itself is left untouched for now and still duplicates every field sched_ops holds - this commit only lays the groundwork. Once every backend registers through sched_ops, struct scheduler will be shrunk to its genuinely per-cpupool fields (a pointer to a shared sched_ops instance, plus instance data), and the flattening copy, schedulers[], and REGISTER_SCHEDULER() will be removed. That is what actually removes the duplication; this commit does not yet change any behavior, since sched_ops_array[] is still empty.
--- xen/arch/arm/xen.lds.S | 1 + xen/arch/ppc/xen.lds.S | 1 + xen/arch/riscv/xen.lds.S | 1 + xen/arch/x86/xen.lds.S | 1 + xen/common/sched/core.c | 118 +++++++++++++++++++++++++++++++++++-- xen/common/sched/private.h | 73 +++++++++++++++++++++++ xen/include/xen/xen.lds.h | 6 ++ 7 files changed, 196 insertions(+), 5 deletions(-)
xen/arch/arm/xen.lds.S +1 -0
@@ -94,6 +94,7 @@ SECTIONS *(.data.page_aligned) SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -0
@@ -85,6 +85,7 @@ SECTIONS *(.data.page_aligned) SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -0
@@ -90,6 +90,7 @@ SECTIONS *(.data.page_aligned) SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/x86/xen.lds.S +1 -0
@@ -307,6 +307,7 @@ SECTIONS *(.data.read_mostly) SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM } PHDR(text)
xen/common/sched/core.c +113 -5
169 lines not on this page · raw message
xen/common/sched/private.h +73 -0
85 lines not on this page · raw message
xen/include/xen/xen.lds.h +6 -0
@@ -179,6 +179,12 @@ *(.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 \ . = ALIGN(POINTER_ALIGN); \
Signature · 1 line
2.34.1
PATCH 2/7 xen/sched: credit: migrate to new sched_ops
In reply to Furkan CaliskanDeclare sched_credit_def as a struct sched_ops instead of a struct scheduler, dropping the .sched_data field, and register it with REGISTER_SCHED_OPS() so it is found through sched_ops_array[] instead of schedulers[].
This moves the credit scheduler onto the new sched_ops registration path.
--- xen/common/sched/credit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/common/sched/credit.c +2 -3
@@ -2273,11 +2273,10 @@ csched_deinit(struct scheduler *ops) } } -static const struct scheduler sched_credit_def = { +static const struct sched_ops sched_credit_def = { .name ="SMP Credit Scheduler" , .opt_name ="credit" , .sched_id =XEN_SCHEDULER_CREDIT , - .sched_data =NULL , .global_init = csched_global_init,
@@ -2312,4 +2311,4 @@ static const struct scheduler sched_credit_def = { .move_timers = csched_move_timers, }; -REGISTER_SCHEDULER (sched_credit_def); +REGISTER_SCHED_OPS (sched_credit_def);
Signature · 1 line
2.34.1
PATCH 3/7 xen/sched: credit2: migrate to new sched_ops
In reply to Furkan CaliskanDeclare sched_credit2_def as a struct sched_ops instead of a struct scheduler, dropping the .sched_data field, and register it with REGISTER_SCHED_OPS() so it is found through sched_ops_array[] instead of schedulers[].
This moves the credit2 scheduler onto the new sched_ops registration path.
--- xen/common/sched/credit2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/common/sched/credit2.c +2 -3
@@ -4230,11 +4230,10 @@ csched2_deinit(struct scheduler *ops)xfree (prv); } -static const struct scheduler sched_credit2_def = { +static const struct sched_ops sched_credit2_def = { .name ="SMP Credit Scheduler rev2" , .opt_name ="credit2" , .sched_id =XEN_SCHEDULER_CREDIT2 , - .sched_data =NULL , .global_init = csched2_global_init,
@@ -4269,4 +4268,4 @@ static const struct scheduler sched_credit2_def = { .free_domdata = csched2_free_domdata, }; -REGISTER_SCHEDULER (sched_credit2_def); +REGISTER_SCHED_OPS (sched_credit2_def);
Signature · 1 line
2.34.1
PATCH 4/7 xen/sched: rtds: migrate to new sched_ops
In reply to Furkan CaliskanDeclare sched_rtds_def as a struct sched_ops instead of a struct scheduler, dropping the .sched_data field, and register it with REGISTER_SCHED_OPS() so it is found through sched_ops_array[] instead of schedulers[].
This moves the rtds scheduler onto the new sched_ops registration path.
--- xen/common/sched/rt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/common/sched/rt.c +2 -3
@@ -1617,11 +1617,10 @@ static void cf_check repl_timer_handler(void *data)spin_unlock_irq (&prv->lock); } -static const struct scheduler sched_rtds_def = { +static const struct sched_ops sched_rtds_def = { .name ="SMP RTDS Scheduler" , .opt_name ="rtds" , .sched_id =XEN_SCHEDULER_RTDS , - .sched_data =NULL , .dump_cpu_state = rt_dump_pcpu, .dump_settings = rt_dump,
@@ -1646,4 +1645,4 @@ static const struct scheduler sched_rtds_def = { .move_timers = rt_move_timers, }; -REGISTER_SCHEDULER (sched_rtds_def); +REGISTER_SCHED_OPS (sched_rtds_def);
Signature · 1 line
2.34.1
PATCH 5/7 xen/sched: arinc653: migrate to new sched_ops
In reply to Furkan CaliskanDeclare sched_arinc653_def as a struct sched_ops instead of a struct scheduler, dropping the .sched_data field, and register it with REGISTER_SCHED_OPS() so it is found through sched_ops_array[] instead of schedulers[].
This moves the arinc653 scheduler onto the new sched_ops registration path.
--- xen/common/sched/arinc653.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
xen/common/sched/arinc653.c +2 -9
@@ -702,17 +702,10 @@ a653sched_adjust_global(const struct scheduler *ops, }#endif /* CONFIG_SYSCTL */ -/** -* This structure defines our scheduler for Xen. -* The entries tell Xen where to find our scheduler-specific -* callback functions. -* The symbol must be visible to the rest of Xen at link time. -*/ -static const struct scheduler sched_arinc653_def = { +static const struct sched_ops sched_arinc653_def = { .name ="ARINC 653 Scheduler" , .opt_name ="arinc653" , .sched_id =XEN_SCHEDULER_ARINC653 , - .sched_data =NULL , .init = a653sched_init, .deinit = a653sched_deinit,
@@ -743,7 +736,7 @@ static const struct scheduler sched_arinc653_def = { .dump_cpu_state = NULL, }; -REGISTER_SCHEDULER (sched_arinc653_def); +REGISTER_SCHED_OPS (sched_arinc653_def);/* * Local variables:
Signature · 1 line
2.34.1
PATCH 6/7 xen/sched: null: migrate to new sched_ops
In reply to Furkan CaliskanDeclare sched_null_def as a struct sched_ops instead of a struct scheduler, dropping the .sched_data field, and register it with REGISTER_SCHED_OPS() so it is found through sched_ops_array[] instead of schedulers[].
This moves the null scheduler onto the new sched_ops registration path.
--- xen/common/sched/null.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/common/sched/null.c +2 -3
@@ -1037,11 +1037,10 @@ static void cf_check null_dump(const struct scheduler *ops)spin_unlock_irqrestore (&prv->lock, flags); } -static const struct scheduler sched_null_def = { +static const struct sched_ops sched_null_def = { .name ="null Scheduler" , .opt_name ="null" , .sched_id =XEN_SCHEDULER_NULL , - .sched_data =NULL , .init = null_init, .deinit = null_deinit,
@@ -1068,4 +1067,4 @@ static const struct scheduler sched_null_def = { .dump_settings = null_dump, }; -REGISTER_SCHEDULER (sched_null_def); +REGISTER_SCHED_OPS (sched_null_def);
Signature · 1 line
2.34.1
PATCH 7/7 xen/sched: remove old scheduler registration, shrink struct scheduler
In reply to Furkan CaliskanEvery in-tree scheduler now registers through sched_ops instead of the original struct-scheduler-as-vtable path, so schedulers[], REGISTER_SCHEDULER() and NUM_SCHEDULERS have no remaining users. Remove them and finish the change struct sched_ops was introduced
for: struct scheduler is shrunk down to just its per-cpupool fields - a pointer to a shared sched_ops, plus sched_data and cpupool.
scheduler_alloc() now stores a pointer to the matching sched_ops instance instead of copying every field into a fresh allocation. Cpupools sharing a scheduler type now share one dispatch table instead of each holding a private copy of it.
Every accessor in private.h is updated from s->field to s->ops->field to match. sched_idle_ops is split the same way every other scheduler was.
A handful of call sites elsewhere read a scheduler's name, opt_name or sched_id directly and are updated to go through ->ops as well.
--- xen/arch/arm/xen.lds.S | 1 - xen/arch/ppc/xen.lds.S | 1 - xen/arch/riscv/xen.lds.S | 1 - xen/arch/x86/xen.lds.S | 1 - xen/common/sched/core.c | 144 +++++----------------------------- xen/common/sched/cpupool.c | 6 +- xen/common/sched/private.h | 155 ++++++++++--------------------------- xen/include/xen/xen.lds.h | 6 -- 8 files changed, 67 insertions(+), 248 deletions(-)
xen/arch/arm/xen.lds.S +0 -1
@@ -93,7 +93,6 @@ SECTIONS .data : { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY SCHED_OPS_ARRAY HYPFS_PARAM
xen/arch/ppc/xen.lds.S +0 -1
@@ -84,7 +84,6 @@ SECTIONS DECL_SECTION(.data) { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY SCHED_OPS_ARRAY HYPFS_PARAM
xen/arch/riscv/xen.lds.S +0 -1
@@ -89,7 +89,6 @@ SECTIONS .data : { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY SCHED_OPS_ARRAY HYPFS_PARAM
xen/arch/x86/xen.lds.S +0 -1
@@ -306,7 +306,6 @@ SECTIONS DECL_SECTION(.data.read_mostly) { *(.data.read_mostly) - SCHEDULER_ARRAY SCHED_OPS_ARRAY HYPFS_PARAM } PHDR(text)
xen/common/sched/core.c +21 -123
253 lines not on this page · raw message
xen/common/sched/cpupool.c +3 -3
@@ -338,7 +338,7 @@ static struct cpupool *cpupool_create(unsigned int poolid,spin_unlock (&cpupool_lock);debugtrace_printk ("Created cpupool %u with scheduler %s (%s)\n" , - c->cpupool_id, c->sched->name, c->sched->opt_name); + c->cpupool_id, c->sched->ops->name, c->sched->ops->opt_name);return c;
@@ -862,7 +862,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)if ( c ==NULL )break ; op->cpupool_id = c->cpupool_id; - op->sched_id = c->sched->sched_id; + op->sched_id = c->sched->ops->sched_id; op->n_dom = c->n_dom; ret =cpumask_to_xenctl_bitmap (&op->cpumap, c->cpu_valid);cpupool_put (c);
@@ -1294,7 +1294,7 @@ struct cpupool *__init cpupool_create_pool(unsigned int pool_id, int sched_id)struct cpupool *pool;if ( sched_id <0 ) - sched_id =scheduler_get_default ()->sched_id; + sched_id =scheduler_get_default ()->ops->sched_id; pool =cpupool_create (pool_id, sched_id);
xen/common/sched/private.h +43 -112
286 lines not on this page · raw message
xen/include/xen/xen.lds.h +0 -6
@@ -173,12 +173,6 @@ _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 = .; \
Signature · 1 line
2.34.1
Quoted 47 lines · Furkan Caliskan
Each struct scheduler currently doubles as both a scheduler backend's static vtable (name,
opt_name,sched_idand every function pointer) and the per-cpupool runtime object thatscheduler_alloc()allocates. Because these are the same type,scheduler_alloc()memcpy()s the entire vtable into a fresh heap allocation for every cpupool it creates. With N cpupools running the same scheduler, this duplicates N copies of identical function pointers and identifying fields that never differ between instances - the only fields that are genuinely per-cpupool aresched_dataand cpupool.This series splits the vtable out into its own type, struct
sched_ops, so it can be shared by every cpupool using a given scheduler instead of copied per cpupool. struct scheduler is left holding only what is actually per-instance: a pointer to the sharedsched_ops, plussched_dataand cpupool.The series is structured as introduce/migrate/remove, so that every commit builds and boots on its own:
- The first patch adds struct
sched_ops,REGISTER_SCHED_OPS(), and a sched_ops_array[] alongside the existing schedulers[], extending every lookup path (scheduler_alloc(),sched_get_by_name(),scheduler_init()) to search both arrays. This is purely additive - no scheduler uses it yet.- The next five patches each migrate one scheduler backend (credit, credit2, rtds, arinc653, null) from struct scheduler to struct
sched_ops. Each is small, mechanical, and independently bisectable, with no behavioral difference, sincescheduler_alloc()builds an identical runtime struct scheduler regardless of which array a match is found in.- The final patch removes the old schedulers[] and
REGISTER_SCHEDULER()path now that nothing uses it, shrinks struct scheduler down to { ops,sched_data, cpupool }, and updates every accessor inprivate.haccordingly.Furkan Caliskan (7):
xen/sched: introduce structsched_opsas a shared scheduler vtable xen/sched: credit: migrate to newsched_ops
xen/sched: credit2: migrate to newsched_ops
xen/sched: rtds: migrate to newsched_ops
xen/sched: arinc653: migrate to newsched_ops
xen/sched: null: migrate to newsched_ops
xen/sched: remove old scheduler registration, shrink struct scheduler
Quoted 15 lines
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 | 11 +--- xen/common/sched/core.c | 80 ++++++++++++++++------------- xen/common/sched/cpupool.c | 6 +-- xen/common/sched/credit.c | 5 +- xen/common/sched/credit2.c | 5 +- xen/common/sched/null.c | 5 +- xen/common/sched/private.h | 100 +++++++++++++++++++----------------- xen/common/sched/rt.c | 5 +- xen/include/xen/xen.lds.h | 8 +-- 13 files changed, 116 insertions(+), 117 deletions(-)
You have a series here which is adding 116 lines and removing 117.
Patch 7 alone is removing 248 lines while adding 67 lines.
So in the end there is a single patch in this series which has more code churn than the complete series when added in one go.
IOW: making this just a single patch would be easier to review than the last patch alone, let alone all the temporary modifications which would be gone when merging all patches into one. And with that you could even drop some of the renaming you did (e.g. in the linker file), making the diff even smaller.
I agree with the overall goal, but I'm sparing my time doing a thorough review of the series in this shape.
Juergen
Hi Jürgen,
Quoted 77 lines · Jürgen Groß
Quoted 60 lines · Furkan Caliskan
Each struct scheduler currently doubles as both a scheduler backend's static vtable (name,
opt_name,sched_idand every function pointer) and the per-cpupool runtime object thatscheduler_alloc()allocates. Because these are the same type,scheduler_alloc()memcpy()s the entire vtable into a fresh heap allocation for every cpupool it creates. With N cpupools running the same scheduler, this duplicates N copies of identical function pointers and identifying fields that never differ between instances - the only fields that are genuinely per-cpupool aresched_dataand cpupool.This series splits the vtable out into its own type, struct
sched_ops, so it can be shared by every cpupool using a given scheduler instead of copied per cpupool. struct scheduler is left holding only what is actually per-instance: a pointer to the sharedsched_ops, plussched_dataand cpupool.The series is structured as introduce/migrate/remove, so that every commit builds and boots on its own:
- The first patch adds struct
sched_ops,REGISTER_SCHED_OPS(), and a sched_ops_array[] alongside the existing schedulers[], extending every lookup path (scheduler_alloc(),sched_get_by_name(),scheduler_init()) to search both arrays. This is purely additive - no scheduler uses it yet.- The next five patches each migrate one scheduler backend (credit, credit2, rtds, arinc653, null) from struct scheduler to struct
sched_ops. Each is small, mechanical, and independently bisectable, with no behavioral difference, sincescheduler_alloc()builds an identical runtime struct scheduler regardless of which array a match is found in.- The final patch removes the old schedulers[] and
REGISTER_SCHEDULER()path now that nothing uses it, shrinks struct scheduler down to { ops,sched_data, cpupool }, and updates every accessor inprivate.haccordingly.Furkan Caliskan (7):
xen/sched: introduce structsched_opsas a shared scheduler vtable xen/sched: credit: migrate to newsched_ops
xen/sched: credit2: migrate to newsched_ops
xen/sched: rtds: migrate to newsched_ops
xen/sched: arinc653: migrate to newsched_ops
xen/sched: null: migrate to newsched_ops
xen/sched: remove old scheduler registration, shrink struct schedulerxen/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| 11 +--- xen/common/sched/core.c | 80 ++++++++++++++++------------- xen/common/sched/cpupool.c | 6 +-- xen/common/sched/credit.c | 5 +- xen/common/sched/credit2.c | 5 +- xen/common/sched/null.c | 5 +- xen/common/sched/private.h | 100 +++++++++++++++++++----------------- xen/common/sched/rt.c | 5 +- xen/include/xen/xen.lds.h | 8 +--Quoted 2 lines
13 files changed, 116 insertions(+), 117 deletions(-)You have a series here which is adding 116 lines and removing 117.
Patch 7 alone is removing 248 lines while adding 67 lines.
So in the end there is a single patch in this series which has more code churn than the complete series when added in one go.
IOW: making this just a single patch would be easier to review than the last patch alone, let alone all the temporary modifications which would be gone when merging all patches into one. And with that you could even drop some of the renaming you did (e.g. in the linker file), making the diff even smaller.
Quoted 5 lines
I agree with the overall goal, but I'm sparing my time doing a thorough review of the series in this shape.
Juergen
My first instinct was actually to just send this as one patch. I split it up because I wanted each scheduler's conversion to be its own small, bisectable commit, but you're right that it's not worth it here.
I will squash it into a single patch and resend. But I would still like to rename SCHEDULER_ARRAY to SCHED_OPS_ARRAY in the per-arch linker files and other related variable names in other files, since they now hold sched_ops entries rather than struct scheduler ones, and I think the name should reflect that.
Thanks for the feedback,
Furkan Caliskan
Quoted 90 lines · Furkan Çalışkan
Hi Jürgen,
Quoted 77 lines · Jürgen Groß
Quoted 47 lines · Furkan Caliskan
Each struct scheduler currently doubles as both a scheduler backend's static vtable (name,
opt_name,sched_idand every function pointer) and the per-cpupool runtime object thatscheduler_alloc()allocates. Because these are the same type,scheduler_alloc()memcpy()s the entire vtable into a fresh heap allocation for every cpupool it creates. With N cpupools running the same scheduler, this duplicates N copies of identical function pointers and identifying fields that never differ between instances - the only fields that are genuinely per-cpupool aresched_dataand cpupool.This series splits the vtable out into its own type, struct
sched_ops, so it can be shared by every cpupool using a given scheduler instead of copied per cpupool. struct scheduler is left holding only what is actually per-instance: a pointer to the sharedsched_ops, plussched_dataand cpupool.The series is structured as introduce/migrate/remove, so that every commit builds and boots on its own:
- The first patch adds struct
sched_ops,REGISTER_SCHED_OPS(), and a sched_ops_array[] alongside the existing schedulers[], extending every lookup path (scheduler_alloc(),sched_get_by_name(),scheduler_init()) to search both arrays. This is purely additive - no scheduler uses it yet.- The next five patches each migrate one scheduler backend (credit, credit2, rtds, arinc653, null) from struct scheduler to struct
sched_ops. Each is small, mechanical, and independently bisectable, with no behavioral difference, sincescheduler_alloc()builds an identical runtime struct scheduler regardless of which array a match is found in.- The final patch removes the old schedulers[] and
REGISTER_SCHEDULER()path now that nothing uses it, shrinks struct scheduler down to { ops,sched_data, cpupool }, and updates every accessor inprivate.haccordingly.Furkan Caliskan (7):
xen/sched: introduce structsched_opsas a shared scheduler vtable xen/sched: credit: migrate to newsched_ops
xen/sched: credit2: migrate to newsched_ops
xen/sched: rtds: migrate to newsched_ops
xen/sched: arinc653: migrate to newsched_ops
xen/sched: null: migrate to newsched_ops
xen/sched: remove old scheduler registration, shrink struct schedulerQuoted 15 lines
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 | 11 +--- xen/common/sched/core.c | 80 ++++++++++++++++------------- xen/common/sched/cpupool.c | 6 +-- xen/common/sched/credit.c | 5 +- xen/common/sched/credit2.c | 5 +- xen/common/sched/null.c | 5 +- xen/common/sched/private.h | 100 +++++++++++++++++++----------------- xen/common/sched/rt.c | 5 +- xen/include/xen/xen.lds.h | 8 +-- 13 files changed, 116 insertions(+), 117 deletions(-)You have a series here which is adding 116 lines and removing 117.
Patch 7 alone is removing 248 lines while adding 67 lines.
So in the end there is a single patch in this series which has more code churn than the complete series when added in one go.
IOW: making this just a single patch would be easier to review than the last patch alone, let alone all the temporary modifications which would be gone when merging all patches into one. And with that you could even drop some of the renaming you did (e.g. in the linker file), making the diff even smaller.
Quoted 5 lines
I agree with the overall goal, but I'm sparing my time doing a thorough review of the series in this shape.
Juergen
My first instinct was actually to just send this as one patch. I split it up because I wanted each scheduler's conversion to be its own small, bisectable commit, but you're right that it's not worth it here.
Quoted 5 lines
I will squash it into a single patch and resend. But I would still like to rename
SCHEDULER_ARRAYtoSCHED_OPS_ARRAYin the per-arch linker files and other related variable names in other files, since they now holdsched_opsentries rather than struct scheduler ones, and I think the name should reflect that.
Now THIS could be done in a separate patch.
Juergen