[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/4] xen: sched: simplify (and speedup) checking soft-affinity
The fact of whether or not a vCPU has a soft-affinity which is effective, i.e., with the power of actually affecting the scheduling of the vCPU itself rarely changes. Very, very rarely, as compared to how often we need to check for the same thing (basically, at every scheduling decision!). That can be improved by storing in a (per-vCPU) flag (it's actually a boolean field in struct vcpu) whether or not, considering how hard-affinity and soft-affinity look like, soft-affinity should or not be taken into account during scheduling decisions. This saves some cpumask manipulations, which is nice, considering how frequently they were being done. Note that we can't get rid of 100% of the cpumask operations involved in the check, because soft-affinity being effective or not, not only depends on the relationship between the hard and soft-affinity masks of a vCPU, but also of the online pCPUs and/or of what pCPUs are part of the cpupool where the vCPU lives, and that's rather impractical to store in a per-vCPU flag. Still the overhead is reduced to "just" one cpumask_subset() (and only if the newly introduced flag is 'true')! Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- Cc: George Dunlap <george.dunlap@xxxxxxxxxx> Cc: Anshul Makkar <anshulmakkar@xxxxxxxxx> --- xen/common/schedule.c | 5 +++++ xen/include/xen/sched-if.h | 7 +++---- xen/include/xen/sched.h | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index a8b82fd..284df66 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -854,6 +854,11 @@ void sched_set_affinity( cpumask_copy(v->cpu_hard_affinity, hard); if ( soft ) cpumask_copy(v->cpu_hard_affinity, soft); + + v->soft_aff_effective = !cpumask_subset(v->cpu_hard_affinity, + v->cpu_soft_affinity) && + cpumask_intersects(v->cpu_soft_affinity, + v->cpu_hard_affinity); } static int vcpu_set_affinity( diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 417789a..1f4ff1b 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -247,10 +247,9 @@ static inline cpumask_t* cpupool_domain_cpumask(struct domain *d) */ static inline int has_soft_affinity(const struct vcpu *v) { - return !cpumask_subset(cpupool_domain_cpumask(v->domain), - v->cpu_soft_affinity) && - !cpumask_subset(v->cpu_hard_affinity, v->cpu_soft_affinity) && - cpumask_intersects(v->cpu_soft_affinity, v->cpu_hard_affinity); + return v->soft_aff_effective && + !cpumask_subset(cpupool_domain_cpumask(v->domain), + v->cpu_soft_affinity); } /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 4f386f1..68c66f3 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -210,6 +210,8 @@ struct vcpu bool hcall_compat; #endif + /* Does soft affinity actually play a role (given hard affinity)? */ + bool soft_aff_effective; /* * > 0: a single port is being polled; _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |