From patchwork Wed Apr 6 17:23:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8763941 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 5D5A69F39A for ; Wed, 6 Apr 2016 17:25:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7484A201E4 for ; Wed, 6 Apr 2016 17:24:59 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 716ED201D3 for ; Wed, 6 Apr 2016 17:24:58 +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 1anrAa-00018L-Lz; Wed, 06 Apr 2016 17:23:08 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anrAY-000184-MF for xen-devel@lists.xenproject.org; Wed, 06 Apr 2016 17:23:06 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id 14/F5-03497-AF545075; Wed, 06 Apr 2016 17:23:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRWlGSWpSXmKPExsVyMfS6o+5PV9Z wg8c32S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozXy7axFbxTqGjeO5utgfGfVBcjF4eQwHRG iZfPZjODOCwCa1gl2v88ZgVxJAQusUqc+fqeqYuRE8iJkXjWPYMdwq6Q2N66jQ3EFhJQkbi5f RUTxKhFTBLL7zYygySEBfQkjhz9wQ5he0t82HsLbBCbgIHEmx17WUFsEQEliXurJgPFOTiYBf QlVn/lAQmzCKhK3L27mwXE5hWwl1jQdxKshFPAQWLPZHeItfYSV7+cANskKiAnsfJyCytEuaD EyZlPWCAmakqs36UPEmYWkJfY/nYO8wRGkVlIqmYhVM1CUrWAkXkVo0ZxalFZapGuoZFeUlFm ekZJbmJmjq6hoYlebmpxcWJ6ak5iUrFecn7uJkZg8DMAwQ7Gs9OcDzFKcjApifJ6SrCGC/El5 adUZiQWZ8QXleakFh9ilOHgUJLgjXMBygkWpaanVqRl5gDjECYtwcGjJMJ7yxkozVtckJhbnJ kOkTrFaMyx5fe1tUwc26beW8skxJKXn5cqJQ4xSQCkNKM0D24QLD1cYpSVEuZlBDpNiKcgtSg 3swRV/hWjOAejkjCvPcgUnsy8Erh9r4BOYQI6pV6YCeSUkkSElFQDo/CFuxxNt2ycTLQTbTMe KDD7O97XCO1ar3FqbcfasrSmsxsUZZcziuSreWazr+y+9XbZpldTnJafjPpw3VWIufvX0z6m+ M+hFUt2aPXsyP2zoDGsnUV9pWGK7nJv1c57Nr77VFTPuxqlJeQFu0z6d/Llo311HcIt2RL+N9 ZO2jW3vVj9/lRdJZbijERDLeai4kQAXS3U7goDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1459963384!23829929!1 X-Originating-IP: [209.85.215.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29620 invoked from network); 6 Apr 2016 17:23:04 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Apr 2016 17:23:04 -0000 Received: by mail-lf0-f65.google.com with SMTP id p81so5077190lfb.3 for ; Wed, 06 Apr 2016 10:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=vwvMXpw2m9Ndtdxcd6g9SAkHTJ120l20XbxGc5mJySk=; b=Xbt1VVsHeaUGgRlSEXR4SFl2Rxl3EW5wvTCbgeIqrhaHR/Aa70bhoVZtyCu1tn/O+l LH4n+EHOFXthKuRAzpFsD9R/5R1UcgAj7E7cZhQxLLn4RGF+e3ws25VUQE0v48v0j+Lf e/aFtBhnrCKAzcC87TQCunmTeyE4Y9f/avnhDD5sb6/OHkyU299qeMn+VihY3Khuuc0d Q5o0vk49615ypvpWv1acrd48SNHekmWPrpuFuMSp7R5JRbbJ50vGRO+h8JsWJ5228o0i nwvM9oz9vGYiNgoswHesdXw5tGMZcIB0LF+FUdbE3pFpQhIFKR+bkjVMu2Dbgdkm+nJL 7BKg== 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 :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=vwvMXpw2m9Ndtdxcd6g9SAkHTJ120l20XbxGc5mJySk=; b=NF4PDF8R+GqukOe+COzBHH7J9eDElwU0lg/XUYhUblk1BDS84tFeIUOIOo/Qo+WiS0 /deF+85cTl5wSwb/wvOiBpFv1plmseUEaK7AlJvj6Y8DABMxnvdhgn/oLqmEDzQiQMVZ Ev6gjF/zhzarOEJ/R4QPOaeRM/7ldZvDpjmSh4qvGkDMQDsGDxugdjS5WCvTdgtzriYy 4lnN5puyt7Ia1F5AKQaHw+h2rdBFjFcErgA0OQmUvgzKfuZ7frSSZ+hYY+3bhSpjT7ve n9xuj9TO+caUAeUU/6hE8ZcYtLhYrY7CRn4eKJEW3xcWfBJcNUvGFnqr1xU8G4jbhFNI bR8g== X-Gm-Message-State: AD7BkJJ2VX1JHyWAyMkL5BWbm6vF6siPMrdCWdo3Y3IE5SPvt3TDvAdvdjdyOiyaFjopMg== X-Received: by 10.28.230.69 with SMTP id d66mr6055230wmh.54.1459963384158; Wed, 06 Apr 2016 10:23:04 -0700 (PDT) Received: from Solace.fritz.box (net-37-116-155-252.cust.vodafonedsl.it. [37.116.155.252]) by smtp.gmail.com with ESMTPSA id s10sm1350762wjp.3.2016.04.06.10.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 10:23:03 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 06 Apr 2016 19:23:01 +0200 Message-ID: <20160406172301.25877.38149.stgit@Solace.fritz.box> In-Reply-To: <20160406170023.25877.15622.stgit@Solace.fritz.box> References: <20160406170023.25877.15622.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap Subject: [Xen-devel] [PATCH v2 03/11] xen: sched: move pCPU initialization in an helper 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 That will turn out useful in following patches, where such code will need to be called more than just once. Create an helper now, and move the code there, to avoid mixing code motion and functional changes later. In Credit2, some style cleanup is also done. No functional change intended. Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap --- xen/common/sched_credit.c | 20 ++++++++++++-------- xen/common/sched_credit2.c | 26 ++++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index f503e73..96a245d 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -543,17 +543,12 @@ csched_alloc_pdata(const struct scheduler *ops, int cpu) } static void -csched_init_pdata(const struct scheduler *ops, void *pdata, int cpu) +init_pdata(struct csched_private *prv, struct csched_pcpu *spc, int cpu) { - struct csched_private *prv = CSCHED_PRIV(ops); - struct csched_pcpu * const spc = pdata; - unsigned long flags; - - /* cpu data needs to be allocated, but STILL uninitialized */ + ASSERT(spin_is_locked(&prv->lock)); + /* cpu data needs to be allocated, but STILL uninitialized. */ ASSERT(spc && spc->runq.next == NULL && spc->runq.prev == NULL); - spin_lock_irqsave(&prv->lock, flags); - /* Initialize/update system-wide config */ prv->credit += prv->credits_per_tslice; prv->ncpus++; @@ -576,7 +571,16 @@ csched_init_pdata(const struct scheduler *ops, void *pdata, int cpu) /* Start off idling... */ BUG_ON(!is_idle_vcpu(curr_on_cpu(cpu))); cpumask_set_cpu(cpu, prv->idlers); +} +static void +csched_init_pdata(const struct scheduler *ops, void *pdata, int cpu) +{ + unsigned long flags; + struct csched_private *prv = CSCHED_PRIV(ops); + + spin_lock_irqsave(&prv->lock, flags); + init_pdata(prv, pdata, cpu); spin_unlock_irqrestore(&prv->lock, flags); } diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 8a56953..8989eea 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1972,16 +1972,13 @@ static void deactivate_runqueue(struct csched2_private *prv, int rqi) } static void -csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) +init_pdata(struct csched2_private *prv, unsigned int cpu) { unsigned rqi; - unsigned long flags; - struct csched2_private *prv = CSCHED2_PRIV(ops); struct csched2_runqueue_data *rqd; spinlock_t *old_lock; - spin_lock_irqsave(&prv->lock, flags); - + ASSERT(spin_is_locked(&prv->lock)); ASSERT(!cpumask_test_cpu(cpu, &prv->initialized)); /* Figure out which runqueue to put it in */ @@ -2001,7 +1998,7 @@ csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) BUG(); } - rqd=prv->rqd + rqi; + rqd = prv->rqd + rqi; printk("Adding cpu %d to runqueue %d\n", cpu, rqi); if ( ! cpumask_test_cpu(rqi, &prv->active_queues) ) @@ -2011,13 +2008,13 @@ csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) } /* IRQs already disabled */ - old_lock=pcpu_schedule_lock(cpu); + old_lock = pcpu_schedule_lock(cpu); /* Move spinlock to new runq lock. */ per_cpu(schedule_data, cpu).schedule_lock = &rqd->lock; /* Set the runqueue map */ - prv->runq_map[cpu]=rqi; + prv->runq_map[cpu] = rqi; cpumask_set_cpu(cpu, &rqd->idle); cpumask_set_cpu(cpu, &rqd->active); @@ -2027,12 +2024,21 @@ csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) cpumask_set_cpu(cpu, &prv->initialized); - spin_unlock_irqrestore(&prv->lock, flags); - return; } static void +csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) +{ + struct csched2_private *prv = CSCHED2_PRIV(ops); + unsigned long flags; + + spin_lock_irqsave(&prv->lock, flags); + init_pdata(prv, cpu); + spin_unlock_irqrestore(&prv->lock, flags); +} + +static void csched2_free_pdata(const struct scheduler *ops, void *pcpu, int cpu) { unsigned long flags;