schedule: move credit scheduler specific member to its privates
PATCH v4 1/1 schedule: move credit scheduler specific member to its privates
From: Andrii Anisov <[email protected]>
The vcpu structure member last_run_time is used by credit scheduler only. In order to get better encapsulation, it is moved from a generic structure to the credit scheduler private vcpu definition. Also, rename the member to last_sched_time in order to reflect that it is the time when the vcpu went through the scheduling path.
With this move we have slight changes in functionality:
- last_sched_time is not updated for an idle vcpu. But the idle vcpu is, in fact, a per-pcpu stub and never migrates so last_sched_time is meaningless for it.
- The value of last_sched_time is updated on every schedule, even if the vcpu is not being changed. It is still ok, because last_sched_time is only used for runnable vcpu migration decision, and we have it correct at that moment. Scheduling parameters and statistics are tracked by other entities.
Reducing code and data usage when not running credit scheduler is another nice side effect.
While here, also:
- turn last_sched_time into s_time_t, which is more appropriate.
- properly const-ify related argument of __csched_vcpu_is_cache_hot().
---
Changes in
v4:
- The member renamed to last_sched_time
- removed a misleading comment
- commit title and message updated describing member rename, change motivation and a side effect
v3:
- commit message updated accordingly to [1]
v2:
- last_run_time type changed to s_time_t
- scurr changed to svc
- dropped stray blanks
- pointers to const are used appropriately
[1] https://lists.xenproject.org/archives/html/xen-devel/2018-09/msg01201.html
--- xen/common/sched_credit.c | 11 ++++++++--- xen/common/schedule.c | 1 - xen/include/xen/sched.h | 3 --- 3 files changed, 8 insertions(+), 7 deletions(-)
xen/common/sched_credit.c +8 -3
@@ -175,6 +175,8 @@ struct csched_vcpu {atomic_t credit;unsigned int residual; +s_time_t last_sched_time; + #ifdef CSCHED_STATS struct { int credit_last;
@@ -701,10 +703,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, +const struct csched_vcpu *svc) {bool hot = prv->vcpu_migr_delay && - (NOW () - v->last_run_time) < prv->vcpu_migr_delay; + (NOW () - svc->last_sched_time) < prv->vcpu_migr_delay;if ( hot )SCHED_STAT_CRANK (vcpu_hot);
@@ -716,6 +719,7 @@ static inline int __csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu *vc, int dest_cpu, cpumask_t *mask) { + const struct csched_vcpu *svc = 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 +729,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, svc) &&cpumask_test_cpu (dest_cpu, mask); }
@@ -1870,6 +1874,7 @@ csched_schedule(/* Update credits of a non-idle VCPU. */ burn_credits (scurr, now); scurr->start_time -= now; + scurr->last_sched_time = now; }else {
xen/common/schedule.c +0 -1
@@ -1486,7 +1486,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
@@ -174,9 +174,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
Quoted 29 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
The vcpu structure member
last_run_timeis used by credit scheduler only.
In order to get better encapsulation, it is moved from a generic structure to the credit scheduler private vcpu definition. Also, rename
the member tolast_sched_timein order to reflect that it is the time when the vcpu went through the scheduling path.With this move we have slight changes in functionality:
-last_sched_timeis not updated for an idle vcpu. But the idle vcpu
is,
in fact, a per-pcpu stub and never migrates solast_sched_timeis meaningless for it.
- The value oflast_sched_timeis updated on every schedule, even if
the
vcpu is not being changed. It is still ok, becauselast_sched_time
is
only used for runnable vcpu migration decision, and we have it
correct
at that moment. Scheduling parameters and statistics are tracked
by
other entities.Reducing code and data usage when not running credit scheduler is another
nice side effect.
Quoted 7 lines
While here, also:
- turnlast_sched_timeintos_time_t, which is more appropriate.
- properly const-ify related argument of__csched_vcpu_is_cache_hot().Signed-off-by Andrii Anisov <[email protected]>
Thanks and Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel