[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 9/9] sched:credit2: get guest time from time accounting code



From: Andrii Anisov <andrii_anisov@xxxxxxxx>

While the Credit2 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_credit2.c | 17 +++++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index d17a8b4..6408c18 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -234,6 +234,7 @@ config SCHED_CREDIT
 config SCHED_CREDIT2
        bool "Credit2 scheduler support"
        default y
+       select TACC_NEEDS_LOCK
        ---help---
          The credit2 scheduler is a general purpose scheduler that is
          optimized for lower latency and higher VM density.
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 6b77da7..3b3888b 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1342,7 +1342,7 @@ static inline bool is_preemptable(const struct 
csched2_vcpu *svc,
         return true;
 
     ASSERT(svc->vcpu->is_running);
-    return now - svc->vcpu->runstate.state_entry_time >
+    return tacc_get_guest_time_delta_vcpu(svc->vcpu)>
            ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE;
 }
 
@@ -1722,7 +1722,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,
         return;
     }
 
-    delta = now - svc->start_time;
+    delta = tacc_get_guest_time_delta_vcpu(svc->vcpu);
 
     if ( unlikely(delta <= 0) )
     {
@@ -1739,7 +1739,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,
     if ( has_cap(svc) )
         svc->budget -= delta;
 
-    svc->start_time = now;
+    svc->vcpu->pcpu_guest_time += delta;
 
  out:
     if ( unlikely(tb_init_done) )
@@ -3189,8 +3189,8 @@ csched2_runtime(const struct scheduler *ops, int cpu,
     {
         s_time_t ratelimit_min = MICROSECS(prv->ratelimit_us);
         if ( snext->vcpu->is_running )
-            ratelimit_min = snext->vcpu->runstate.state_entry_time +
-                            MICROSECS(prv->ratelimit_us) - now;
+            ratelimit_min = tacc_get_guest_time_delta_vcpu(snext->vcpu) +
+                            MICROSECS(prv->ratelimit_us);
         if ( ratelimit_min > min_time )
             min_time = ratelimit_min;
     }
@@ -3265,6 +3265,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
     struct csched2_vcpu *snext = NULL;
     struct csched2_private *prv = csched2_priv(per_cpu(scheduler, cpu));
     bool yield = false, soft_aff_preempt = false;
+    s_time_t guest_time;
 
     *skipped = 0;
 
@@ -3286,8 +3287,8 @@ runq_candidate(struct csched2_runqueue_data *rqd,
      * no point forcing it to do so until rate limiting expires.
      */
     if ( !yield && prv->ratelimit_us && vcpu_runnable(scurr->vcpu) &&
-         (now - scurr->vcpu->runstate.state_entry_time) <
-          MICROSECS(prv->ratelimit_us) )
+         ((guest_time = tacc_get_guest_time_delta_vcpu(scurr->vcpu)) <
+          MICROSECS(prv->ratelimit_us)))
     {
         if ( unlikely(tb_init_done) )
         {
@@ -3297,7 +3298,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
             } d;
             d.dom = scurr->vcpu->domain->domain_id;
             d.vcpu = scurr->vcpu->vcpu_id;
-            d.runtime = now - scurr->vcpu->runstate.state_entry_time;
+            d.runtime = guest_time;
             __trace_var(TRC_CSCHED2_RATELIMIT, 1,
                         sizeof(d),
                         (unsigned char *)&d);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.