From patchwork Mon Feb 8 13:19:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8249551 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 0B8059F1C1 for ; Mon, 8 Feb 2016 13:22:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BB61203B8 for ; Mon, 8 Feb 2016 13:22:38 +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 11721203B4 for ; Mon, 8 Feb 2016 13:22:37 +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 1aSliu-00082i-35; Mon, 08 Feb 2016 13:19:24 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSlir-00082d-Hv for xen-devel@lists.xenproject.org; Mon, 08 Feb 2016 13:19:21 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id A6/99-08977-8D598B65; Mon, 08 Feb 2016 13:19:20 +0000 X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1454937559!14608818!1 X-Originating-IP: [74.125.82.54] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21069 invoked from network); 8 Feb 2016 13:19:20 -0000 Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Feb 2016 13:19:20 -0000 Received: by mail-wm0-f54.google.com with SMTP id c200so15138380wme.0 for ; Mon, 08 Feb 2016 05:19:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=O/5EuuPzZ4Lzsm+w75KgThdnRsN8gyoZ+gKJjcsWi8s=; b=oR7TffYO1faWRtglKgoenM2jMhemMVNs8h7suj+QCafmXREfNOW67tFo2FEfCqMxk9 aIDrBOeDP2F7i6iTEmRSySV27eENahf3caueDPEc05Knyeo/K+cnL/Fn18yHmVTJFdJi U6swaGKR3cA2AegUWEEATjGD14YlX7x2g1yHe+2BGK1BbBaSnaOJqN2WEV6qgncnDxdJ fZMlfMzlYtUR31sOLYqZBM9XTkatienvWZPXDHh5RhlOm0F4PuqTAWu0PR7EnPP/TsYI 3CH+1fGfoh9QgiAjmV3sGjBEk0HqXy0S00i3GsBVpLsVAdj+HqKQZC6Jfmol8TbrZvqQ vytg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=O/5EuuPzZ4Lzsm+w75KgThdnRsN8gyoZ+gKJjcsWi8s=; b=BC3SKxEVnglusM48OpAsr7ImkK9Sfy7vF3d2ucFQpreA69uhVjNejiIZC7MCMFiqCB 0rK8ZSSLV0COn5Lj/E+pkmFBQ0yKevqrDZu02EKxfGkoLc4fejgln++F2kcY/CtEkhw9 M5J5nlPiqeuAL4zAt5Urrb3w9SPVm8pu7GlnCoRZO8Dm5Bn8PmtgRCQ9CJzrbtcOUjVe xg+/+p+Bx5+Q8USrqgPOwBJXfpRgAOcLm7UXMO6uYWG7r+J9x06NSbNhVS5Ze37TaZrK X9z6Al1AQb7UVmSfvJjtZDNM4uWWwvhJUzKM9UAIY3U+N8KTwpicW79loDYoLJj1Upnu 5ihQ== X-Gm-Message-State: AG10YOQ0PCvbbqH0rMWaI/XURsMLNFQcBpIC5ijxQMmc8cmL1cMhBK1RVEcOlvjysPSYsQ== X-Received: by 10.194.246.37 with SMTP id xt5mr27953898wjc.7.1454937559487; Mon, 08 Feb 2016 05:19:19 -0800 (PST) Received: from Solace.station (net-2-35-170-8.cust.vodafonedsl.it. [2.35.170.8]) by smtp.gmail.com with ESMTPSA id x6sm29787532wje.38.2016.02.08.05.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 05:19:18 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Mon, 08 Feb 2016 14:19:16 +0100 Message-ID: <20160208131916.27675.143.stgit@Solace.station> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Juergen Gross , George Dunlap Subject: [Xen-devel] [PATCH] xen: sched: get rid of static private schedulers' structures 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: , 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_SIGNED, 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 In fact, they look rather useless: they are never referenced neither directly, nor via the sched_data pointer, as a dynamic copy that overrides them is allocated as the very first step of a scheduler's initialization. While there, take the chance to also reset the sched_data pointer to NULL, upon scheduler de-initialization. Signed-off-by: Dario Faggioli Acked-by: George Dunlap --- Cc: George Dunlap Cc: Juergen Gross --- xen/common/sched_arinc653.c | 3 ++- xen/common/sched_credit.c | 7 +++---- xen/common/sched_credit2.c | 8 +++----- xen/common/sched_rt.c | 7 +++---- xen/include/xen/sched-if.h | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 0606988..8a11a2f 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -367,9 +367,10 @@ a653sched_init(struct scheduler *ops) * @param ops Pointer to this instance of the scheduler structure */ static void -a653sched_deinit(const struct scheduler *ops) +a653sched_deinit(struct scheduler *ops) { xfree(SCHED_PRIV(ops)); + ops->sched_data = NULL; } /** diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 671bbee..25a4773 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1959,13 +1959,14 @@ csched_init(struct scheduler *ops) } static void -csched_deinit(const struct scheduler *ops) +csched_deinit(struct scheduler *ops) { struct csched_private *prv; prv = CSCHED_PRIV(ops); if ( prv != NULL ) { + ops->sched_data = NULL; free_cpumask_var(prv->cpus); free_cpumask_var(prv->idlers); xfree(prv); @@ -1995,13 +1996,11 @@ static void csched_tick_resume(const struct scheduler *ops, unsigned int cpu) - now % MICROSECS(prv->tick_period_us) ); } -static struct csched_private _csched_priv; - static const struct scheduler sched_credit_def = { .name = "SMP Credit Scheduler", .opt_name = "credit", .sched_id = XEN_SCHEDULER_CREDIT, - .sched_data = &_csched_priv, + .sched_data = NULL, .init_domain = csched_dom_init, .destroy_domain = csched_dom_destroy, diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 78220a7..68a8f1c 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2183,22 +2183,20 @@ csched2_init(struct scheduler *ops) } static void -csched2_deinit(const struct scheduler *ops) +csched2_deinit(struct scheduler *ops) { struct csched2_private *prv; prv = CSCHED2_PRIV(ops); + ops->sched_data = NULL; xfree(prv); } - -static struct csched2_private _csched2_priv; - static const struct scheduler sched_credit2_def = { .name = "SMP Credit Scheduler rev2", .opt_name = "credit2", .sched_id = XEN_SCHEDULER_CREDIT2, - .sched_data = &_csched2_priv, + .sched_data = NULL, .init_domain = csched2_dom_init, .destroy_domain = csched2_dom_destroy, diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 2e5430f..d82d69c 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -462,7 +462,7 @@ rt_init(struct scheduler *ops) } static void -rt_deinit(const struct scheduler *ops) +rt_deinit(struct scheduler *ops) { struct rt_private *prv = rt_priv(ops); @@ -473,6 +473,7 @@ rt_deinit(const struct scheduler *ops) xfree(_cpumask_scratch); _cpumask_scratch = NULL; } + ops->sched_data = NULL; xfree(prv); } @@ -1168,13 +1169,11 @@ rt_dom_cntl( return rc; } -static struct rt_private _rt_priv; - static const struct scheduler sched_rtds_def = { .name = "SMP RTDS Scheduler", .opt_name = "rtds", .sched_id = XEN_SCHEDULER_RTDS, - .sched_data = &_rt_priv, + .sched_data = NULL, .dump_cpu_state = rt_dump_pcpu, .dump_settings = rt_dump, diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 66dc9c8..825f1ad 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -126,7 +126,7 @@ struct scheduler { int (*global_init) (void); int (*init) (struct scheduler *); - void (*deinit) (const struct scheduler *); + void (*deinit) (struct scheduler *); void (*free_vdata) (const struct scheduler *, void *); void * (*alloc_vdata) (const struct scheduler *, struct vcpu *,