@@ -227,6 +227,7 @@ config TACC_NEEDS_LOCK
config SCHED_CREDIT
bool "Credit scheduler support"
default y
+ select TACC_NEEDS_LOCK
---help---
The traditional credit scheduler is a general purpose scheduler.
@@ -324,16 +324,15 @@ runq_remove(struct csched_vcpu *svc)
__runq_remove(svc);
}
-static void burn_credits(struct csched_vcpu *svc, s_time_t now)
+static void burn_credits(struct csched_vcpu *svc, s_time_t delta)
{
- s_time_t delta;
uint64_t val;
unsigned int credits;
/* Assert svc is current */
ASSERT( svc == CSCHED_VCPU(curr_on_cpu(svc->vcpu->processor)) );
- if ( (delta = now - svc->start_time) <= 0 )
+ if ( delta <= 0 )
return;
val = delta * CSCHED_CREDITS_PER_MSEC + svc->residual;
@@ -341,7 +340,6 @@ static void burn_credits(struct csched_vcpu *svc, s_time_t now)
credits = val;
ASSERT(credits == val); /* make sure we haven't truncated val */
atomic_sub(credits, &svc->credit);
- svc->start_time += (credits * MILLISECS(1)) / CSCHED_CREDITS_PER_MSEC;
}
static bool_t __read_mostly opt_tickle_one_idle = 1;
@@ -956,7 +954,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned int cpu)
/*
* Update credits
*/
- burn_credits(svc, NOW());
+ burn_credits(svc, tacc_get_guest_time_delta_vcpu(svc->vcpu));
/*
* Put this VCPU and domain back on the active list if it was
@@ -1856,14 +1854,14 @@ csched_schedule(
(unsigned char *)&d);
}
- runtime = now - current->runstate.state_entry_time;
+ runtime = tacc_get_guest_time_delta();
if ( runtime < 0 ) /* Does this ever happen? */
runtime = 0;
if ( !is_idle_vcpu(scurr->vcpu) )
{
/* Update credits of a non-idle VCPU. */
- burn_credits(scurr, now);
+ burn_credits(scurr, runtime);
scurr->start_time -= now;
scurr->last_sched_time = now;
}