From patchwork Fri Jul 15 14:49:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9232155 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 9E18E6075D for ; Fri, 15 Jul 2016 14:51:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FF0527AC2 for ; Fri, 15 Jul 2016 14:51:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8497327F94; Fri, 15 Jul 2016 14:51:46 +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 211FF27AC2 for ; Fri, 15 Jul 2016 14:51:45 +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 1bO4Qc-0005ji-SD; Fri, 15 Jul 2016 14:49:22 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bO4Qb-0005jN-Tk for xen-devel@lists.xenproject.org; Fri, 15 Jul 2016 14:49:22 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id 4F/B1-10347-1F7F8875; Fri, 15 Jul 2016 14:49:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRWlGSWpSXmKPExsXiVRvkpPvhe0e 4wbI5uhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0br8q+MBSdEKvZ/b2VsYOwW6GLk4hASmMEo cWRvDzuIwyKwhlXidcNuMEdC4BKrxP/ms0AOJ5ATIzF3WiOUXS5x9ehMJhBbSEBF4ub2VUwQo xYxSdy8spQFJCEsoCdx5OgPdgg7QeLRxzVgcTYBA4k3O/aygtgiAkoS91ZNBhvELLCQUaK5PR DEZhFQlei9/Aisl1fAW+Lpyg9g9ZwCvhLP70PMERLwkXhxdzZYr6iAnMTKyy2sEPWCEidnPgG q4QCaqSmxfpc+xHh5ie1v5zBPYBSZhaRqFkLVLCRVCxiZVzFqFKcWlaUW6Rqa6CUVZaZnlOQm ZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBEYAAxDsYDx72vMQoyQHk5Io78aUjnAhvqT8lMqMx OKM+KLSnNTiQ4waHBwCE87Onc4kxZKXn5eqJMH77BtQnWBRanpqRVpmDjBGYUolOHiURHjfga R5iwsSc4sz0yFSpxh1ObZMvbeWSQhshpQ470KQIgGQoozSPLgRsHRxiVFWSpiXEehAIZ6C1KL czBJU+VeM4hyMSsK8m0Cm8GTmlcBtegV0BBPQEdbm7SBHlCQipKQaGMNqg9r8dDXTZk1I+smg fu8NY4WAtGAwE5PBn2iZ9mX/tr2RCNwjeV5qcYLdr9qa5YcMVZgFxNWYIw/ZCkvfmh/bEH5Q4 tWS7UeZxLe6OUeHuyZ3Lz49y3oaU0vpmWvdLgZCbNPK7/w5t4hbsD/CY7XU4k1/hSef12wPVZ 2v8eFXyfNDXTNVlFiKMxINtZiLihMBHiItLBIDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1468594160!33820923!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19688 invoked from network); 15 Jul 2016 14:49:20 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-2.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 15 Jul 2016 14:49:20 -0000 Received: by mail-wm0-f66.google.com with SMTP id q128so2480382wma.1 for ; Fri, 15 Jul 2016 07:49:20 -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=qjuD3tNBDnX2d7PZJot8Gxkua8gOfu+r9Ps/avGuEQ4=; b=R6vyiToQcSSAinBi/gFWK60WiSD2v8CQKTUPcem7o5LRK4EbWCLeg6/QCXYcWSXE0G DgPhUopld9mCr8/OsJFAWf5haPs9KQZlOGF8rlO/PO2Zz3Mkbq3OX77dfaUeaaK3VULP RoGBdRSku/xPp5BlRBwgZ6u5+Ywe2/HoaH90Id5dm3xgAq/Rs48YPTDyBpM3m57lXeYF Fk/n/0j5aDpPhLD0NmIRs/PXQ8+v9/MbuhocQ5hHd6CeGfBPYWrHJOnExapjHQNjoC6/ kjo+suWXFoRBWe2wU4SHIc0N/EgQXl5xs1QVcWQLdF2H91nz1zzUIHOmpao4u6s5S3DA XNWw== 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=qjuD3tNBDnX2d7PZJot8Gxkua8gOfu+r9Ps/avGuEQ4=; b=fLAGYoG+ZiAAe4JY8x5gD+KGAqLMoem+SRrfmv7lEV/F4D+D+1XCXEMdZX7M3C+R/r fQxsKLBcQUy0kZv21YCpi6yz8IeZB9U1SJVERI579jW8ABBSVNa2z+OuJIn0fuGh4BbD FE61D71h4cVewXVsmbyQLgXmh+eEzyVdAXrEayJOHP+VD9Y0t9OAn96ZByn6DNWvcPj2 zYpi3gz40zCz4FUHMitN/Wazxcz6ckq1j7UVvqAutXnNGVho615XNTVCQgQu2eWaDrS+ SiXuZxF4s8QjHU5RCNjI3Tx0AsqtEUQIGmYXJnApoeFo6D4mTslBVLmU9H9Ka7xFQ+jD LVgQ== X-Gm-Message-State: ALyK8tLR26OiMDBX8VHA7QQnwXQkHZBFcAlqN0+C5mVXfs6IWhZCe4Tjv0zzTI21jQ6tKQ== X-Received: by 10.195.2.37 with SMTP id bl5mr1140851wjd.11.1468594160309; Fri, 15 Jul 2016 07:49:20 -0700 (PDT) Received: from Solace.fritz.box (net-188-217-84-158.cust.vodafonedsl.it. [188.217.84.158]) by smtp.gmail.com with ESMTPSA id i8sm6268326wmg.21.2016.07.15.07.49.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2016 07:49:19 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 15 Jul 2016 16:49:18 +0200 Message-ID: <146859415833.10217.1295698882153856098.stgit@Solace.fritz.box> In-Reply-To: <146859397891.10217.10155969474613302167.stgit@Solace.fritz.box> References: <146859397891.10217.10155969474613302167.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Anshul Makkar , George Dunlap , Jan Beulich , David Vrabel Subject: [Xen-devel] [PATCH v2 02/11] 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! Some more info here: http://lists.xen.org/archives/html/xen-devel/2016-06/msg00922.html 2. independently from 1, it makes sense and is easy enough to have a 'safety catch'. 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: Jan Beulich Cc: Anshul Makkar Cc: David Vrabel --- Leaving the patch as it was in v1, for reasons explained in these messages, by both George and me: * * * <1467888805.23985.62.camel@citrix.com> --- 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 7e572bf..6cb06e8 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 ) )