diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index c11148e89f..9b35e0fbb7 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -620,14 +620,23 @@ 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; BUG_ON( is_idle_vcpu(svc->vcpu) ); BUG_ON( 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