From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Subject: [PATCH v2 01/10] xen: credit1: return the 'time remaining to the limit' as next timeslice.
Date: Fri, 30 Sep 2016 04:53:25 +0200 [thread overview]
Message-ID: <147520400560.22544.6704334115981723287.stgit@Solace.fritz.box> (raw)
In-Reply-To: <147520253247.22544.10673844222866363947.stgit@Solace.fritz.box>
If vcpu x has run for 200us, and sched_ratelimit_us is
1000us, continue running x _but_ return 1000us-200us as
the next time slice. This way, next scheduling point will
happen in 800us, i.e., exactly at the point when x crosses
the threshold, and can be descheduled (if appropriate).
Right now (without this patch), we're always returning
sched_ratelimit_us (1000us, in the example above), which
means we're (potentially) allowing x to run more than
it should have been able to.
Note that, however, in order to avoid setting timers to very
short intervals, which is part of the purpose of rate limiting,
we never use a time slice smaller than a well defined threshold.
Such threshold (CSCHED_MIN_TIMER defined in this patch) is, in
general independent from rate limiting, but it looks a good idea
to set it to the minimum possible ratelimiting value.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
---
Changes from v1:
* introduce CSCHED_MIN_TIMER, as agreed during review.
---
xen/common/sched_credit.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index b63efac..4d84b5f 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -51,6 +51,8 @@
/* Default timeslice: 30ms */
#define CSCHED_DEFAULT_TSLICE_MS 30
#define CSCHED_CREDITS_PER_MSEC 10
+/* Never set a timer shorter than this value. */
+#define CSCHED_MIN_TIMER XEN_SYSCTL_SCHED_RATELIMIT_MIN
/*
@@ -1811,7 +1813,15 @@ csched_schedule(
snext = scurr;
snext->start_time += now;
perfc_incr(delay_ms);
- tslice = MICROSECS(prv->ratelimit_us);
+ /*
+ * Next timeslice must last just until we'll have executed for
+ * ratelimit_us. However, to avoid setting a really short timer, which
+ * will most likely be inaccurate and counterproductive, we never go
+ * below CSCHED_MIN_TIMER.
+ */
+ tslice = MICROSECS(prv->ratelimit_us) - runtime;
+ if ( unlikely(runtime < CSCHED_MIN_TIMER) )
+ tslice = CSCHED_MIN_TIMER;
ret.migrated = 0;
goto out;
}
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-30 2:53 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 2:53 [PATCH v2 00/10] sched: Credit1 and Credit2 improvements... but *NO* soft-affinity for Credit2! Dario Faggioli
2016-09-30 2:53 ` Dario Faggioli [this message]
2016-09-30 11:16 ` [PATCH v2 01/10] xen: credit1: return the 'time remaining to the limit' as next timeslice George Dunlap
2016-09-30 2:53 ` [PATCH v2 02/10] xen: credit1: don't rate limit context switches in case of yields Dario Faggioli
2016-09-30 11:18 ` George Dunlap
2016-09-30 2:53 ` [PATCH v2 03/10] xen: credit2: make tickling more deterministic Dario Faggioli
2016-09-30 11:25 ` George Dunlap
2016-09-30 2:53 ` [PATCH v2 04/10] xen: credit2: only reset credit on reset condition Dario Faggioli
2016-09-30 11:28 ` George Dunlap
2016-09-30 12:25 ` anshul makkar
2016-09-30 12:57 ` Dario Faggioli
2016-09-30 2:53 ` [PATCH v2 05/10] xen: credit2: implement yield() Dario Faggioli
2016-09-30 12:52 ` George Dunlap
2016-09-30 14:01 ` Dario Faggioli
2016-09-30 2:54 ` [PATCH v2 06/10] xen: tracing: add trace records for schedule and rate-limiting Dario Faggioli
2016-09-30 13:16 ` George Dunlap
2016-10-01 0:18 ` Meng Xu
2016-09-30 2:54 ` [PATCH v2 07/10] tools: tracing: handle more scheduling related events Dario Faggioli
2016-09-30 10:22 ` Ian Jackson
2016-09-30 2:54 ` [PATCH v2 08/10] libxl: fix coding style of credit1 parameters related functions Dario Faggioli
2016-09-30 10:24 ` Ian Jackson
2016-09-30 12:04 ` Dario Faggioli
2016-09-30 13:25 ` George Dunlap
2016-09-30 2:54 ` [PATCH v2 09/10] libxl: allow to set the ratelimit value online for Credit2 Dario Faggioli
2016-09-30 10:30 ` Ian Jackson
2016-09-30 10:33 ` George Dunlap
2016-09-30 10:35 ` Ian Jackson
2016-09-30 12:37 ` Dario Faggioli
2016-09-30 2:54 ` [PATCH v2 10/10] xl: " Dario Faggioli
2016-09-30 10:34 ` Ian Jackson
2016-09-30 15:54 ` Dario Faggioli
2016-09-30 16:02 ` Ian Jackson
2016-10-13 22:19 ` Jim Fehlig
2016-10-14 11:31 ` George Dunlap
2016-09-30 13:51 ` [PATCH v2 00/10] sched: Credit1 and Credit2 improvements... but *NO* soft-affinity for Credit2! George Dunlap
2016-09-30 14:06 ` Dario Faggioli
2016-09-30 14:10 ` George Dunlap
2016-09-30 14:12 ` 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=147520400560.22544.6704334115981723287.stgit@Solace.fritz.box \
--to=dario.faggioli@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).