From patchwork Tue Sep 12 00:45:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: anshul makkar X-Patchwork-Id: 9952145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2990760360 for ; Wed, 13 Sep 2017 21:34:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B37F28C7F for ; Wed, 13 Sep 2017 21:34:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FCE628C83; Wed, 13 Sep 2017 21:34:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5810E28C7F for ; Wed, 13 Sep 2017 21:33:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsFGH-0000Z6-MA; Wed, 13 Sep 2017 21:31:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsFGG-0000YJ-0j for xen-devel@lists.xen.org; Wed, 13 Sep 2017 21:31:56 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 3A/D9-03454-BC3A9B95; Wed, 13 Sep 2017 21:31:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRWlGSWpSXmKPExsVyMbThoO6pxTs jDf7PkrJY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDO+3pIpuB9acfLYCbYGxusuXYxcHEICExgl JhxqZgZxWAReskg8aGpmAnEkBPpZJWbdWsraxcgJ5CRJ3N2ymQXCTpOYPXMbO4RdJbF5636wu JCAqsTkhRNYIMauYpLYMHkqWIJNQFti1YfZYINEBKQlrn2+zAhSxCwwhVniyLNnYEXCAlESh2 +sYQaxWYAmzdrYzgRi8wq4SXxuesYMsU1O4ua5TjCbU8BdYvW8A0wQm90kbm44zDyBUXABI8M qRvXi1KKy1CJdY72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMCQYwCCHYwd/5wO MUpyMCmJ8u7V3RkpxJeUn1KZkVicEV9UmpNafIhRg4NDYMLZudOZpFjy8vNSlSR4dy0CqhMsS k1PrUjLzAFGBUypBAePkgivM0iat7ggMbc4Mx0idYrRnuPCnUt/mDh+TLoCJA/suQUkO27e/c MkBDZVSpy3DaRNAKQtozQPbigsii8xykoJ8zICnSzEU5BalJtZgir/ilGcg1FJmLcbZApPZl4 J3O5XQGcxAZ115vQOkLNKEhFSUg2Maw/M9vHYydX0Lb05wPf7r2c86r++adYF7mhna3j/6VsR 57KnuT3RdzYfjvw6qeXar4X304O35v08vuF7zrXHgW/Zz+3+emJGwvSnNdNmvZTQtlh1RWftq QapOKaJJW+kHezS5RMSqk/cFS3xVil78jbd71qA/P6j6v+mFXsxfo5K9U45Zf1CSYmlOCPRUI u5qDgRAE6s3HfdAgAA X-Env-Sender: anshulmakkar@gmail.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1505338314!116817175!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=1.3 required=7.0 tests=BODY_RANDOM_LONG, DATE_IN_PAST_24_48 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18388 invoked from network); 13 Sep 2017 21:31:54 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-6.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 13 Sep 2017 21:31:54 -0000 Received: by mail-wr0-f193.google.com with SMTP id g50so695363wra.3 for ; Wed, 13 Sep 2017 14:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=byf7dcRSnems21sLQw4fZWntLXl7vi+87tymURH7noI=; b=HnrDh1cLdGQ1bE88YekeA89hkZUdXxDwMrXl9CrOUdOt1qCN3INblvbMyMaOyzwh1t Z/sxwU5J8T8Uz+e80VWIbcz4KUZIo/Moa475aORLDYPsHN9Ap3L1MaaJENmmNv5cvVNb owmeyvN9jVI9zs6DUWY5fDiZjw+Rs5hnDhrK3NZgKr3XSt21QaA3B0XDD4je1QaEDJ+h aIWR68WZDPHDogYkyfdw+MJ6rScB70tlVWAIgfOf0z2bI1uLOG4Vq/gTalY/F2U5Cg2s utnWTi/NjPwBVZbtihb06IQ746obpSxSiHlxePlqrtW48qQ/D4a7Ceov1nGlqW0o45SK MuIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=byf7dcRSnems21sLQw4fZWntLXl7vi+87tymURH7noI=; b=PoDgIiD5nO9UYXrYpE1i03PWw9KLEJbFn6vtDDssCqAUvzNxwNhOtAQpVMVKWWmR9j DCslDuZINskz0fnebkjjEUwRj6O7Ya30lcpAuOXJ6+M/FtAmMSrq+wONyNnRt3V8iSXC syoWe4HDGcPy2fhOXACMYmazITMzOwiKBv4x2qdevxYfhL0pYdeXale33pRi9XYIrGOY /EIJibWQWFNGB8gOssEi7rhIEGAoQz/FEWMXHfkMolmRvcqCOwDUL97jdmKH2zjNi4GC bWDtz8yMfU++CUMGTwPNalXcj34CmdMlWlvwvBHaw2NmxhwytdWHqSxS89jwETvfI5c0 V9Ow== X-Gm-Message-State: AHPjjUidODlVlfFybxwpFg+7Mn7HqsB1DJP9LCmOpHAIg2tQHGwR1W/3 VrbqXr+fjWvm0dph+/I= X-Google-Smtp-Source: ADKCNb47RE8o7baYdKDFV508ae2+nh3tGVbOQ/JQHQVpIQNqiYcesUCD1EwHYoQPIYZ0EoeH12x/cA== X-Received: by 10.223.177.211 with SMTP id r19mr17744112wra.2.1505338313545; Wed, 13 Sep 2017 14:31:53 -0700 (PDT) Received: from anshul-VirtualBox.home (host109-151-54-23.range109-151.btcentralplus.com. [109.151.54.23]) by smtp.gmail.com with ESMTPSA id j4sm9224317wrg.96.2017.09.13.14.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Sep 2017 14:31:52 -0700 (PDT) From: anshulmakkar To: xen-devel@lists.xen.org Date: Tue, 12 Sep 2017 01:45:42 +0100 Message-Id: <1505177142-14864-4-git-send-email-anshulmakkar@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505177142-14864-1-git-send-email-anshulmakkar@gmail.com> References: <1505177142-14864-1-git-send-email-anshulmakkar@gmail.com> Cc: jgross@suse.com, sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, marmarek@invisiblethingslab.com, robert.vanvossen@dornerworks.com, tim@xen.org, josh.whitehead@dornerworks.com, mengxu@cis.upenn.edu, jbeulich@suse.com, anshulmakkar Subject: [Xen-devel] [PATCH 3/3] credit2: xen related changes to add support for runqueue per cpupool. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Handles extra scheduler configuration paramers received at init stage. Signed-off-by: Anshul Makkar --- xen/common/cpupool.c | 13 ++++++++----- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 2 +- xen/common/sched_credit2.c | 8 +++++++- xen/common/sched_null.c | 3 ++- xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 11 +++++++---- xen/include/public/sysctl.h | 45 +++++++++++++++++++++++++++++---------------- xen/include/xen/sched-if.h | 3 ++- xen/include/xen/sched.h | 4 +++- 10 files changed, 61 insertions(+), 32 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 9998394..31bace4 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -129,12 +129,13 @@ void cpupool_put(struct cpupool *pool) * - unknown scheduler */ static struct cpupool *cpupool_create( - int poolid, unsigned int sched_id, int *perr) + int poolid, unsigned int sched_id, + xen_sysctl_sched_param_t param, + int *perr) { struct cpupool *c; struct cpupool **q; int last = 0; - *perr = -ENOMEM; if ( (c = alloc_cpupool_struct()) == NULL ) return NULL; @@ -171,7 +172,7 @@ static struct cpupool *cpupool_create( } else { - c->sched = scheduler_alloc(sched_id, perr); + c->sched = scheduler_alloc(sched_id, param, perr); if ( c->sched == NULL ) { spin_unlock(&cpupool_lock); @@ -600,10 +601,11 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) case XEN_SYSCTL_CPUPOOL_OP_CREATE: { int poolid; + xen_sysctl_sched_param_t param = op->sched_param; poolid = (op->cpupool_id == XEN_SYSCTL_CPUPOOL_PAR_ANY) ? CPUPOOLID_NONE: op->cpupool_id; - c = cpupool_create(poolid, op->sched_id, &ret); + c = cpupool_create(poolid, op->sched_id, param, &ret); if ( c != NULL ) { op->cpupool_id = c->cpupool_id; @@ -798,7 +800,8 @@ static int __init cpupool_presmp_init(void) { int err; void *cpu = (void *)(long)smp_processor_id(); - cpupool0 = cpupool_create(0, 0, &err); + xen_sysctl_sched_param_t param; + cpupool0 = cpupool_create(0, 0, param, &err); BUG_ON(cpupool0 == NULL); cpupool_put(cpupool0); cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 0b1b849..1f5d0d0 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -343,7 +343,7 @@ arinc653_sched_get( * */ static int -a653sched_init(struct scheduler *ops) +a653sched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param) { a653sched_priv_t *prv; diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 4fdaa08..44ceaf7 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -2160,7 +2160,7 @@ csched_dump(const struct scheduler *ops) } static int -csched_init(struct scheduler *ops) +csched_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param) { struct csched_private *prv; diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 0f93ad5..9b5bbbf 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -391,6 +391,7 @@ struct csched2_private { unsigned int load_precision_shift; /* Precision of load calculations */ unsigned int load_window_shift; /* Lenght of load decaying window */ unsigned int ratelimit_us; /* Rate limiting for this scheduler */ + unsigned runqueue; /* cpupool has its own type of runq */ cpumask_t active_queues; /* Runqueues with (maybe) active cpus */ struct csched2_runqueue_data *rqd; /* Data of the various runqueues */ @@ -3349,7 +3350,7 @@ csched2_deinit_pdata(const struct scheduler *ops, void *pcpu, int cpu) } static int -csched2_init(struct scheduler *ops) +csched2_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param) { int i; struct csched2_private *prv; @@ -3410,6 +3411,11 @@ csched2_init(struct scheduler *ops) /* initialize ratelimit */ prv->ratelimit_us = sched_ratelimit_us; + /* not need of type checking here if sched_para.type = credit2. Code + * block is here means we have type as credit2. + */ + prv->runqueue = sched_param.u.sched_credit2.runq; + prv->load_precision_shift = opt_load_precision_shift; prv->load_window_shift = opt_load_window_shift - LOADAVG_GRANULARITY_SHIFT; ASSERT(opt_load_window_shift > 0); diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index b4a24ba..cab45c7 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -135,7 +135,8 @@ static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu, return cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu)); } -static int null_init(struct scheduler *ops) +static int null_init(struct scheduler *ops, + xen_sysctl_sched_param_t sched_param) { struct null_private *prv; diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 0ac5816..6593489 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -624,7 +624,7 @@ rt_cpu_pick(const struct scheduler *ops, struct vcpu *vc) * Init/Free related code */ static int -rt_init(struct scheduler *ops) +rt_init(struct scheduler *ops, xen_sysctl_sched_param_t sched_param) { int rc = -ENOMEM; struct rt_private *prv = xzalloc(struct rt_private); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 8827921..8945cf0 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1676,6 +1676,7 @@ void __init scheduler_init(void) { struct domain *idle_domain; int i; + xen_sysctl_sched_param_t param; open_softirq(SCHEDULE_SOFTIRQ, schedule); @@ -1704,9 +1705,9 @@ void __init scheduler_init(void) if ( cpu_schedule_up(0) ) BUG(); register_cpu_notifier(&cpu_schedule_nfb); - + printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name); - if ( SCHED_OP(&ops, init) ) + if ( SCHED_OP(&ops, init, param) ) panic("scheduler returned error on init"); if ( sched_ratelimit_us && @@ -1835,7 +1836,9 @@ struct scheduler *scheduler_get_default(void) return &ops; } -struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr) +struct scheduler *scheduler_alloc(unsigned int sched_id, + xen_sysctl_sched_param_t param, + int *perr) { int i; struct scheduler *sched; @@ -1851,7 +1854,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr) if ( (sched = xmalloc(struct scheduler)) == NULL ) return NULL; memcpy(sched, schedulers[i], sizeof(*sched)); - if ( (*perr = SCHED_OP(sched, init)) != 0 ) + if ( (*perr = SCHED_OP(sched, init, param)) != 0 ) { xfree(sched); sched = NULL; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 7830b98..1182422 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -538,7 +538,34 @@ struct xen_sysctl_numainfo { typedef struct xen_sysctl_numainfo xen_sysctl_numainfo_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_numainfo_t); +struct xen_sysctl_credit_schedule { + /* Length of timeslice in milliseconds */ +#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000 +#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1 + unsigned tslice_ms; + unsigned ratelimit_us; +}; +typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t); + +struct xen_sysctl_credit2_schedule { + unsigned ratelimit_us; + unsigned runq; +}; +typedef struct xen_sysctl_credit2_schedule xen_sysctl_credit2_schedule_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit2_schedule_t); + + /* XEN_SYSCTL_cpupool_op */ +struct xen_sysctl_sched_param { + union { + struct xen_sysctl_credit2_schedule sched_credit2; + struct xen_sysctl_credit_schedule sched_credit; + } u; +}; +typedef struct xen_sysctl_sched_param xen_sysctl_sched_param_t; +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_sched_param_t); + #define XEN_SYSCTL_CPUPOOL_OP_CREATE 1 /* C */ #define XEN_SYSCTL_CPUPOOL_OP_DESTROY 2 /* D */ #define XEN_SYSCTL_CPUPOOL_OP_INFO 3 /* I */ @@ -555,6 +582,8 @@ struct xen_sysctl_cpupool_op { uint32_t cpu; /* IN: AR */ uint32_t n_dom; /* OUT: I */ struct xenctl_bitmap cpumap; /* OUT: IF */ + /* IN: scheduler param relevant for cpupool */ + xen_sysctl_sched_param_t sched_param; }; typedef struct xen_sysctl_cpupool_op xen_sysctl_cpupool_op_t; DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpupool_op_t); @@ -630,22 +659,6 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_arinc653_schedule_t); #define XEN_SYSCTL_SCHED_RATELIMIT_MAX 500000 #define XEN_SYSCTL_SCHED_RATELIMIT_MIN 100 -struct xen_sysctl_credit_schedule { - /* Length of timeslice in milliseconds */ -#define XEN_SYSCTL_CSCHED_TSLICE_MAX 1000 -#define XEN_SYSCTL_CSCHED_TSLICE_MIN 1 - unsigned tslice_ms; - unsigned ratelimit_us; -}; -typedef struct xen_sysctl_credit_schedule xen_sysctl_credit_schedule_t; -DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit_schedule_t); - -struct xen_sysctl_credit2_schedule { - unsigned ratelimit_us; -}; -typedef struct xen_sysctl_credit2_schedule xen_sysctl_credit2_schedule_t; -DEFINE_XEN_GUEST_HANDLE(xen_sysctl_credit2_schedule_t); - /* XEN_SYSCTL_scheduler_op */ /* Set or get info? */ #define XEN_SYSCTL_SCHEDOP_putinfo 0 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index c4a4935..2272ea0 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -136,7 +136,8 @@ struct scheduler { int (*global_init) (void); - int (*init) (struct scheduler *); + int (*init) (struct scheduler *, + xen_sysctl_sched_param_t); void (*deinit) (struct scheduler *); void (*free_vdata) (const struct scheduler *, void *); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 5b8f8c6..43b7dae 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -832,7 +832,9 @@ void cpu_init(void); struct scheduler; struct scheduler *scheduler_get_default(void); -struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr); +struct scheduler *scheduler_alloc(unsigned int sched_id, + xen_sysctl_sched_param_t param, + int *perr); void scheduler_free(struct scheduler *sched); int schedule_cpu_switch(unsigned int cpu, struct cpupool *c); void vcpu_force_reschedule(struct vcpu *v);