aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Dunlap <george.dunlap@eu.citrix.com>2013-03-04 13:39:19 +0100
committerJan Beulich <jbeulich@suse.com>2013-03-04 13:39:19 +0100
commitc0704a8a90d3219cbbc607f5b83cd4f60371a47e (patch)
treeba83d608188a9824c4a4e0d263a6e3192f16c078
parent8b3072a050a67405022f9e7911c37ccff9c0cdb5 (diff)
downloadxen-c0704a8a90d3219cbbc607f5b83cd4f60371a47e.tar.gz
xen-c0704a8a90d3219cbbc607f5b83cd4f60371a47e.tar.bz2
xen-c0704a8a90d3219cbbc607f5b83cd4f60371a47e.zip
credit2: track residual from divisions done during accounting
This should help with under-accounting of vCPU-s running for extremly short periods of time, but becoming runnable again at a high frequency. Don't bother subtracting the residual from the runtime, as it can only ever add up to one nanosecond, and will end up being debited during the next reset interval anyway. Original-patch-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
-rw-r--r--xen/common/sched_credit2.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 804049ebe5..a7bd2ee6c0 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -21,7 +21,7 @@
#include <xen/perfc.h>
#include <xen/sched-if.h>
#include <xen/softirq.h>
-#include <asm/atomic.h>
+#include <asm/div64.h>
#include <xen/errno.h>
#include <xen/trace.h>
#include <xen/cpu.h>
@@ -205,7 +205,7 @@ struct csched_runqueue_data {
struct list_head runq; /* Ordered list of runnable vms */
struct list_head svc; /* List of all vcpus assigned to this runqueue */
- int max_weight;
+ unsigned int max_weight;
cpumask_t idle, /* Currently idle */
tickled; /* Another cpu in the queue is already targeted for this one */
@@ -244,7 +244,8 @@ struct csched_vcpu {
struct csched_dom *sdom;
struct vcpu *vcpu;
- int weight;
+ unsigned int weight;
+ unsigned int residual;
int credit;
s_time_t start_time; /* When we were scheduled (used for credit) */
@@ -271,11 +272,19 @@ struct csched_dom {
/*
* Time-to-credit, credit-to-time.
+ *
+ * We keep track of the "residual" time to make sure that frequent short
+ * schedules still get accounted for in the end.
+ *
* FIXME: Do pre-calculated division?
*/
-static s_time_t t2c(struct csched_runqueue_data *rqd, s_time_t time, struct csched_vcpu *svc)
+static void t2c_update(struct csched_runqueue_data *rqd, s_time_t time,
+ struct csched_vcpu *svc)
{
- return time * rqd->max_weight / svc->weight;
+ uint64_t val = time * rqd->max_weight + svc->residual;
+
+ svc->residual = do_div(val, svc->weight);
+ svc->credit -= val;
}
static s_time_t c2t(struct csched_runqueue_data *rqd, s_time_t credit, struct csched_vcpu *svc)
@@ -636,8 +645,7 @@ void burn_credits(struct csched_runqueue_data *rqd, struct csched_vcpu *svc, s_t
delta = now - svc->start_time;
if ( delta > 0 ) {
- /* This will round down; should we consider rounding up...? */
- svc->credit -= t2c(rqd, delta, svc);
+ t2c_update(rqd, delta, svc);
svc->start_time = now;
d2printk("b d%dv%d c%d\n",