From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Creekmore Subject: [PATCH 4/4] sched: Use the auto-generated list of schedulers Date: Thu, 17 Dec 2015 14:59:34 -0600 Message-ID: <1450385974-12732-5-git-send-email-jonathan.creekmore@gmail.com> References: <1450385974-12732-1-git-send-email-jonathan.creekmore@gmail.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 1a9fed-0007nF-Ij for xen-devel@lists.xenproject.org; Thu, 17 Dec 2015 21:00:03 +0000 Received: by mail-yk0-f182.google.com with SMTP id 140so34480544ykp.0 for ; Thu, 17 Dec 2015 13:00:02 -0800 (PST) In-Reply-To: <1450385974-12732-1-git-send-email-jonathan.creekmore@gmail.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: xen-devel@lists.xenproject.org Cc: George Dunlap , Jonathan Creekmore , Dario Faggioli List-Id: xen-devel@lists.xenproject.org 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; 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; - #define REGISTER_SCHEDULER(x) static const struct scheduler *x##_entry \ __used_section(".data.schedulers") = &x; -- 2.6.4