From patchwork Thu Jan 14 14:49:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Creekmore X-Patchwork-Id: 8032471 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A13089F6FA for ; Thu, 14 Jan 2016 14:52:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD8F620411 for ; Thu, 14 Jan 2016 14:52:18 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74FE120459 for ; Thu, 14 Jan 2016 14:52:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJjDN-0002O6-ED; Thu, 14 Jan 2016 14:49:29 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJjDM-0002Mb-9e for xen-devel@lists.xenproject.org; Thu, 14 Jan 2016 14:49:28 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id B8/BD-03235-775B7965; Thu, 14 Jan 2016 14:49:27 +0000 X-Env-Sender: jonathan.creekmore@gmail.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1452782966!15894730!1 X-Originating-IP: [209.85.220.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17442 invoked from network); 14 Jan 2016 14:49:26 -0000 Received: from mail-qk0-f193.google.com (HELO mail-qk0-f193.google.com) (209.85.220.193) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 14 Jan 2016 14:49:26 -0000 Received: by mail-qk0-f193.google.com with SMTP id e124so14705702qkc.3 for ; Thu, 14 Jan 2016 06:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=79O5rNfM5mMHpsocz5XHFv5CrAJbECD2q+sm9OjRrQk=; b=i9ZX4wECkCnV/MmMT0NI3lb6Dx5+L+llbhgsq5HHT+nU8VTQM3dMZYWcfl0mMMqa2B Pyh63LmCtH3IouAnVTemOHxBj/FRVsxXvFlUjF6H+rovpK1vD6OHLCC9g508NvUpGzvv nFoWgPt7dERaqPqb0DBHo4SczqwxSnVhX+iBTOK24IlGwcHecxQ1GZJSYO15FKiqGdQZ nn1drhJPG6H4XCEdzOcttpP8ju350is5PViVrfByVbQfQlbMXV25myo++O7z5rt47FLp CBB88qHABmD2mD9XMRdfZVZYTwdbHrta9eMgxZyUjhlHzusTCugQAlQBvq1rcoZjWseG 8BdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=79O5rNfM5mMHpsocz5XHFv5CrAJbECD2q+sm9OjRrQk=; b=SfhV5Pm+wNKeRcEHIyHiVhLx4dd3euQIWZx8cygK7+kddG4EMvdCdzmFqzqfvpWZr2 cOdUqm8r6jDNHhbxSw68FLBrzKPdmdGsdQy40JHuYFBGOA76eXau8zWx4Jdodhq2KXbV Ng8OOD874LzJEBt/DOzO6UZh3E8RLwBJq7SYaNlSDo91oeC1Zhtsoskj3VCkAyv1u8lc pYhB/mStNKwWQSvTR15cIk05iQpTzjLTU3Al6TGzgOZWUezlokS0DBWDJl9M09t1DxZF BMUo+8cexPstOTf47v5Ys8AAAkj+rP5vsTMJem8FyhHjbAePnGvKGrlWW5amWBht8eg9 liYw== X-Gm-Message-State: ALoCoQkTqcer5K8MVj6Yc4w942BP4UCL8EfG2WcdD7feQ8sLLHulVPed3IIEMv/8qhAQZZEpfUp9G2ZmmuJNbQoU3wzuHrlGtQ== X-Received: by 10.129.99.69 with SMTP id x66mr3450205ywb.320.1452782965878; Thu, 14 Jan 2016 06:49:25 -0800 (PST) Received: from Nebula.lan (c-68-34-224-206.hsd1.al.comcast.net. [68.34.224.206]) by smtp.gmail.com with ESMTPSA id i81sm4633114ywe.28.2016.01.14.06.49.24 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jan 2016 06:49:25 -0800 (PST) From: Jonathan Creekmore To: xen-devel@lists.xenproject.org Date: Thu, 14 Jan 2016 08:49:14 -0600 Message-Id: <1452782954-56016-6-git-send-email-jonathan.creekmore@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1452782954-56016-1-git-send-email-jonathan.creekmore@gmail.com> References: <1452782954-56016-1-git-send-email-jonathan.creekmore@gmail.com> Cc: George Dunlap , Jonathan Creekmore , Dario Faggioli Subject: [Xen-devel] [PATCH v5 5/5] sched: Use the auto-generated list of schedulers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Dario Faggioli Reviewed-by: Andrew Cooper Reviewed-by: Doug Goldstein --- Changed since v4: * Remove extra size field that was accidentally left in Changed since v1: * Simplify the calculation of the number of schedulers * Make the scheduler ops structures static to their files --- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 2 +- xen/common/sched_credit2.c | 2 +- xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 23 ++++++----------------- xen/include/xen/sched-if.h | 5 ----- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 3b59514..0606988 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -724,7 +724,7 @@ a653sched_adjust_global(const struct scheduler *ops, * callback functions. * The symbol must be visible to the rest of Xen at link time. */ -const struct scheduler sched_arinc653_def = { +static const struct scheduler sched_arinc653_def = { .name = "ARINC 653 Scheduler", .opt_name = "arinc653", .sched_id = XEN_SCHEDULER_ARINC653, diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index e586248..028e41b 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1991,7 +1991,7 @@ static void csched_tick_resume(const struct scheduler *ops, unsigned int cpu) static struct csched_private _csched_priv; -const struct scheduler sched_credit_def = { +static const struct scheduler sched_credit_def = { .name = "SMP Credit Scheduler", .opt_name = "credit", .sched_id = XEN_SCHEDULER_CREDIT, diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 38b02d0..78220a7 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2194,7 +2194,7 @@ csched2_deinit(const struct scheduler *ops) static struct csched2_private _csched2_priv; -const struct scheduler sched_credit2_def = { +static const struct scheduler sched_credit2_def = { .name = "SMP Credit Scheduler rev2", .opt_name = "credit2", .sched_id = XEN_SCHEDULER_CREDIT2, diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 7640cd0..2e5430f 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1170,7 +1170,7 @@ rt_dom_cntl( static struct rt_private _rt_priv; -const struct scheduler sched_rtds_def = { +static const struct scheduler sched_rtds_def = { .name = "SMP RTDS Scheduler", .opt_name = "rtds", .sched_id = XEN_SCHEDULER_RTDS, diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2f98a48..0232179 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -64,20 +64,9 @@ 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 *__start_schedulers_array[], *__end_schedulers_array[]; +#define NUM_SCHEDULERS (__end_schedulers_array - __start_schedulers_array) +static const struct scheduler **schedulers = __start_schedulers_array; static struct scheduler __read_mostly ops; @@ -1468,7 +1457,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 +1468,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 +1588,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;