All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: George Dunlap <George.Dunlap@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"JBeulich@suse.com" <JBeulich@suse.com>
Subject: Re: [PATCH v2] credit: generalize __vcpu_has_soft_affinity()
Date: Fri, 6 Mar 2015 13:23:20 +0000	[thread overview]
Message-ID: <1425648197.12503.68.camel@citrix.com> (raw)
In-Reply-To: <54F996DE.6010203@eu.citrix.com>


[-- Attachment #1.1: Type: text/plain, Size: 2741 bytes --]

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. 
> >>>
> >> "hard" means allow (or not allow)
> >> "soft" means prefer
> > 
> > while I read your reply to mean the opposite.
> 
> 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".
> 
Yep.

> Consider the following example
> 
> Soft affinity: 00001100
> Hard affinity: 00111100
> 
> 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.
> 
Exactly.

So, in this case:

 cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) = 1

And, as far as this check only is concerned, __vcpu_has_soft_affinity()
should return 'true'.

> Now consider the reverse:
> 
> Soft affinity: 00111100
> Hard affinity: 00001100
> 
> 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.
> 
Correct again. So, here:

 cpumask_subset(vc->cpu_soft_affinity, vc->cpu_hard_affinity) = 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

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2015-03-06 13:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  7:36 [PATCH v2] credit: generalize __vcpu_has_soft_affinity() Jan Beulich
2015-03-06  8:39 ` Dario Faggioli
2015-03-06  9:53 ` George Dunlap
2015-03-06 10:16   ` Jan Beulich
2015-03-06 11:32     ` George Dunlap
2015-03-06 11:44       ` Jan Beulich
2015-03-06 12:00         ` George Dunlap
2015-03-06 13:10           ` Jan Beulich
2015-03-06 13:23           ` Dario Faggioli [this message]
2015-03-06 13:32             ` Jan Beulich
2015-03-06 13:44               ` Dario Faggioli
2015-03-06 11:12   ` Dario Faggioli
2015-03-06 11:38     ` George Dunlap
2015-03-06 13:31       ` Dario Faggioli
2015-03-06 14:57         ` George Dunlap
2015-03-06 15:10           ` Dario Faggioli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425648197.12503.68.camel@citrix.com \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.