From: "Jan Beulich" Subject: [PATCH v3] credit: generalize __vcpu_has_soft_affinity() Date: Fri, 06 Mar 2015 13:29:10 +0000 Message-ID: <54F9B9B602000078000670AB@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartD8ED78B6.2__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YTsJT-0000dn-9c for xen-devel@lists.xenproject.org; Fri, 06 Mar 2015 13:29:11 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: George Dunlap , Dario Faggioli List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartD8ED78B6.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline As pointed out in the discussion of the patch at http://lists.xenproject.org/archives/html/xen-devel/2015-02/msg03256.html= =20 generalizing the conditions here means code elsewhere doesn't need to take into consideration internals of how load balancing in the credit scheduler works. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap --- v3: Swap soft and hard affinities in the 2nd of the 3 checks. Alter comment as requested by George (which made us notice the need for the code change, therefore retaining his review tag). v2: Use VCPU2ONLINE(vc) (or really an open coded variant thereof) instead of cpu_online_map (suggested by Dario). --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -279,24 +279,23 @@ __runq_remove(struct csched_vcpu *svc) =20 /* * Hard affinity balancing is always necessary and must never be skipped. - * OTOH, if the vcpu's soft affinity is full (it spans all the possible - * pcpus) we can safely avoid dealing with it entirely. + * But soft affinity need only be considered when it has a functionally + * different effect than other constraints (such as hard affinity, cpus + * online, or cpupools). * - * A vcpu's soft affinity is also deemed meaningless in case it has empty - * intersection with mask, to cover the cases where using the soft = affinity - * mask seems legit, but would instead led to trying to schedule the vcpu - * on _no_ pcpu! Typical use cases are for mask to be equal to the vcpu's - * hard affinity, or to the && of hard affinity and the set of online = cpus - * in the domain's cpupool. + * Soft affinity only needs to be considered if: + * * The cpus in the cpupool are not a subset of soft affinity + * * The hard affinity is not a subset of soft affinity + * * There is an overlap between the soft affinity and the mask which is + * currently being considered. */ static inline int __vcpu_has_soft_affinity(const struct vcpu *vc, const cpumask_t *mask) { - if ( cpumask_full(vc->cpu_soft_affinity) - || !cpumask_intersects(vc->cpu_soft_affinity, mask) ) - return 0; - - return 1; + return !cpumask_subset(cpupool_online_cpumask(vc->domain->cpupool), + vc->cpu_soft_affinity) && + !cpumask_subset(vc->cpu_hard_affinity, vc->cpu_soft_affinity) = && + cpumask_intersects(vc->cpu_soft_affinity, mask); } =20 /* --=__PartD8ED78B6.2__= Content-Type: text/plain; name="credit-has-soft-affinity.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="credit-has-soft-affinity.patch" credit: generalize __vcpu_has_soft_affinity()=0A=0AAs pointed out in the = discussion of the patch at=0Ahttp://lists.xenproject.org/archives/html/xen-= devel/2015-02/msg03256.html=0Ageneralizing the conditions here means code = elsewhere doesn't need to=0Atake into consideration internals of how load = balancing in the credit=0Ascheduler works.=0A=0ASigned-off-by: Jan Beulich = =0AReviewed-by: George Dunlap =0A---=0Av3: Swap soft and hard affinities in the 2nd of the 3 checks. = Alter=0A comment as requested by George (which made us notice the need = for=0A the code change, therefore retaining his review tag).=0Av2: Use = VCPU2ONLINE(vc) (or really an open coded variant thereof)=0A instead of = cpu_online_map (suggested by Dario).=0A=0A--- a/xen/common/sched_credit.c= =0A+++ b/xen/common/sched_credit.c=0A@@ -279,24 +279,23 @@ __runq_remove(st= ruct csched_vcpu *svc)=0A =0A /*=0A * Hard affinity balancing is always = necessary and must never be skipped.=0A- * OTOH, if the vcpu's soft = affinity is full (it spans all the possible=0A- * pcpus) we can safely = avoid dealing with it entirely.=0A+ * But soft affinity need only be = considered when it has a functionally=0A+ * different effect than other = constraints (such as hard affinity, cpus=0A+ * online, or cpupools).=0A = *=0A- * A vcpu's soft affinity is also deemed meaningless in case it has = empty=0A- * intersection with mask, to cover the cases where using the = soft affinity=0A- * mask seems legit, but would instead led to trying to = schedule the vcpu=0A- * on _no_ pcpu! Typical use cases are for mask to be = equal to the vcpu's=0A- * hard affinity, or to the && of hard affinity and = the set of online cpus=0A- * in the domain's cpupool.=0A+ * Soft affinity = only needs to be considered if:=0A+ * * The cpus in the cpupool are not a = subset of soft affinity=0A+ * * The hard affinity is not a subset of soft = affinity=0A+ * * There is an overlap between the soft affinity and the = mask which is=0A+ * currently being considered.=0A */=0A static inline = int __vcpu_has_soft_affinity(const struct vcpu *vc,=0A = const cpumask_t *mask)=0A {=0A- if ( cpumask_full= (vc->cpu_soft_affinity)=0A- || !cpumask_intersects(vc->cpu_soft_aff= inity, mask) )=0A- return 0;=0A-=0A- return 1;=0A+ return = !cpumask_subset(cpupool_online_cpumask(vc->domain->cpupool),=0A+ = vc->cpu_soft_affinity) &&=0A+ !cpumask_subset(vc-= >cpu_hard_affinity, vc->cpu_soft_affinity) &&=0A+ cpumask_interse= cts(vc->cpu_soft_affinity, mask);=0A }=0A =0A /*=0A --=__PartD8ED78B6.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartD8ED78B6.2__=--