From patchwork Fri Mar 18 19:04:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8623311 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 1F82BC0553 for ; Fri, 18 Mar 2016 19:07:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3289C20204 for ; Fri, 18 Mar 2016 19:07:28 +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 4A71820123 for ; Fri, 18 Mar 2016 19:07:27 +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-0000KO-GL; Fri, 18 Mar 2016 19:05:02 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agzhl-0000Jx-Ss for xen-devel@lists.xenproject.org; Fri, 18 Mar 2016 19:05:01 +0000 Received: from [193.109.254.147] by server-13.bemta-14.messagelabs.com id 94/48-02874-D515CE65; Fri, 18 Mar 2016 19:05:01 +0000 X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1458327900!32268255!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43672 invoked from network); 18 Mar 2016 19:05:00 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Mar 2016 19:05:00 -0000 Received: by mail-wm0-f67.google.com with SMTP id x188so8147900wmg.0 for ; Fri, 18 Mar 2016 12:05:00 -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=HbmhpRfuhBx0mYVMLThdfVM8V8UCN3ScG8+5iAd0bck=; b=OJsvO8PSdkmee4/8KovDrWDY2Vw2l7Jzdnk4bbqA/iYh9j4ux2nW2aeBFOhC5jgb/x z204GbXM4MHBgmri/nuz+kyVhrG9dIlOfGkmRvSqlOCich9XsFi31HSZOc+h0DpxDh1I ++m5NFHd1q0tHKsjphHRMimxpJeZ83bGQKZKNl+xhl+Lenl4FOY3LU6Yk8Rj5Mjb+OVc tzFyYDPXIrpv6wc+Iq1+STvjfO2HJVYeTMq7vpQSfG2TOxqfsDsBUZUEJvdFvmuf8MKL wRInh3cyUQF1SCHqtWQGvM7B8mpIoRqtb69B7ylzXRV7FbB6UJOAenysQqO1OYfrKB6K vHtQ== 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=HbmhpRfuhBx0mYVMLThdfVM8V8UCN3ScG8+5iAd0bck=; b=VB7CNpg0HEa2FrCdH4qgo7zfaMUEkElyrBuU2dIEbJxhDghJmddrafE/wHXZXAKUW0 weVEZnQgbnW/SXz60RReiAvqMWIbaTo1dBXA5FO56shVvd3iqxWXQgRUiHf6BXWOoZRQ rmyaCCnlm/dx94yp7PmpWFAMrLbXdDhN+JAi49bcMriX9NTI8hhJmkx9hrCgBooc+dPw rBSkUEwvf5oA3raDAKnz+MOxWBCE3QViXGrVnIl3yESBKVKzFyitZFtvdaGrJ67okIsW 1Rq3G+455zWoQmCsxT//Sl0Bv2+db/OVRrs7whgUi+lqfTvnZEyiCdkPzCPAqhygt9Ap G00w== X-Gm-Message-State: AD7BkJKBl3ge3Y4fknz6ikOwnNbruASh2JstYgS6J1Y4ULAXxLHYhkTFClIl1N7w1IKC9A== X-Received: by 10.194.111.229 with SMTP id il5mr19909922wjb.82.1458327900241; Fri, 18 Mar 2016 12:05:00 -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 192sm588711wmw.0.2016.03.18.12.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 12:04:59 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 18 Mar 2016 20:04:57 +0100 Message-ID: <20160318190457.8117.88084.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 , Tianyang Chen , Meng Xu Subject: [Xen-devel] [PATCH 08/16] xen: sched: prepare a .switch_sched hook for Credit2 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 RTDS is basically identical to Credit2, as far as scheduler lock (re)mapping is concerned. Therefore, the same analisys and considerations expressed for the previous patch ("xen: sched: prepare a .switch_sched hook for Credit2"), applies to it to. This patch, therefore, introduces the switch_sched hook for RTDS, as done already for Credit2 and Credit1. Signed-off-by: Dario Faggioli Reviewed-by: Meng Xu --- Cc: George Dunlap Cc: Meng Xu Cc: Tianyang Chen --- xen/common/sched_rt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index b6ac3ad..92be248 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -665,6 +665,36 @@ rt_init_pdata(const struct scheduler *ops, void *pdata, int cpu) spin_unlock_irqrestore(old_lock, flags); } +/* Change the scheduler of cpu to us (RTDS). */ +static void +rt_switch_sched(struct scheduler *new_ops, unsigned int cpu, + void *pdata, void *vdata) +{ + struct rt_vcpu *svc = vdata; + spinlock_t *old_lock; + + ASSERT(!pdata && svc && is_idle_vcpu(svc->vcpu)); + + /* + * We may be acquiring the lock of another scheduler here (the one cpu + * still belongs to when calling this function). That is ok as, anyone + * trying to schedule on this cpu will block until when we release that + * lock (bottom of this function). When unblocked --because of the loop + * implemented by schedule_lock() functions-- he will notice the lock + * changed, and acquire ours before being able to proceed. + */ + old_lock = pcpu_schedule_lock_irq(cpu); + + idle_vcpu[cpu]->sched_priv = vdata; + per_cpu(scheduler, cpu) = new_ops; + per_cpu(schedule_data, cpu).sched_priv = NULL; /* no pdata */ + /* (Re?)route the lock to our global lock. */ + per_cpu(schedule_data, cpu).schedule_lock = &rt_priv(new_ops)->lock; + + /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ + spin_unlock_irq(old_lock); +} + static void * rt_alloc_pdata(const struct scheduler *ops, int cpu) { @@ -1400,6 +1430,7 @@ static const struct scheduler sched_rtds_def = { .alloc_pdata = rt_alloc_pdata, .free_pdata = rt_free_pdata, .init_pdata = rt_init_pdata, + .switch_sched = rt_switch_sched, .alloc_domdata = rt_alloc_domdata, .free_domdata = rt_free_domdata, .init_domain = rt_dom_init,