From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v2 2/2] xen: credit1: avoid boosting vCPUs being "just" migrated
Date: Fri, 12 Feb 2016 10:37:05 +0100 [thread overview]
Message-ID: <20160212093705.16002.46867.stgit@Solace.station> (raw)
In-Reply-To: <20160212093501.16002.32635.stgit@Solace.station>
Moving a vCPU to a different pCPU means offlining it and
then waking it up, on the new pCPU. Credit1 grants BOOST
priority to vCPUs that wakes up, with the aim of improving
I/O latency. The net effect of this all is that vCPUs get
boosted when migrating, which shouldn't happen.
For instance, this causes scheduling anomalies and,
potentially, performance problems, as reported here:
http://lists.xen.org/archives/html/xen-devel/2015-10/msg02851.html
This patch fixes this by noting down (by means of a flag)
the fact that the vCPU is about to undergo a migration.
This way we can tell, later, during a wakeup, whether the
vCPU is migrating or unblocking, and decide whether or
not to apply the boosting.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>
---
Changes from v1:
* rewritten, following suggestion got during review: there
are no wakeup flags any longer, and all is done in sched_credit.c
by setting a flag in csched_cpu_pick() and testing (and
cleating) it in csched_vcpu_wake().
---
xen/common/sched_credit.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index 5708701..756e884 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -66,6 +66,7 @@
*/
#define CSCHED_FLAG_VCPU_PARKED 0x0 /* VCPU over capped credits */
#define CSCHED_FLAG_VCPU_YIELD 0x1 /* VCPU yielding */
+#define CSCHED_FLAG_VCPU_MIGRATING 0x2 /* VCPU may have moved to a new pcpu */
/*
@@ -787,6 +788,16 @@ _csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t commit)
static int
csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc)
{
+ struct csched_vcpu *svc = CSCHED_VCPU(vc);
+
+ /*
+ * We have been called by vcpu_migrate() (in schedule.c), as part
+ * of the process of seeing if vc can be migrated to another pcpu.
+ * We make a note about this in svc->flags so that later, in
+ * csched_vcpu_wake() (still called from vcpu_migrate()) we won't
+ * get boosted, which we don't deserve as we are "only" migrating.
+ */
+ set_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags);
return _csched_cpu_pick(ops, vc, 1);
}
@@ -1022,11 +1033,18 @@ csched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc)
* more CPU resource intensive VCPUs without impacting overall
* system fairness.
*
- * The one exception is for VCPUs of capped domains unpausing
- * after earning credits they had overspent. We don't boost
- * those.
+ * There are two cases, when we don't want to boost:
+ * - VCPUs that are waking up after a migration, rather than
+ * after having block;
+ * - VCPUs of capped domains unpausing after earning credits
+ * they had overspent.
+ *
+ * Note that checking whether we are "only" migrating must be
+ * done up front, as we do not want the clearing of the bit we
+ * set in csched_cpu_pick() to be short-circuited away.
*/
- if ( svc->pri == CSCHED_PRI_TS_UNDER &&
+ if ( !__test_and_clear_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags) &&
+ svc->pri == CSCHED_PRI_TS_UNDER &&
!test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) )
{
TRACE_2D(TRC_CSCHED_BOOST_START, vc->domain->domain_id, vc->vcpu_id);
next prev parent reply other threads:[~2016-02-12 9:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 9:36 [PATCH 0/2] xen: sched: Credit1 shouldn't boost vcpus being migrated Dario Faggioli
2016-02-12 9:36 ` [PATCH v2 1/2] xen: credit1: trace vCPU boost/unboost Dario Faggioli
2016-02-12 9:37 ` Dario Faggioli [this message]
2016-02-12 9:50 ` [PATCH v2 2/2] xen: credit1: avoid boosting vCPUs being "just" migrated Jan Beulich
2016-02-12 10:50 ` Dario Faggioli
2016-02-12 14:16 ` Dario Faggioli
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=20160212093705.16002.46867.stgit@Solace.station \
--to=dario.faggioli@citrix.com \
--cc=JBeulich@suse.com \
--cc=george.dunlap@eu.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).