From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Anshul Makkar <anshul.makkar@citrix.com>,
George Dunlap <george.dunlap@citrix.com>
Subject: [PATCH v2 1/2] xen: credit2: fix two s_time_t handling issues in load balancing
Date: Tue, 19 Jul 2016 17:33:57 +0200 [thread overview]
Message-ID: <146894243783.483.7419666066796617565.stgit@Solace.fritz.box> (raw)
In-Reply-To: <146894226840.483.8554580913887484141.stgit@Solace.fritz.box>
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.
Spotted by Coverity.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
Cc: George Dunlap <george.dunlap@citrix.com>
Cc: Anshul Makkar <anshul.makkar@citrix.com>
---
Changed from v1:
* fixed a '> 0' which wanted to be '>= 0' in the ASSERT()-s;
* cite Coverity in the changelog.
---
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..a55240f 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)) )
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-19 15:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 15:33 [PATCH v2 0/2] xen: Credit2: fix two issues from recently committed series Dario Faggioli
2016-07-19 15:33 ` Dario Faggioli [this message]
2016-07-20 9:33 ` [PATCH v2 1/2] xen: credit2: fix two s_time_t handling issues in load balancing George Dunlap
2016-07-19 15:34 ` [PATCH v2 2/2] xen: credit2: fix potential issues in csched2_cpu_pick with tracing enabled Dario Faggioli
2016-07-20 9:47 ` George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=146894243783.483.7419666066796617565.stgit@Solace.fritz.box \
--to=dario.faggioli@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=anshul.makkar@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).