From patchwork Fri Mar 18 19:04:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8623261 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 C839FC0553 for ; Fri, 18 Mar 2016 19:06:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D800720351 for ; Fri, 18 Mar 2016 19:06:53 +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 DAFC720306 for ; Fri, 18 Mar 2016 19:06:52 +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 1agzhM-00007O-Jq; Fri, 18 Mar 2016 19:04:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agzhL-00006u-Lr for xen-devel@lists.xenproject.org; Fri, 18 Mar 2016 19:04:35 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 36/5A-25417-3415CE65; Fri, 18 Mar 2016 19:04:35 +0000 X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1458327874!29876674!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7956 invoked from network); 18 Mar 2016 19:04:34 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-7.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Mar 2016 19:04:34 -0000 Received: by mail-wm0-f65.google.com with SMTP id x188so8145767wmg.0 for ; Fri, 18 Mar 2016 12:04:34 -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=fJMAEU2PF2G4Mq5XY7rt578TzPaynXdtfOvXKZ9ql+A=; b=mzAiOL2zeKdGF3gfPZXkIqxbSeqACtrUDQtYpt3SCoG5UX75RMo+4AZv8DNNayXNu0 ywZi8BNz+eiCMZgvnPv17+7w2EwcSNroD0HiovDxTiyDMOVKvyH8OJtAK/AnEGW2aPHt Tc/RbJoCkyw/Zcpw8S3CcwnNUUy3neSHusKWzl5uLYJSSkNLuW04xlU/4S6WlipOc18q pZBsiujuVEFJTX1Z9lFTdtc1PlxwNP7wiy7wpZoUVGoYjbRg0X7/xGEVAPwyVz/2zC2Y FMvh2P9F/vwQdXTPk3w7e3mcUcNkGWh4TsI+iTaI/QpowXq6Z86cB7d2LsnFYJplp6A5 3FHQ== 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=fJMAEU2PF2G4Mq5XY7rt578TzPaynXdtfOvXKZ9ql+A=; b=Yt+Y8vsSWbeixrTRuJ/n6gaqw+YUc61OiMSQhydxNgPhlmGZLzd48BiM5qWFBPmjRD ZJ/1nh/yYAb8zZ9l6Wb/4/5jXxBRWdLF49io/R/PPZLkcPUHhEiCDRCiANazgCj5+39t Y4TwHqFNS6mKTUAjw9YJL3IJDniuW1RxcmaVHXf5mFUfF0eePVUKG3ZPMW3M5ZNoPiSM da7kZvDZphaoljTE52IPhn+m8K0i52CMacNNf1pJ2IJnDA2Lb9mEeMIYKcBG+M7j0AV7 +tIu+CYdLm0pwYevNbrCqCUkLHHIwDrH9JMxFovQTBez4es9xY1ce6HuwtYmFyPWr22t tN+A== X-Gm-Message-State: AD7BkJIKnfKt7wrkcdErelx69D26pTSiIwvHEy0V8+IYmr3PRRO/axPtj6LaZvRByW/U1Q== X-Received: by 10.28.226.212 with SMTP id z203mr963858wmg.9.1458327874254; Fri, 18 Mar 2016 12:04:34 -0700 (PDT) Received: from Solace.station (net-2-35-170-8.cust.vodafonedsl.it. [2.35.170.8]) by smtp.gmail.com with ESMTPSA id e19sm581897wmd.1.2016.03.18.12.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 12:04:33 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 18 Mar 2016 20:04:32 +0100 Message-ID: <20160318190432.8117.78163.stgit@Solace.station> In-Reply-To: <20160318185524.8117.74837.stgit@Solace.station> References: <20160318185524.8117.74837.stgit@Solace.station> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap Subject: [Xen-devel] [PATCH 05/16] 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 --- Cc: George Dunlap --- xen/common/sched_credit.c | 22 +++++++++++++--------- xen/common/sched_credit2.c | 26 ++++++++++++++++---------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index d4a0f5e..4488d7c 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -542,16 +542,11 @@ 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(spc && spc->runq.next == spc->runq.prev && spc->runq.next == NULL); - - spin_lock_irqsave(&prv->lock, flags); + 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); /* Initialize/update system-wide config */ prv->credit += prv->credits_per_tslice; @@ -575,7 +570,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 b1642a8..919ca13 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1969,16 +1969,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 */ @@ -1998,7 +1995,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) ) @@ -2008,13 +2005,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); @@ -2024,12 +2021,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;