From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v2] credit: generalize __vcpu_has_soft_affinity() Date: Fri, 6 Mar 2015 13:23:20 +0000 Message-ID: <1425648197.12503.68.camel@citrix.com> References: <54F9672B0200007800066D4A@mail.emea.novell.com> <54F9792A.7030605@eu.citrix.com> <54F98C920200007800066EC5@mail.emea.novell.com> <54F99035.8000804@eu.citrix.com> <54F9A13C0200007800066FD4@mail.emea.novell.com> <54F996DE.6010203@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7238808031858335680==" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YTsDr-0007hI-G9 for xen-devel@lists.xenproject.org; Fri, 06 Mar 2015 13:23:23 +0000 In-Reply-To: <54F996DE.6010203@eu.citrix.com> Content-Language: en-US List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: George Dunlap Cc: "xen-devel@lists.xenproject.org" , "JBeulich@suse.com" List-Id: xen-devel@lists.xenproject.org --===============7238808031858335680== Content-Language: en-US Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-NQPD7xYzX/C25HT+5J8r" --=-NQPD7xYzX/C25HT+5J8r Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2015-03-06 at 12:00 +0000, George Dunlap wrote: > >> On 03/06/2015 10:16 AM, Jan Beulich wrote: > >>> Hmm, not sure. And I keep being confused whether soft means > >>> "allow" and hard means "prefer" or the other way around.=20 > >>> > >> "hard" means allow (or not allow) > >> "soft" means prefer > >=20 > > while I read your reply to mean the opposite. >=20 > No, Dario and I mean the same thing: "Hard affinity" means "May only run > on these cpus and no others". "Soft affinity" means "I prefer you to > run here if you can, but if it's too busy, go ahead and run it somewhere > else". >=20 Yep. > Consider the following example >=20 > Soft affinity: 00001100 > Hard affinity: 00111100 >=20 > In this case, the scheduler should *prefer* to run it on cpus 4 or 5 > (which is in both the soft and hard affinities), but *may* run it on > cpus 2-3 if it thinks it's necessary; so there is an "effective soft > affinity" -- even though soft affinity is a subset of hard affinity. >=20 Exactly. So, in this case: cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) =3D 1 And, as far as this check only is concerned, __vcpu_has_soft_affinity() should return 'true'. > Now consider the reverse: >=20 > Soft affinity: 00111100 > Hard affinity: 00001100 >=20 > In this case, the scheduler *must* run it on either cpus 4 or 5; but > there is no preference between the two, since both are in the soft > affinity set. So this is effectively the same as not having any soft > affinity. And hard affinity is a subset of soft affinity. >=20 Correct again. So, here: cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) =3D 0 And __vcpu_has_soft_affinity() should (modulo the other parts) return 'false'. Which means that, yes, this part of the condition must loose the '!', or have the arguments of the call to cpumask_subset() switched. I personally prefer the former: return !cpumask_subset(cpupool_online_cpumask(vc->domain->cpupool), vc->cpu_soft_affinity) && cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) && cpumask_intersects(vc->cpu_soft_affinity, mask); At which point it may make sense to turn everything into 'affermative' logic. It at least look easier to read here: return cpumask_subset(vc->cpu_soft_affinity, cpupool_online_cpumask(vc->domain->cpupool) && cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) && cpumask_intersects(vc->cpu_soft_affinity, mask); IAC, sorry for overlooking this, I was focusing more on the very first item of the conditional expression, and managed to miss this. :-( Regards, Dario --=-NQPD7xYzX/C25HT+5J8r Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlT5qkUACgkQk4XaBE3IOsTNOACghuz1OZUvaL4hkJRKs7XGajnN 5vUAnRhzxzKSjbYuoOGKIWm+D9EDn88V =in8J -----END PGP SIGNATURE----- --=-NQPD7xYzX/C25HT+5J8r-- --===============7238808031858335680== 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 --===============7238808031858335680==--