From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH] xen: credit2: don't let b_avgload go negative.
Date: Fri, 22 Jul 2016 14:04:53 +0200 [thread overview]
Message-ID: <146918909364.19443.6394900696027710502.stgit@Solace.fritz.box> (raw)
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 <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
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) )
{
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2016-07-22 12:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-22 12:04 Dario Faggioli [this message]
2016-07-22 12:34 ` [PATCH] xen: credit2: don't let b_avgload go negative George Dunlap
2016-07-22 12:35 ` Wei Liu
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=146918909364.19443.6394900696027710502.stgit@Solace.fritz.box \
--to=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=wei.liu2@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).