xen/sched: split scheduler vtable from scheduler
v2 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.
Patch 1 contains the whole functional change: struct sched_ops is introduced, every in-tree scheduler backend is converted to it, and struct scheduler is shrunk accordingly.
Patch 2 is a pure rename of the symbols to match the new sched_ops.
v2: folded the previous 7-patch series into two patches.
Furkan Caliskan (2):
xen/sched: split scheduler vtable from struct scheduler xen/sched: rename scheduler registration symbols
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 | 81 ++++++++++++++++------------- xen/common/sched/cpupool.c | 7 +-- 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 | 10 ++-- 13 files changed, 119 insertions(+), 118 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 xen/sched: split scheduler vtable from struct scheduler
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.
Split 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. scheduler_alloc() now stores a pointer to the matching sched_ops instance instead of copying its fields, and every accessor in private.h is updated from s->field to s->ops->field to match.
Every in-tree scheduler backend (credit, credit2, rtds, arinc653, null) is converted from struct scheduler to struct sched_ops.
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/common/sched/arinc653.c | 9 +--- xen/common/sched/core.c | 52 +++++++++++--------- xen/common/sched/cpupool.c | 7 +-- xen/common/sched/credit.c | 3 +- xen/common/sched/credit2.c | 3 +- xen/common/sched/null.c | 3 +- xen/common/sched/private.h | 98 +++++++++++++++++++------------------ xen/common/sched/rt.c | 3 +- 8 files changed, 89 insertions(+), 89 deletions(-)
xen/common/sched/arinc653.c +1 -8
@@ -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,
xen/common/sched/core.c +29 -23
146 lines not on this page · raw message
xen/common/sched/cpupool.c +4 -3
@@ -338,7 +338,8 @@ 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 +863,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 +1295,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/credit.c +1 -2
@@ -2277,11 +2277,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,
xen/common/sched/credit2.c +1 -2
@@ -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,
xen/common/sched/null.c +1 -2
@@ -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,
xen/common/sched/private.h +51 -47
233 lines not on this page · raw message
xen/common/sched/rt.c +1 -2
@@ -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,
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] xen/sched: split scheduler vtable from struct scheduler
Quoted 17 lines · Furkan Caliskan
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 objectscheduler_alloc()allocates. Being the same type forcesscheduler_alloc()tomemcpy()the whole vtable into a fresh allocation per cpupool, duplicating identical function pointers across every cpupool using the same scheduler.Split 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.scheduler_alloc()now stores a pointer to the matchingsched_opsinstance instead of copying its fields, and every accessor inprivate.his updated froms->fieldtos->ops->fieldto match.
Quoted 8 lines
Every in-tree scheduler backend (credit, credit2, rtds, arinc653, null) is converted from struct scheduler to struct
sched_ops.A handful of call sites elsewhere read a scheduler's name,
opt_nameorsched_iddirectly and are updated to go through ->ops as well.Signed-off-by Furkan Caliskan <[email protected]>
Juergen
Re: [PATCH v2 1/2] xen/sched: split scheduler vtable from struct scheduler
In reply to Furkan CaliskanQuoted 41 lines · Furkan Caliskan
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 objectscheduler_alloc()allocates. Being the same type forcesscheduler_alloc()tomemcpy()the whole vtable into a fresh allocation per cpupool, duplicating identical function pointers across every cpupool using the same scheduler.Split 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.scheduler_alloc()now stores a pointer to the matchingsched_opsinstance instead of copying its fields, and every accessor inprivate.his updated froms->fieldtos->ops->fieldto match.Every in-tree scheduler backend (credit, credit2, rtds, arinc653, null) is converted from struct scheduler to struct
sched_ops.A handful of call sites elsewhere read a scheduler's name,
opt_nameorsched_iddirectly and are updated to go through ->ops as well.Signed-off-by Furkan Caliskan <[email protected]>--- xen/common/sched/arinc653.c | 9 +--- xen/common/sched/core.c | 52 +++++++++++--------- xen/common/sched/cpupool.c | 7 +-- xen/common/sched/credit.c | 3 +- xen/common/sched/credit2.c | 3 +- xen/common/sched/null.c | 3 +- xen/common/sched/private.h | 98 +++++++++++++++++++------------------ xen/common/sched/rt.c | 3 +- 8 files changed, 89 insertions(+), 89 deletions(-)xen/common/sched/arinc653.c +0
-0
xen/common/sched/arinc653.c a653sched_adjust_global(const struct scheduler *ops, · line 710
Quoted 9 lines
xen/common/sched/arinc653.c +0
-6@@ -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. -*/
The removal of the comment about symbol visibility is a definite improvement, and I'm okay with the overall comment removal. However, next time I'd prefer this to be mentioned in the commit message.
For now, I don't want to delay this any further, so for ARINC 653:
I will still give some additional remarks below, but I don't consider them blocking since they are nit/cosmetic and Juergen already gave his R-b.
Quoted 83 lines
xen/common/sched/arinc653.c +1
-2-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,xen/common/sched/core.c +11
-7@@ -87,7 +87,7 @@ DEFINE_PER_CPU(cpumask_t, cpumask_scratch);/* How many urgent vcpus. */ DEFINE_PER_CPU (atomic_t, sched_urgent_count); -extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; +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@@ -127,10 +127,9 @@ static void cf_check sched_idle_schedule( unit->next_task =sched_idle_unit (cpu); } -static struct scheduler sched_idle_ops = { +static struct sched_ops sched_idle_sched_ops = { .name ="Idle Scheduler" , .opt_name ="idle" , - .sched_data =NULL , .pick_resource = sched_idle_res_pick, .do_schedule = sched_idle_schedule,@@ -139,6 +138,11 @@ static struct scheduler sched_idle_ops = { .free_udata = sched_idle_free_udata, }; +static struct scheduler sched_idle_ops = { + .ops = &sched_idle_sched_ops, + .sched_data =NULL , +}; +static inline struct vcpu *unit2vcpu_cpu (const struct sched_unit *unit,unsigned int cpu) {@@ -2081,7 +2085,7 @@ long do_set_timer_op(s_time_t timeout)/* scheduler_id - fetch ID of current scheduler */ int scheduler_id (void ) { -return operations.sched_id; +return operations.ops->sched_id; }#endif @@ -2090,7 +2094,7 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op) {long ret; -if ( op->sched_id !=dom_scheduler (d)->sched_id ) +if ( op->sched_id !=dom_scheduler (d)->ops->sched_id )return -EINVAL ; switch ( op->cmd )@@ -2132,7 +2136,7 @@ long sched_adjust_global(struct xen_sysctl_scheduler_op *op)rcu_read_lock (&sched_res_rculock); - rc = ((op->sched_id == pool->sched->sched_id) + rc = ((op->sched_id == pool->sched->ops->sched_id) ?sched_adjust_cpupool (pool->sched, op) : -EINVAL );rcu_read_unlock (&sched_res_rculock);@@ -2299,7 +2303,7 @@ static struct sched_unit *do_schedule(struct sched_unit *prev, s_time_t now,struct sched_unit *next;/* get policy-specific decision on scheduling... */ - sched->do_schedule (sched, prev, now,sched_tasklet_check (cpu)); + sched->ops->do_schedule (sched, prev, now,sched_tasklet_check (cpu)); next = prev->next_task;
xen/common/sched/core.c void scheduler_enable(void) · line 2996
Quoted 5 lines
xen/common/sched/core.c +1
-1@@ -2989,10 +2993,9 @@ void scheduler_enable(void) }static inline -const struct scheduler *__init sched_get_by_name (const char *sched_name) +const struct sched_ops *__init sched_ops_get_by_name (const char * sched_name)
Nit: whitespace: const char *sched_name
xen/common/sched/core.c void scheduler_enable(void) · line 2995
Quoted 3 lines
xen/common/sched/core.c +0
-1{unsigned int i; -
Nit: please retain the newline here
xen/common/sched/core.c const struct scheduler *__init sched_get_by_name(const char *sched_name) · line 3008
Quoted 11 lines
xen/common/sched/core.c +1
-3for ( i =0 ; i <NUM_SCHEDULERS ; i++ )if ( schedulers[i] && !strcmp (schedulers[i]->opt_name, sched_name) )return schedulers[i];@@ -3002,16 +3005,15 @@ const struct scheduler *__init sched_get_by_name(const char *sched_name)int __init sched_get_id_by_name (const char *sched_name) { -const struct scheduler *scheduler =sched_get_by_name (sched_name); - -return scheduler ? scheduler->sched_id :-1 ; +const struct sched_ops *ops =sched_ops_get_by_name (sched_name);
Nit: newline
Quoted 44 lines
xen/common/sched/core.c +11
-8+return ops ? ops->sched_id :-1 ; }/* Initialise the data structures. */ void __init scheduler_init (void ) {struct domain *idle_domain; -const struct scheduler *scheduler; +const struct sched_ops *ops;int i;scheduler_enable ();@@ -3044,21 +3046,23 @@ void __init scheduler_init(void) } } - scheduler =sched_get_by_name (opt_sched); -if ( !scheduler ) + ops =sched_ops_get_by_name (opt_sched); +if ( !ops ) {printk ("Could not find scheduler: %s\n" , opt_sched); - scheduler =sched_get_by_name (CONFIG_SCHED_DEFAULT ); -BUG_ON (!scheduler); -printk ("Using '%s' (%s)\n" , scheduler->name, scheduler->opt_name); + ops =sched_ops_get_by_name (CONFIG_SCHED_DEFAULT ); +BUG_ON (!ops); +printk ("Using '%s' (%s)\n" , ops->name, ops->opt_name); } - operations = *scheduler; + + operations.ops = ops;if (cpu_schedule_up (0 ) )BUG ();register_cpu_notifier (&cpu_schedule_nfb); -printk ("Using scheduler: %s (%s)\n" , operations.name, operations.opt_name); +printk ("Using scheduler: %s (%s)\n" , + operations.ops->name, operations.ops->opt_name);if (sched_init (&operations) )panic ("scheduler returned error on init\n" );
xen/common/sched/core.c struct scheduler *scheduler_alloc(unsigned int sched_id) · line 3422
Quoted 9 lines
xen/common/sched/core.c +2
-1@@ -3411,12 +3415,14 @@ struct scheduler *scheduler_alloc(unsigned int sched_id)for ( i =0 ; i <NUM_SCHEDULERS ; i++ )if ( schedulers[i] && schedulers[i]->sched_id == sched_id ) goto found; +return ERR_PTR (-ENOENT ); found: - if ( (sched = xmalloc(struct scheduler)) == NULL ) + if ( (sched = xzalloc(struct scheduler)) == NULL )
The change to xzalloc deserves a mention in the commit message.
Quoted 121 lines
xen/common/sched/core.c +3
-2return ERR_PTR (-ENOMEM ); -memcpy (sched, schedulers[i],sizeof (*sched)); + sched->ops = schedulers[i]; +if ( (ret =sched_init (sched)) !=0 ) {xfree (sched);@@ -3447,7 +3453,7 @@ void schedule_dump(struct cpupool *c) { sched = c->sched; cpus = c->res_valid; -printk ("Scheduler: %s (%s)\n" , sched->name, sched->opt_name); +printk ("Scheduler: %s (%s)\n" , sched->ops->name, sched->ops->opt_name);sched_dump_settings (sched); } elsexen/common/sched/cpupool.c +4
-3@@ -338,7 +338,8 @@ 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 +863,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 +1295,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/credit.c +1
-2@@ -2277,11 +2277,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,xen/common/sched/credit2.c +1
-2@@ -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,xen/common/sched/null.c +1
-2@@ -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,xen/common/sched/private.h +4
-6@@ -294,12 +294,10 @@ static inline spinlock_t *pcpu_schedule_trylock(unsigned int cpu)return NULL ; } -struct scheduler { -const char *name;/* full name for this scheduler */ -const char *opt_name;/* option name for this scheduler */ -unsigned int sched_id;/* ID for this scheduler */ -void *sched_data;/* global data pointer */ -struct cpupool *cpupool;/* points to this scheduler's pool */ +struct sched_ops { +const char *name;/* full name for this sched_ops */ +const char *opt_name;/* option name for this sched_ops */ +unsigned int sched_id;/* ID for this sched_ops */ int (*global_init) (void );
xen/common/sched/private.h struct scheduler { · line 369
Quoted 6 lines
xen/common/sched/private.h +3
-0@@ -366,127 +364,133 @@ struct scheduler { struct sched_resource *sr); }; +struct scheduler { +const struct sched_ops *ops;/* shared, read-only dispatch table */ +void *sched_data;/* global data pointer */
Isn't it a scheduler instance data pointer, not global?
PATCH v2 2/2 xen/sched: rename scheduler registration symbols
In reply to Furkan CaliskanREGISTER_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.
--- 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(-)
xen/arch/arm/xen.lds.S +1 -1
@@ -93,7 +93,7 @@ SECTIONS .data : { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/ppc/xen.lds.S +1 -1
@@ -84,7 +84,7 @@ SECTIONS DECL_SECTION(.data) { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/riscv/xen.lds.S +1 -1
@@ -89,7 +89,7 @@ SECTIONS .data : { /* Data */ *(.data.page_aligned) - SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM *(.data .data.*)
xen/arch/x86/xen.lds.S +1 -1
@@ -306,7 +306,7 @@ SECTIONS DECL_SECTION(.data.read_mostly) { *(.data.read_mostly) - SCHEDULER_ARRAY + SCHED_OPS_ARRAY HYPFS_PARAM } PHDR(text)
xen/common/sched/arinc653.c +1 -1
@@ -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:
xen/common/sched/core.c +17 -16
@@ -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_arraystatic struct scheduler __read_mostly operations;
@@ -2996,9 +2996,9 @@ static inlineconst 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 ) {
xen/common/sched/credit.c +1 -1
@@ -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);
xen/common/sched/credit2.c +1 -1
@@ -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);
xen/common/sched/null.c +1 -1
@@ -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);
xen/common/sched/private.h +2 -2
@@ -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 {
xen/common/sched/rt.c +1 -1
@@ -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);
xen/include/xen/xen.lds.h +5 -5
@@ -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 \
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] xen/sched: rename scheduler registration symbols
Quoted 9 lines · Furkan Caliskan
REGISTER_SCHEDULER(), schedulers[],NUM_SCHEDULERS, and the per-archSCHEDULER_ARRAYlinker macro now register and hold structsched_opsinstances 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]>
Quoted 14 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 | 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(-)
I'm not quite sure if all of this is really useful. In many (all?) places I think "scheduler" as a term is still quite applicable.
One (general) nit though: if already you touch malformed lines (overlong ones is which prompted this comment), please adjust them to be style- conformant.
Jan
Re: [PATCH v2 2/2] xen/sched: rename scheduler registration symbols
Hi Jan,
Quoted 25 lines · Jan Beulich
Quoted 9 lines · Furkan Caliskan
REGISTER_SCHEDULER(), schedulers[],NUM_SCHEDULERS, and the per-archSCHEDULER_ARRAYlinker macro now register and hold structsched_opsinstances 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]>Quoted 14 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 | 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(-)
Quoted 8 lines
I'm not quite sure if all of this is really useful. In many (all?) places I think "scheduler" as a term is still quite applicable.
One (general) nit though: if already you touch malformed lines (overlong ones is which prompted this comment), please adjust them to be style- conformant.
Jan
The main reason I renamed those symbols was type consistency - since 'struct scheduler' is now just the runtime per-cpupool object, keeping 'schedulers[]' and 'REGISTER_SCHEDULER()' around to hold 'struct sched_ops' pointers felt like it might confuse someone reading the code later.
That said, I get your point. At a higher level, those macros and linker arrays are still just registering scheduler implementations, so keeping the names is okay too. If the maintainers prefer keeping the existing naming, patch 1 can simply be taken on its own without the second patch.
Juergen, what do you think here?
Thanks,
Furkan Caliskan
Re: [PATCH v2 2/2] xen/sched: rename scheduler registration symbols
Quoted 43 lines · Furkan Çalışkan
Hi Jan,
Quoted 25 lines · Jan Beulich
Quoted 9 lines · Furkan Caliskan
REGISTER_SCHEDULER(), schedulers[],NUM_SCHEDULERS, and the per-archSCHEDULER_ARRAYlinker macro now register and hold structsched_opsinstances 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]>Quoted 14 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 | 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(-)Quoted 8 lines
I'm not quite sure if all of this is really useful. In many (all?) places I think "scheduler" as a term is still quite applicable.
One (general) nit though: if already you touch malformed lines (overlong ones is which prompted this comment), please adjust them to be style- conformant.
Jan
The main reason I renamed those symbols was type consistency - since 'struct scheduler' is now just the runtime per-cpupool object, keeping 'schedulers[]' and '
REGISTER_SCHEDULER()' around to hold 'structsched_ops' pointers felt like it might confuse someone reading the code later.
Quoted 6 lines
That said, I get your point. At a higher level, those macros and linker arrays are still just registering scheduler implementations, so keeping the names is okay too. If the maintainers prefer keeping the existing naming, patch 1 can simply be taken on its own without the second patch.
Juergen, what do you think here?
I don't think different names make a real difference. I already expected this renaming to be questioned, hence the suggestion to do it in an extra patch, allowing to take the main rework independently from it. :-)
IOW: I wouldn't oppose doing the renaming, but I'd take replies as Jan's as a hint not to Ack the patch.
Juergen