From patchwork Tue Jul 19 12:07:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9236895 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 472FB6075D for ; Tue, 19 Jul 2016 12:09:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382AE205A4 for ; Tue, 19 Jul 2016 12:09:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AE9126929; Tue, 19 Jul 2016 12:09:27 +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 3B7C9205A4 for ; Tue, 19 Jul 2016 12:09:24 +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 1bPTnn-0002Bg-OV; Tue, 19 Jul 2016 12:07:07 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPTnn-0002BN-0G for xen-devel@lists.xenproject.org; Tue, 19 Jul 2016 12:07:07 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 95/F6-13744-AE71E875; Tue, 19 Jul 2016 12:07:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsXiVRvkrPtSvC/ cYE+/ocX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHtwkGWggUCFZevTWBsYHzG08XIySEkMJ1R onWDdBcjFweLwBpWiRVN95lAHAmBS6wSM45OZAapkhCIkdjZsJAJwi6XWL3sKhtEt4rEze2rw BqEBJYySeyeM5sFJCEsoCdx5OgPdgg7TOLdqU9gcTYBA4k3O/aygtgiAkoS91ZNBmtmFmhmlF h+cy7YNhYBVYlXu7aAbeMV8JGYt+0HkM3BwQlk/9vhB7HYW2Lr2xlgc0QF5CRWXm5hhSgXlDg 58wkLSDmzgKbE+l36IGFmAXmJ7W/nME9gFJmFpGoWQtUsJFULGJlXMaoXpxaVpRbpGuklFWWm Z5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgQGPwMQ7GBc9tfpEKMkB5OSKK+qaG+4EF9Sf kplRmJxRnxRaU5q8SFGDQ4OgQln505nkmLJy89LVZLgvSLWFy4kWJSanlqRlpkDjE+YUgkOHi URXk5gjArxFhck5hZnpkOkTjHqcmyZem8tkxDYDClx3tUgMwRAijJK8+BGwFLFJUZZKWFeRqA DhXgKUotyM0tQ5V8xinMwKgnz7gGZwpOZVwK36RXQEUxARxiodoMcUZKIkJJqYIw6v/ed/Imj N889fmp25ujBQw/S/bwt3yQdet/o5pbTwXnD5mTUv6UaL+XKws0P3fJfkOxrcuxd/ZEpVx437 M/cOzHy8+PygMPJa52/Hmcy+PNendXzpZ4og6j6pag/s59+WuJS1Rb8v2HuzTU2Ts8ZD2lUNw jt7va/8iq1fn5MQnK9ebVVlq8SS3FGoqEWc1FxIgCYk6y8EAMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1468930025!10699276!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.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51963 invoked from network); 19 Jul 2016 12:07:05 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 19 Jul 2016 12:07:05 -0000 Received: by mail-wm0-f67.google.com with SMTP id x83so2588321wma.3 for ; Tue, 19 Jul 2016 05:07:05 -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=a353eUROXlCblXT1EzIg1dKoK7K7YwqubnjPJiYvZTA=; b=qYWsO/xOAPRCyCxhZlwCqyGQGAeEN+yUoqmXz5YN5A5sOarckQv5rEGQknZ3fxlL1l WJEQwrwR19h3H2JLrGxgKi6HF0uqaNAgF55DrQiRH/LixM3z47pz/ioer5jLLDeWbQOg FDkYYeWY2pLWS7CHNs0D673y3/wEYvEmRgJRrBxiD+HxhEqka315w7/eBNx87rv0IqUN 7iwM9oRmyV5j9Ihd5+j47XTiJg8W9gbmuI1zcN3IMy4WOKXxaE0ABjYvlTRkfxAL01BU RbGQeqRuJL5FwIWrqSdJz1cgOWSli5ImSikhtDw3KrDyqHozvTxr24dHCERCWvrDVKMa +J0w== 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=a353eUROXlCblXT1EzIg1dKoK7K7YwqubnjPJiYvZTA=; b=D6NACRm3kbDRlB7IdLrboCIuDI284aGiGHN4BDv8rsAH0q3xJCgT+2gVRTNB54Ktjo xW8eY9YR3s/PrDofx/PaZAvtlUVFS9urT9BbG5UxdZh3SU20BGvySmmqkR1eGAk/5SDh xZbNB9Qj8sA0vAl9p1apsAUPeKf+sPj32pXnJWHjyyFRRu6l/jIhXiEqyht4uZRjD2gr CmzklLXChCeZxOCXFoTwnWZQ0+Ef9/6NWajeXraJvRLTI0b/4UJQnpWmWN3SnTj6+oMe yYXFNf6Qsdruqkf7MTFZ5Q6nX3fFtMZIYCAPs05ncGW6zHzmA3N49NOeBRBAdTQZqhde SECA== X-Gm-Message-State: ALyK8tLEe5y8WfpdWLqqPYgb+Foztrlvz5jZnSl6+rPoSkDIPMyorlij/uSf68cA1JPctA== X-Received: by 10.28.0.203 with SMTP id 194mr3964814wma.29.1468930025188; Tue, 19 Jul 2016 05:07:05 -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 p126sm22383123wmp.13.2016.07.19.05.07.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 05:07:04 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Tue, 19 Jul 2016 14:07:03 +0200 Message-ID: <146893002307.30642.10136248649438820718.stgit@Solace.fritz.box> In-Reply-To: <146892985892.30642.2392453881110942183.stgit@Solace.fritz.box> References: <146892985892.30642.2392453881110942183.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Andrew Cooper , Anshul Makkar , George Dunlap Subject: [Xen-devel] [PATCH 1/2] xen: credit2: fix two s_time_t handling issues in load balancing 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 both introduced in d205f8a7f48e2ec ("xen: credit2: rework load tracking logic"). First, in __update_runq_load(), the ASSERT() was actually useless. Let's instead check that the computed value of the load has not overflowed (and hence gone negative). While there, do that in __update_svc_load() as well. Second, in balance_load(), cpus_max needs being extended in order to be correctly shifted, and the result compared with an s_time_t value, without risking loosing info. Signed-off-by: Dario Faggioli Reported-by: Andrew Cooper --- Cc: George Dunlap Cc: Anshul Makkar --- xen/common/sched_credit2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index b33ba7a..3d3e4ae 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -656,7 +656,8 @@ __update_runq_load(const struct scheduler *ops, rqd->load += change; rqd->load_last_update = now; - ASSERT(rqd->avgload <= STIME_MAX && rqd->b_avgload <= STIME_MAX); + /* Overflow, capable of making the load look negative, must not occur. */ + ASSERT(rqd->avgload > 0 && rqd->b_avgload > 0); if ( unlikely(tb_init_done) ) { @@ -714,6 +715,9 @@ __update_svc_load(const struct scheduler *ops, } svc->load_last_update = now; + /* Overflow, capable of making the load look negative, must not occur. */ + ASSERT(svc->avgload > 0); + if ( unlikely(tb_init_done) ) { struct { @@ -1742,7 +1746,7 @@ retry: * If we're under 100% capacaty, only shift if load difference * is > 1. otherwise, shift if under 12.5% */ - if ( load_max < (cpus_max << prv->load_precision_shift) ) + if ( load_max < ((s_time_t)cpus_max << prv->load_precision_shift) ) { if ( st.load_delta < (1ULL << (prv->load_precision_shift + opt_underload_balance_tolerance)) )