From patchwork Fri Feb 12 09:37:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8289461 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 410629F1C0 for ; Fri, 12 Feb 2016 09:39:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F4FD203B7 for ; Fri, 12 Feb 2016 09:39:37 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EFD2203B5 for ; Fri, 12 Feb 2016 09:39:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUAA3-0002oW-C7; Fri, 12 Feb 2016 09:37:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUAA1-0002no-5o for xen-devel@lists.xenproject.org; Fri, 12 Feb 2016 09:37:09 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 18/EA-06010-4C7ADB65; Fri, 12 Feb 2016 09:37:08 +0000 X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1455269827!21870227!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42960 invoked from network); 12 Feb 2016 09:37:07 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-12.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Feb 2016 09:37:07 -0000 Received: by mail-wm0-f66.google.com with SMTP id p63so1668423wmp.1 for ; Fri, 12 Feb 2016 01:37:07 -0800 (PST) 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-type:content-transfer-encoding; bh=0VI2u1u6H7xx2F7WlPmWdeRoQRQtBmswipZrXrfVdNE=; b=eAhZnVKHQTWuioYMmBirp6hqqYbC7KJD2u+uXEVhQ0zIFmwJr40Hpl1T63Vo0ILae/ QvTJWDK97X+vFhOAWMBNpYdWUAiRkii4wOwYVk8tdxLYA2FeIGcRmmrjkVOxzGb5nM3J +OHgAyQ4b5bG79Xjc0cJHNJDehlZHaDX3qjt2kDp+oZxo8oTCETMf9qeGD9qzbZ7bsDp 93Fo+KHTBz1cweqQKSk/iENsEQVwtefLA0lr5OhfsyhmfYReMLZ1ExOff4s6/nYRPmPg DDhj2DtvEmoW8/YyHNgO+2n7MWOp2UB6uW4yv2CiSx7pJkq9+DwWsLBp31jD4eAICy9t AAbg== 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-type :content-transfer-encoding; bh=0VI2u1u6H7xx2F7WlPmWdeRoQRQtBmswipZrXrfVdNE=; b=kNMQj2ihvRqIGs6ja508+FaOgeldTeWO4s4wwx9eNTXdBiaZquCw1CanJ7ZL9oStfa a8okOWWqbiHqX4I+/GoH/CjI2L1cAZKRmeg+37pAmKiRVHOoBY0KktNoEaAPOt4Bi7dT ElfXsll/u8LziAzOD5lbBtIev92qY5jAB+YfAiNO1JEhmiXlIPsOYz+P1LMMYiTOroEf WACfQTLg4nNaZzkKO/lmpmB+eR8WvK8vj4XhTEuPvrPJ7ShBXQ7KoDjJrtkorkze1IAp DjrRATU4+hQ+Esci9pXO1pDU9sbqll1HnIcR49EpN1GZA+n6BTjKPU02IYcYRuFvg/Vr WXNA== X-Gm-Message-State: AG10YORx/DITRGpq8s5ornyv21gNvncJnLqOfjS8L9AAwOnSRMGVn82gSYVSLlAXkNWsSQ== X-Received: by 10.28.173.208 with SMTP id w199mr1745799wme.45.1455269827651; Fri, 12 Feb 2016 01:37:07 -0800 (PST) Received: from Solace.station (net-2-35-170-8.cust.vodafonedsl.it. [2.35.170.8]) by smtp.gmail.com with ESMTPSA id js8sm11170007wjc.37.2016.02.12.01.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2016 01:37:06 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 12 Feb 2016 10:37:05 +0100 Message-ID: <20160212093705.16002.46867.stgit@Solace.station> In-Reply-To: <20160212093501.16002.32635.stgit@Solace.station> References: <20160212093501.16002.32635.stgit@Solace.station> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Jan Beulich Subject: [Xen-devel] [PATCH v2 2/2] xen: credit1: avoid boosting vCPUs being "just" migrated X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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 Moving a vCPU to a different pCPU means offlining it and then waking it up, on the new pCPU. Credit1 grants BOOST priority to vCPUs that wakes up, with the aim of improving I/O latency. The net effect of this all is that vCPUs get boosted when migrating, which shouldn't happen. For instance, this causes scheduling anomalies and, potentially, performance problems, as reported here: http://lists.xen.org/archives/html/xen-devel/2015-10/msg02851.html This patch fixes this by noting down (by means of a flag) the fact that the vCPU is about to undergo a migration. This way we can tell, later, during a wakeup, whether the vCPU is migrating or unblocking, and decide whether or not to apply the boosting. Signed-off-by: Dario Faggioli --- Cc: George Dunlap Cc: Jan Beulich --- Changes from v1: * rewritten, following suggestion got during review: there are no wakeup flags any longer, and all is done in sched_credit.c by setting a flag in csched_cpu_pick() and testing (and cleating) it in csched_vcpu_wake(). --- xen/common/sched_credit.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 5708701..756e884 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -66,6 +66,7 @@ */ #define CSCHED_FLAG_VCPU_PARKED 0x0 /* VCPU over capped credits */ #define CSCHED_FLAG_VCPU_YIELD 0x1 /* VCPU yielding */ +#define CSCHED_FLAG_VCPU_MIGRATING 0x2 /* VCPU may have moved to a new pcpu */ /* @@ -787,6 +788,16 @@ _csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t commit) static int csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc) { + struct csched_vcpu *svc = CSCHED_VCPU(vc); + + /* + * We have been called by vcpu_migrate() (in schedule.c), as part + * of the process of seeing if vc can be migrated to another pcpu. + * We make a note about this in svc->flags so that later, in + * csched_vcpu_wake() (still called from vcpu_migrate()) we won't + * get boosted, which we don't deserve as we are "only" migrating. + */ + set_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags); return _csched_cpu_pick(ops, vc, 1); } @@ -1022,11 +1033,18 @@ csched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) * more CPU resource intensive VCPUs without impacting overall * system fairness. * - * The one exception is for VCPUs of capped domains unpausing - * after earning credits they had overspent. We don't boost - * those. + * There are two cases, when we don't want to boost: + * - VCPUs that are waking up after a migration, rather than + * after having block; + * - VCPUs of capped domains unpausing after earning credits + * they had overspent. + * + * Note that checking whether we are "only" migrating must be + * done up front, as we do not want the clearing of the bit we + * set in csched_cpu_pick() to be short-circuited away. */ - if ( svc->pri == CSCHED_PRI_TS_UNDER && + if ( !__test_and_clear_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags) && + svc->pri == CSCHED_PRI_TS_UNDER && !test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) { TRACE_2D(TRC_CSCHED_BOOST_START, vc->domain->domain_id, vc->vcpu_id);