From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Creekmore Subject: Re: [PATCH 4/4] sched: Use the auto-generated list of schedulers Date: Fri, 18 Dec 2015 10:44:59 -0600 Message-ID: References: <1450385974-12732-1-git-send-email-jonathan.creekmore@gmail.com> <1450385974-12732-5-git-send-email-jonathan.creekmore@gmail.com> <5673CDE4.5000606@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9y9P-00072U-Ln for xen-devel@lists.xenproject.org; Fri, 18 Dec 2015 16:45:03 +0000 Received: by mail-yk0-f182.google.com with SMTP id 140so64037443ykp.0 for ; Fri, 18 Dec 2015 08:45:02 -0800 (PST) In-reply-to: <5673CDE4.5000606@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: George Dunlap , Jonathan Creekmore , Dario Faggioli , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes: > On 17/12/2015 20:59, Jonathan Creekmore wrote: >> Instead of having a manually-curated list of schedulers, use the array >> that was auto-generated simply by compiling in the scheduler files as >> the sole source of truth of the available schedulers. >> >> CC: George Dunlap >> CC: Dario Faggioli >> Signed-off-by: Jonathan Creekmore >> --- >> xen/common/schedule.c | 24 +++++++----------------- >> xen/include/xen/sched-if.h | 5 ----- >> 2 files changed, 7 insertions(+), 22 deletions(-) >> >> diff --git a/xen/common/schedule.c b/xen/common/schedule.c >> index 2f98a48..efbd67d 100644 >> --- a/xen/common/schedule.c >> +++ b/xen/common/schedule.c >> @@ -64,20 +64,10 @@ static void poll_timer_fn(void *data); >> DEFINE_PER_CPU(struct schedule_data, schedule_data); >> DEFINE_PER_CPU(struct scheduler *, scheduler); >> >> -static const struct scheduler *schedulers[] = { >> -#ifdef CONFIG_SCHED_CREDIT >> - &sched_credit_def, >> -#endif >> -#ifdef CONFIG_SCHED_CREDIT2 >> - &sched_credit2_def, >> -#endif >> -#ifdef CONFIG_SCHED_ARINC653 >> - &sched_arinc653_def, >> -#endif >> -#ifdef CONFIG_SCHED_RTDS >> - &sched_rtds_def, >> -#endif >> -}; >> +extern const struct scheduler *__schedulers_start[], *__schedulers_end[]; >> +#define NUM_SCHEDULERS (((uintptr_t)__schedulers_end-(uintptr_t)__schedulers_start) \ >> + / sizeof(struct scheduler *)) >> +static const struct scheduler **schedulers = __schedulers_start; > > You should be able to play some tricks with getting the linker to set a > size of a variable it creates, which would hopefully avoid some of this > complexity. Yeah, that looks fairly straightforward. I can do that in a v2. >> >> static struct scheduler __read_mostly ops; >> >> @@ -1468,7 +1458,7 @@ void __init scheduler_init(void) >> >> open_softirq(SCHEDULE_SOFTIRQ, schedule); >> >> - for ( i = 0; i < ARRAY_SIZE(schedulers); i++ ) >> + for ( i = 0; i < NUM_SCHEDULERS; i++) >> { >> if ( schedulers[i]->global_init && schedulers[i]->global_init() < 0 ) >> schedulers[i] = NULL; >> @@ -1479,7 +1469,7 @@ void __init scheduler_init(void) >> if ( !ops.name ) >> { >> printk("Could not find scheduler: %s\n", opt_sched); >> - for ( i = 0; i < ARRAY_SIZE(schedulers); i++ ) >> + for ( i = 0; i < NUM_SCHEDULERS; i++ ) >> if ( schedulers[i] ) >> { >> ops = *schedulers[i]; >> @@ -1599,7 +1589,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr) >> int i; >> struct scheduler *sched; >> >> - for ( i = 0; i < ARRAY_SIZE(schedulers); i++ ) >> + for ( i = 0; i < NUM_SCHEDULERS; i++ ) >> if ( schedulers[i] && schedulers[i]->sched_id == sched_id ) >> goto found; >> *perr = -ENOENT; >> diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h >> index 9c6e0f5..66dc9c8 100644 >> --- a/xen/include/xen/sched-if.h >> +++ b/xen/include/xen/sched-if.h >> @@ -165,11 +165,6 @@ struct scheduler { >> void (*tick_resume) (const struct scheduler *, unsigned int); >> }; >> >> -extern const struct scheduler sched_credit_def; >> -extern const struct scheduler sched_credit2_def; >> -extern const struct scheduler sched_arinc653_def; >> -extern const struct scheduler sched_rtds_def; >> - > > With these changes, you can make the structures themselves static, which > would be a nice tidyup. > I like that as well and will handle that in the v2.