From patchwork Fri Apr 8 01:23:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8779501 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33B4AC0553 for ; Fri, 8 Apr 2016 01:25:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31B72201CD for ; Fri, 8 Apr 2016 01:25:48 +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 33324201C7 for ; Fri, 8 Apr 2016 01:25:47 +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 1aoL9D-0007k0-FY; Fri, 08 Apr 2016 01:23:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoL9C-0007ji-Ad for xen-devel@lists.xenproject.org; Fri, 08 Apr 2016 01:23:42 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id E1/FF-16885-D1807075; Fri, 08 Apr 2016 01:23:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRWlGSWpSXmKPExsXiVRvkoivDwR5 usPWSjcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvF62Ta2gncKFc17Z7M1MP6T6mLk4hASmMoo cffUXBYQh0VgDavEpYXtrCCOhMAlVokTjYuAHE4gJ0Zi+dbDbF2MHEB2hcSiA/YgYSEBFYmb2 1cxQUxazCRxq2c2O0hCWEBP4sjRH1C2t8T/3rlMIDabgIHEmx17wWaKCChJ3Fs1mQlkJrOAvs TqrzwgYRYBVYmvB/eCtfIK2Es8mryNBcTmFHCQmLjhKRPEXnuJbd0nwGxRATmJlZdbWCHqBSV OznzCAjFSU2L9Ln2QMLOAvMT2t3OYJzCKzEJSNQuhahaSqgWMzKsY1YtTi8pSi3SN9ZKKMtMz SnITM3N0DQ1M9XJTi4sT01NzEpOK9ZLzczcxAkOfAQh2MO7953SIUZKDSUmU98obtnAhvqT8l MqMxOKM+KLSnNTiQ4wyHBxKErx57OzhQoJFqempFWmZOcAohElLcPAoifBuAUnzFhck5hZnpk OkTjHqcmyZem8tkxBLXn5eqpQ4bw5IkQBIUUZpHtwIWEK4xCgrJczLCHSUEE9BalFuZgmq/Ct GcQ5GJWHeRJApPJl5JXCbXgEdwQR0xAV+NpAjShIRUlINjFpnSs9E77x7m/XUC35BhveHBfx2 HGwvVZh58Lzew5Or82zuXes+yuy98fIzplbPB4+2fX+hs+f/Xrl3r8NNct9svbvlp24258aHJ +7wcU9ZvGtjdi+bctC5/pQ1xSope5zdmSKfrDLXaS56P6uc8/ut96ekvRYbs39d/bwzz6Jbvu /L5q986q+UWIozEg21mIuKEwHfD4XAAwMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1460078620!33607667!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39484 invoked from network); 8 Apr 2016 01:23:40 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-3.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Apr 2016 01:23:40 -0000 Received: by mail-wm0-f68.google.com with SMTP id n3so759251wmn.1 for ; Thu, 07 Apr 2016 18:23:40 -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=zL+JtoIHckpLD2E322uxH9mUsN2fgT6L4OiXcOij98GuCCUrsC4H+XRd7GMM6YASnx 5LT8pZ6s45eUnYBKougicuxX9AGPJLfS3oCWdnaD48lyeqtRSKVU2G/jo84u2nZU+kaw hhJSZAeqshTuFWEFlrNMUAAPrR3ef+/ot3/3qTGjdkH3rRneeDEGb/5pouNPWpeEFOjJ CXDnXHCn5g9xbOMLzqA/PNgcf4SURweJuWsCvCAue0DxdTGbQpQHAO9RoTkHnPXo2Snn R0YqssvvuFxbuG+fOhV+zgen4psh7LN7h10Dko95xA3IfZnBUK0AY67L1rqn0BC7UKkh NpIA== 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=a2pg2T2nsv9OBkpBpAExRJRN7747DUmicM0/w9+LqTnQQLJ/pFR7yzwBoNSk1m3bKP dGvrcEYUFutmgBox+zkQZ5evkTd1yYUyBonhSllcshUTF7p+bZXJ5Q4qEGZ/eyyMIGof 4wFSzxMUBESuUqwKQVxXJ3AQgTB4Xq9CGZEmeh38DudUpprCgLYwI5DZ/qhO49KwGDSN PIoqcaUomx9ZBNibZNuEpR0hO4hByB2g9j2ypz1pAgAWj0fhJYF1MwOXjQl+/eU2K5z8 95/g1RxSFJE3lFJfsArJFFFr6k3dMTi5SlHPXr55O3H1iBm5r8DLDQYna2k43KsDtLOA /8jQ== X-Gm-Message-State: AD7BkJJIMCvcfmU4v8Bmhio8mFoigJZotXTB34xh1geyXQfZBE14EK8j/z3RkAPu+bZH4w== X-Received: by 10.194.3.105 with SMTP id b9mr7015939wjb.140.1460078620748; Thu, 07 Apr 2016 18:23:40 -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 gt7sm11019452wjc.1.2016.04.07.18.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Apr 2016 18:23:39 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 08 Apr 2016 03:23:38 +0200 Message-ID: <20160408012336.10762.67822.stgit@Solace.fritz.box> In-Reply-To: <20160408011204.10762.14241.stgit@Solace.fritz.box> References: <20160408011204.10762.14241.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap Subject: [Xen-devel] [PATCH v3 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;