Skip to contentSkip to conversation

schedule: move last_run_time to the credit scheduler privates

PATCH Superseded Andrii Anisov 4 participants 5 messages Sep 11, 2018 – Sep 12, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 schedule: move last_run_time to the credit scheduler privates

From: Andrii Anisov <[email protected]>

The structure member last_run_time is used by a credit scheduler only. So move it from a generic vcpu sctructure to the credit scheduler private vcpu definition.

---
 xen/common/sched_credit.c | 12 +++++++++---
 xen/common/schedule.c     |  1 -
 xen/include/xen/sched.h   |  3 ---
 3 files changed, 9 insertions(+), 7 deletions(-)
xen/common/sched_credit.c +9 -3
index 84e744b..7170172 100644
@@ -175,6 +175,9 @@ struct csched_vcpu {
     atomic_t credit;
     unsigned int residual;
 
+    /* last time when vCPU is scheduled out */
+    uint64_t last_run_time;
+
 #ifdef CSCHED_STATS
     struct {
         int credit_last;
@@ -701,10 +704,11 @@ static unsigned int vcpu_migration_delay_us;
 integer_param("vcpu_migration_delay", vcpu_migration_delay_us);
 
 static inline bool
-__csched_vcpu_is_cache_hot(const struct csched_private *prv, struct vcpu *v)
+__csched_vcpu_is_cache_hot(const struct csched_private *prv,
+                           struct csched_vcpu * scurr)
 {
     bool hot = prv->vcpu_migr_delay &&
-               (NOW() - v->last_run_time) < prv->vcpu_migr_delay;
+               (NOW() - scurr->last_run_time) < prv->vcpu_migr_delay;
 
     if ( hot )
         SCHED_STAT_CRANK(vcpu_hot);
@@ -716,6 +720,7 @@ static inline int
 __csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu *vc,
                              int dest_cpu, cpumask_t *mask)
 {
+    struct csched_vcpu * scurr = CSCHED_VCPU(vc);
     /*
      * Don't pick up work that's hot on peer PCPU, or that can't (or
      * would prefer not to) run on cpu.
@@ -725,7 +730,7 @@ __csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu *vc,
      */
     ASSERT(!vc->is_running);
 
-    return !__csched_vcpu_is_cache_hot(prv, vc) &&
+    return !__csched_vcpu_is_cache_hot(prv, scurr) &&
            cpumask_test_cpu(dest_cpu, mask);
 }
 
@@ -1869,6 +1874,7 @@ csched_schedule(
         /* Update credits of a non-idle VCPU. */
         burn_credits(scurr, now);
         scurr->start_time -= now;
+        scurr->last_run_time = now;
     }
     else
     {
xen/common/schedule.c +0 -1
index 05281d6..3c299ca 100644
@@ -1556,7 +1556,6 @@ static void schedule(void)
         ((prev->pause_flags & VPF_blocked) ? RUNSTATE_blocked :
          (vcpu_runnable(prev) ? RUNSTATE_runnable : RUNSTATE_offline)),
         now);
-    prev->last_run_time = now;
 
     ASSERT(next->runstate.state != RUNSTATE_running);
     vcpu_runstate_change(next, RUNSTATE_running, now);
xen/include/xen/sched.h +0 -3
index 0ba80cb..b6b2c43 100644
@@ -173,9 +173,6 @@ struct vcpu
     } runstate_guest; /* guest address */
 #endif
 
-    /* last time when vCPU is scheduled out */
-    uint64_t last_run_time;
-
     /* Has the FPU been initialised? */
     bool             fpu_initialised;
     /* Has the FPU been used since it was last saved? */
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 11.09.18 at 10:10, <[email protected]> wrote:

From: Andrii Anisov <[email protected]>

The structure member last_run_time is used by a credit scheduler only. So move it from a generic vcpu sctructure to the credit scheduler private vcpu definition.

---
 xen/common/sched_credit.c | 12 +++++++++---
 xen/common/schedule.c     |  1 -
 xen/include/xen/sched.h   |  3 ---
 3 files changed, 9 insertions(+), 7 deletions(-)
xen/common/sched_credit.c +3 -0
index 84e744b..7170172 100644
@@ -175,6 +175,9 @@ struct csched_vcpu {
     atomic_t credit;
     unsigned int residual;
 
+    /* last time when vCPU is scheduled out */
+    uint64_t last_run_time;
+
 #ifdef CSCHED_STATS
     struct {
         int credit_last;

xen/common/sched_credit.c static unsigned int vcpu_migration_delay_us; · line 708

Quoted 6 lines
xen/common/sched_credit.c +2 -1
@@ -701,10 +704,11 @@ static unsigned int vcpu_migration_delay_us;
 integer_param("vcpu_migration_delay", vcpu_migration_delay_us);
 
 static inline bool
-__csched_vcpu_is_cache_hot(const struct csched_private *prv, struct vcpu *v)
+__csched_vcpu_is_cache_hot(const struct csched_private *prv,
+                           struct csched_vcpu * scurr)

Stray blank, and it looks like the parameter can be pointer to const. Similar further down.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 11.09.18 at 10:10, <[email protected]> wrote:

From: Andrii Anisov <[email protected]>

xen/common/sched_credit.c +0 -0
index 84e744b..7170172 100644
@@ -701,10 +704,11 @@ static unsigned int vcpu_migration_delay_us;
 integer_param("vcpu_migration_delay", vcpu_migration_delay_us);
 
Quoted 9 lines

xen/common/sched_credit.c static unsigned int vcpu_migration_delay_us; · line 708

Quoted 5 lines
xen/common/sched_credit.c +2 -1
 static inline bool
-__csched_vcpu_is_cache_hot(const struct csched_private *prv,
 struct vcpu *v)
+__csched_vcpu_is_cache_hot(const struct csched_private *prv,
+                           struct csched_vcpu * scurr)

Stray blank, and it looks like the parameter can be pointer to const. Similar further down.

And besides this that Jan is saying, I'd name the parameter 'svc' rather than 'scurr'.

Calling it scurr makes one think that it is always a vcpu that is currently running on a pcpu which is being passed to the function. But that, not only is not at all required, but it is not even the case right now.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Andrii Anisov
Quoted 15 lines · Andrii Anisov

From: Andrii Anisov <[email protected]>

The structure member last_run_time is used by a credit scheduler only.
So move it from a generic vcpu sctructure to the credit scheduler private
vcpu definition.

---

index 84e744b..7170172 100644

xen/common/sched_credit.c struct csched_vcpu { · line 181

Quoted 7 lines
xen/common/sched_credit.c +3 -0
@@ -175,6 +175,9 @@ struct csched_vcpu {
     atomic_t credit;
     unsigned int residual;
 
+    /* last time when vCPU is scheduled out */
+    uint64_t last_run_time;
+
 

I think that, while we're doing this, we should take the chance to convert the type to s_time_t too.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

Hello Dario,

Quoted 2 lines · Dario Faggioli

I think that, while we're doing this, we should take the chance to convert the type to s_time_t too.

Good point, as well as renaming scurr.

Signature · 7 lines
*Andrii Anisov*


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel