From patchwork Fri Jun 17 23:12:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9185139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1649E601C0 for ; Fri, 17 Jun 2016 23:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027CE200E7 for ; Fri, 17 Jun 2016 23:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E759827F07; Fri, 17 Jun 2016 23:13:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 91AEE200E7 for ; Fri, 17 Jun 2016 23:13:57 +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 1bE2vs-0003Ij-Jq; Fri, 17 Jun 2016 23:12:12 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bE2vr-0003I1-9U for xen-devel@lists.xenproject.org; Fri, 17 Jun 2016 23:12:11 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id C9/D6-11548-AC384675; Fri, 17 Jun 2016 23:12:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHIsWRWlGSWpSXmKPExsXiVRvkrHuqOSX coP03q8X3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnFs7ky2gkVCFevXBDQwNvJ1MXJxCAnMYJQ4 vv8PI4jDIrCGVeLWma+sII6EwCVWiVVP9wBlOIGcGIkJkx6xQdhVEldPnWQGsYUEVCRubl/FB DFqIZPExTmnmUASwgJ6EkeO/mCHsGMlHjy+xApiswkYSLzZsRfMFhFQkri3ajJYM7NAA6PEhM e7wJpZBFQlHm1YCNbMK+Aj0T+hBczmFPCVWH1lFxvEZh+Ji+cgLhIVkJNYebmFFaJeUOLkzCc sXYwcQEM1Jdbv0gcJMwvIS2x/O4d5AqPILCRVsxCqZiGpWsDIvIpRvTi1qCy1SNdYL6koMz2j JDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMPwZgGAHY8c/p0OMkhxMSqK8VypTwoX4kvJTK jMSizPii0pzUosPMWpwcAhMODt3OpMUS15+XqqSBO+GJqA6waLU9NSKtMwcYITClEpw8CiJ8O 4ESfMWFyTmFmemQ6ROMepybJl6by2TENgMKXHezSBFAiBFGaV5cCNgyeISo6yUMC8j0IFCPAW pRbmZJajyrxjFORiVhHlngkzhycwrgdv0CugIJqAjNOclgxxRkoiQkmpgTFzamnui+NVZOccH AhfqSlZdi4iyVVj/5saxeP5Fr4P+Sk83ULH6Ztl2TMn8xI4JV/jbjeoVt0/Kcj/752OTa/zfc KW1qfE7488o/g0/23zg7eNtBys5Hv+zbeW25Cg6F/T+T02KWQKjF9+s2ceOTvl+6tUc92kbJG KFdBtlDO8ciM96Fdy3TomlOCPRUIu5qDgRAOpC21MRAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1466205129!19507899!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17616 invoked from network); 17 Jun 2016 23:12:10 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-9.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jun 2016 23:12:10 -0000 Received: by mail-wm0-f67.google.com with SMTP id m124so1075489wme.3 for ; Fri, 17 Jun 2016 16:12:10 -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=+EpFDBoSMv9WLMdWGf5XzCTs5cYCS9z7FpTBFZgExIo=; b=YuNOzaNUcwdPlerTG37w63ZIfbUI8Go7p2DAKBJytXfpS1Wlk8ZtNsX6g/uAFw7QBN jhLrCGTxd/KuXfTDBCfF809TdurZnQX97J2Z4b/N1BtykZFL2c1HoDX5SrbcBf0Ykgb3 FfJ1Ji/21LnaKFGm5a+Dbnp8xHmlLpNfbSjqz2fFibil2WiDGMZQrSMa4pDraQhImrGc 4gECHm7GYmmiWGPJs1Nc+NXfqVNHK/y3X8bhBVuXOBq/AXcbWQiBOJ3+Iu1+FHtYu/Lw oBojPMbjKy4GNIcF7ZR4YLuA87w68n4w2werUnNQsUpImN/qntKvbBcOqhxgVmR5iCNF e9DQ== 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=+EpFDBoSMv9WLMdWGf5XzCTs5cYCS9z7FpTBFZgExIo=; b=W0ynEaivv5fjKARIbAnVGaZlPv7O9+1NKjMK3mSlnDWyscDhNgzBjsD4yqEKntkJle vpyd++2aS7UTnhxSQfgH7Fu8FXyOeuxr1k4hvpv7y5IBca94FY7q6m8v/Orc8pm3WLKI VcebGUiNJvkNGZdkw8PCEl0aijo91C/kG42EpFUlthNsju1Y8yr6Aq72WDygzkJKPshB n7sJkoaJXNcGFKzd5TpVRWKbpBQDhpOYS5YRzy745rw6E+Yg8KmOcL9xinV4SdP1QKuw epkh5iXCOVG1FllJ0ZLYOBQepfi3RXuxqxOEHoPi8F1f/hPw9+I/rZ5ThZPIWpMHtOku zSxw== X-Gm-Message-State: ALyK8tIJe7ccjUGqRLsU9AYXhphGG3lvBVsLD+71HDteotvA1yuQRId5dCsCxWk/m1RE+w== X-Received: by 10.195.11.163 with SMTP id ej3mr4834773wjd.130.1466205129763; Fri, 17 Jun 2016 16:12:09 -0700 (PDT) Received: from Solace.fritz.box (net-93-65-149-191.cust.vodafonedsl.it. [93.65.149.191]) by smtp.gmail.com with ESMTPSA id g3sm50911913wjb.47.2016.06.17.16.12.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 16:12:09 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Sat, 18 Jun 2016 01:12:07 +0200 Message-ID: <146620512780.29766.17654986428277031886.stgit@Solace.fritz.box> In-Reply-To: <146620492155.29766.10321123657058307698.stgit@Solace.fritz.box> References: <146620492155.29766.10321123657058307698.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Anshul Makkar , George Dunlap , David Vrabel Subject: [Xen-devel] [PATCH 07/19] xen: credit2: prevent load balancing to go mad if time goes backwards 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-Virus-Scanned: ClamAV using ClamSMTP This really should not happen, but: 1. it does happen! Investigation is ongoing here: http://lists.xen.org/archives/html/xen-devel/2016-06/msg00922.html 2. even when 1 will be fixed it makes sense and is easy enough to have a 'safety catch' for it. The reason why this is particularly bad for Credit2 is that negative values of delta mean out of scale high load (because of the conversion to unsigned). This, for instance in the case of runqueue load, results in a runqueue having its load updated to values of the order of 10000% or so, which in turns means that the load balancer will migrate everything off from the pCPUs in the runqueue, and leave them idle until the load gets back to something sane... which may indeed take a while! This is not a fix for the problem of time going backwards. In fact, if that happens a lot, load tracking accuracy is still compromized, but at least the effect is a lot less bad than before. Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Anshul Makkar Cc: David Vrabel --- xen/common/sched_credit2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 50f8dfd..b73d034 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -404,6 +404,12 @@ __update_runq_load(const struct scheduler *ops, else { delta = now - rqd->load_last_update; + if ( unlikely(delta < 0) ) + { + d2printk("%s: Time went backwards? now %"PRI_stime" llu %"PRI_stime"\n", + __func__, now, rqd->load_last_update); + delta = 0; + } rqd->avgload = ( ( delta * ( (unsigned long long)rqd->load << prv->load_window_shift ) ) @@ -455,6 +461,12 @@ __update_svc_load(const struct scheduler *ops, else { delta = now - svc->load_last_update; + if ( unlikely(delta < 0) ) + { + d2printk("%s: Time went backwards? now %"PRI_stime" llu %"PRI_stime"\n", + __func__, now, svc->load_last_update); + delta = 0; + } svc->avgload = ( ( delta * ( (unsigned long long)vcpu_load << prv->load_window_shift ) )