From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Anshul Makkar <anshul.makkar@citrix.com>
Subject: [PATCH v2 08/10] xen: credit2: don't miss accounting while doing a credit reset.
Date: Thu, 09 Feb 2017 14:59:15 +0100 [thread overview]
Message-ID: <148664875514.595.468730348267549995.stgit@Solace.fritz.box> (raw)
In-Reply-To: <148664844741.595.10506268024432565895.stgit@Solace.fritz.box>
A credit reset basically means going through all the
vCPUs of a runqueue and altering their credits, as a
consequence of a 'scheduling epoch' having come to an
end.
Blocked or runnable vCPUs are fine, all the credits
they've spent running so far have been accounted to
them when they were scheduled out.
But if a vCPU is running on a pCPU, when a reset event
occurs (on another pCPU), that does not get properly
accounted. Let's therefore begin to do so, for better
accuracy and fairness.
In fact, after this patch, we see this in a trace:
csched2:schedule cpu 10, rq# 1, busy, not tickled
csched2:burn_credits d1v5, credit = 9998353, delta = 202996
runstate_continue d1v5 running->running
...
csched2:schedule cpu 12, rq# 1, busy, not tickled
csched2:burn_credits d1v6, credit = -1327, delta = 9999544
csched2:reset_credits d0v13, credit_start = 10500000, credit_end = 10500000, mult = 1
csched2:reset_credits d0v14, credit_start = 10500000, credit_end = 10500000, mult = 1
csched2:reset_credits d0v7, credit_start = 10500000, credit_end = 10500000, mult = 1
csched2:burn_credits d1v5, credit = 201805, delta = 9796548
csched2:reset_credits d1v5, credit_start = 201805, credit_end = 10201805, mult = 1
csched2:burn_credits d1v6, credit = -1327, delta = 0
csched2:reset_credits d1v6, credit_start = -1327, credit_end = 9998673, mult = 1
Which shows how d1v5 actually executed for ~9.796 ms,
on pCPU 10, when reset_credit() is executed, on pCPU
12, because of d1v6's credits going below 0.
Without this patch, this 9.796ms are not accounted
to anyone. With this patch, d1v5 is charged for that,
and its credits drop down from 9796548 to 201805.
And this is important, as it means that it will
begin the new epoch with 10201805 credits, instead
of 10500000 (which he would have, before this patch).
Basically, we were forgetting one round of accounting
in epoch x, for the vCPUs that are running at the time
the epoch ends. And this meant favouring a little bit
these same vCPUs, in epoch x+1, providing them with
the chance of execute longer than their fair share.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Anshul Makkar <anshul.makkar@citrix.com>
---
xen/common/sched_credit2.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index bfb4891..8057abf 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1341,18 +1341,28 @@ static void reset_credit(const struct scheduler *ops, int cpu, s_time_t now,
list_for_each( iter, &rqd->svc )
{
+ unsigned int svc_cpu;
struct csched2_vcpu * svc;
int start_credit;
svc = list_entry(iter, struct csched2_vcpu, rqd_elem);
+ svc_cpu = svc->vcpu->processor;
ASSERT(!is_idle_vcpu(svc->vcpu));
ASSERT(svc->rqd == rqd);
+ /*
+ * If svc is running, it is our responsibility to make sure, here,
+ * that the credit it has spent so far get accounted.
+ */
+ if ( svc->vcpu == curr_on_cpu(svc_cpu) )
+ burn_credits(rqd, svc, now);
+
start_credit = svc->credit;
- /* And add INIT * m, avoiding integer multiplication in the
- * common case. */
+ /*
+ * Add INIT * m, avoiding integer multiplication in the common case.
+ */
if ( likely(m==1) )
svc->credit += CSCHED2_CREDIT_INIT;
else
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-09 13:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 13:58 [PATCH v2 00/10] xen: credit2: improve style, and tracing; fix two bugs Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 01/10] xen: sched: harmonize debug dump output among schedulers Dario Faggioli
2017-02-15 10:17 ` George Dunlap
2017-02-15 10:31 ` Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 02/10] xen: credit2: clear bit instead of skip step in runq_tickle() Dario Faggioli
2017-02-15 10:21 ` George Dunlap
2017-02-09 13:58 ` [PATCH v2 03/10] xen: credit2: improve comments' style and definition of CSFLAG-s Dario Faggioli
2017-02-15 10:44 ` George Dunlap
2017-02-09 13:58 ` [PATCH v2 04/10] xen: credit2: make accessor helpers inline functions instead of macros Dario Faggioli
2017-02-09 14:14 ` Andrew Cooper
2017-02-09 14:34 ` Jan Beulich
2017-02-09 14:36 ` Jan Beulich
2017-02-09 15:33 ` Dario Faggioli
2017-02-15 10:49 ` George Dunlap
2017-02-24 18:26 ` Dario Faggioli
2017-02-09 13:58 ` [PATCH v2 05/10] xen: credit2: tidy up functions names by removing leading '__' Dario Faggioli
2017-02-15 13:57 ` George Dunlap
2017-02-24 18:32 ` Dario Faggioli
2017-02-09 13:59 ` [PATCH v2 06/10] xen: credit2: group the runq manipulating functions Dario Faggioli
2017-02-15 14:42 ` George Dunlap
2017-02-27 18:25 ` Dario Faggioli
2017-02-09 13:59 ` [PATCH v2 07/10] xen: credit2: always mark a tickled pCPU as... tickled! Dario Faggioli
2017-02-09 23:48 ` Dario Faggioli
2017-02-15 14:55 ` George Dunlap
2017-02-09 13:59 ` Dario Faggioli [this message]
2017-02-15 15:07 ` [PATCH v2 08/10] xen: credit2: don't miss accounting while doing a credit reset George Dunlap
2017-02-09 13:59 ` [PATCH v2 09/10] xen/tools: tracing: trace (Credit2) runq traversal Dario Faggioli
2017-02-15 15:31 ` George Dunlap
2017-02-24 18:48 ` Dario Faggioli
2017-02-09 13:59 ` [PATCH v2 10/10] xen/tools: tracing: always report how long next slice will be Dario Faggioli
2017-02-15 15:40 ` George Dunlap
2017-02-27 18:12 ` Dario Faggioli
2017-02-09 14:37 ` [PATCH v2 00/10] xen: credit2: improve style, and tracing; fix two bugs Jan Beulich
2017-02-09 15:29 ` Dario Faggioli
2017-02-15 16:03 ` 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=148664875514.595.468730348267549995.stgit@Solace.fritz.box \
--to=dario.faggioli@citrix.com \
--cc=anshul.makkar@citrix.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).