From patchwork Fri Jul 22 12:04:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9243419 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 7DEBD602F0 for ; Fri, 22 Jul 2016 12:09:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E8B61FEBD for ; Fri, 22 Jul 2016 12:09:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62D0127FA4; Fri, 22 Jul 2016 12:09: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 A08801FEBD for ; Fri, 22 Jul 2016 12:09:56 +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 1bQZCN-0007cY-0O; Fri, 22 Jul 2016 12:04:59 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQZCM-0007cS-Cz for xen-devel@lists.xenproject.org; Fri, 22 Jul 2016 12:04:58 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id AC/95-10347-9EB02975; Fri, 22 Jul 2016 12:04:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRWlGSWpSXmKPExsXiVRvkpPuSe1K 4wb8jXBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bzT2vYClr4K9afesbSwNjL08XIxSEkMI1R orOzgxXEYRGYyirR/HM9mCMhsJFVYt/mFWxdjJxATozE7VnbGSHsColP8+6yg9hCAioSN7evY oIYtZRJ4vDVBSwgCWEBPYkjR3+wQ9j2Ej/2bQBrZhMwkHizYy8riC0ioCRxb9VkoGYODmYBP4 kpXSUgYRYBVYnn/7aB7eUV8JaY//wE2BhRATmJlZdbWCHighInZz5hgWjVlFi/Sx8kzCwgL7H 97RzmCYxCs5BUzUKomoWkagEj8ypG9eLUorLUIl1LvaSizPSMktzEzBxdQwNTvdzU4uLE9NSc xKRiveT83E2MwGBmAIIdjGtbnQ8xSnIwKYnyqrFMChfiS8pPqcxILM6ILyrNSS0+xKjBwSEw4 ezc6UxSLHn5ealKErwKwKgREixKTU+tSMvMAcYbTKkEB4+SCO9MkDRvcUFibnFmOkTqFKMux5 ap99YyCYHNkBLnfcwFVCQAUpRRmgc3Ahb7lxhlpYR5GYEOFOIpSC3KzSxBlX/FKM7BqCTM+xl kCk9mXgncpldARzABHTFHoB/kiJJEhJRUA2Pe/DcCf03v3Myaaj3HpVPgeMPiNOUiUUGlVzGP 7zxr+lr7er+wm/UUtatybOwXjvXomE3+dfKT3n+t0K61zJfyivafeXNBfdUpDgsFiQ0OT9YrZ udec1C8XqvRr7x8bVuDy+SowtfBK/WX5rJG2Tdv5Tfkm6LM5rM1x+V7o8vNWTEbeKy1fZRYij MSDbWYi4oTAUFM1eH4AgAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1469189097!35282947!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 19521 invoked from network); 22 Jul 2016 12:04:57 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Jul 2016 12:04:57 -0000 Received: by mail-wm0-f66.google.com with SMTP id i5so5915101wmg.2 for ; Fri, 22 Jul 2016 05:04:57 -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:user-agent:mime-version :content-transfer-encoding; bh=ihmHID4gvcpD0DxwkV0ddhUMi4jWTOOqGbC2CvuzDug=; b=q7wTNQ2+uiGdtuvSZ0Wgwlotbg93M1HAHFx3T4RQTsbGKlchPXFDW+rNHX0kmes/Rh TVwOng/tM4PPyVNpilG3y9XWg7bHnB8yQvXmCE1su4XUJDNhZoJcof9ttHrAnRCBJ1wX OzEi6Zn5Vta7jP85icOeBjfBshjl/23gTtLTnLFrfETGpOy7ofMm+hdkjKPJfKr34xY2 5JVDJejY6MA2iX0hbPVd5Lsi9dXHyk27yhYKjR3qu/hfIKCp2hgQsygBC3oQQjJh2ZFN Aum74GrbGvUzLlYWpJaJAlMST0y6E+JxtMx/DtIh0ktzP21YbjoF6LF5fC4pdHe5LnZ+ jgHw== 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 :user-agent:mime-version:content-transfer-encoding; bh=ihmHID4gvcpD0DxwkV0ddhUMi4jWTOOqGbC2CvuzDug=; b=XCr5tB06qKLnL+fzTR1gduqsFR0zImFeJ03eNmXB4TI8xxNlaESBHWejHRYcwZdo+I EIJ4teRyiwfm+rQQGTaoiahvPwjQyMWAdG/fX+Nn5rUabwHlM8CfeWFbXzuRwrlA0wjV ELQESRJ/Q0xvaQNiHqx1aPisJ6uRWtRcgWr2E91XvT1/bQmlOoUOHiZ8mimy89BNB5DP W3p2bAz3OURqyIY7cLu6KlfZHwCI4a5LYJ0bhSBFRi2TE7InkeWAV0aHbO+hzP60TxoP CJUjwmr8ZCoxiqvVjbPkZELIO86027NODphdOijj9zKD+y1m3U8b1MV3+sDSm1+VrtEf EcnQ== X-Gm-Message-State: ALyK8tLoW/KfyV7jxU8oSwCZKvMAF+riQFIqHI7xHe6ZWhLwW3cua72ptDRh8MMRpwtSVQ== X-Received: by 10.28.95.67 with SMTP id t64mr23780847wmb.99.1469189096705; Fri, 22 Jul 2016 05:04:56 -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 b186sm12270525wmg.23.2016.07.22.05.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 05:04:55 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 22 Jul 2016 14:04:53 +0200 Message-ID: <146918909364.19443.6394900696027710502.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Wei Liu Subject: [Xen-devel] [PATCH] xen: credit2: don't let b_avgload go negative. 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 The ASSERT() made effective by b5b5876619bd8ec2e ("xen: credit2: fix two s_time_t handling issues in load balancing") triggers for b_avgload (spotted by OSSTest). b_avgload is where we store the prediction of how the load of a runqueue will look like in the medium to long term, because of a vcpu being added to or removed from there. On vcpu removal, saturate down b_avgload to zero, as it makes very few sense to predict that the load of a runqueue will at some point become negative! Signed-off-by: Dario Faggioli Acked-by: George Dunlap --- Cc: George Dunlap Cc: Wei Liu --- xen/common/sched_credit2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index b92226c..1d79de0 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1323,14 +1323,16 @@ runq_assign(const struct scheduler *ops, struct vcpu *vc) static void __runq_deassign(struct csched2_vcpu *svc) { + struct csched2_runqueue_data *rqd = svc->rqd; + ASSERT(!__vcpu_on_runq(svc)); ASSERT(!(svc->flags & CSFLAG_scheduled)); list_del_init(&svc->rqd_elem); - update_max_weight(svc->rqd, 0, svc->weight); + update_max_weight(rqd, 0, svc->weight); /* Expected new load based on removing this vcpu */ - svc->rqd->b_avgload -= svc->avgload; + rqd->b_avgload = max_t(s_time_t, rqd->b_avgload - svc->avgload, 0); svc->rqd = NULL; } @@ -1590,7 +1592,7 @@ csched2_cpu_pick(const struct scheduler *ops, struct vcpu *vc) if ( rqd == svc->rqd ) { if ( cpumask_intersects(vc->cpu_hard_affinity, &rqd->active) ) - rqd_avgload = rqd->b_avgload - svc->avgload; + rqd_avgload = max_t(s_time_t, rqd->b_avgload - svc->avgload, 0); } else if ( spin_trylock(&rqd->lock) ) {