|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC 8/9] sched:credit: get guest time from time accounting code
From: Andrii Anisov <andrii_anisov@xxxxxxxx>
While the Credit scheduler code uses guest time from the
other pcpu, we have to use locked time accounting.
Signed-off-by: Andrii Anisov <andrii_anisov@xxxxxxxx>
---
xen/common/Kconfig | 1 +
xen/common/sched_credit.c | 12 +++++-------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index c1748dd..d17a8b4 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -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.
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index 81dee5e..ac6b9e6 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -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;
}
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |