From: Dario Faggioli <dario.faggioli@citrix.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Jonathan Davies <Jonathan.Davies@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Marcus Granado <marcus.granado@citrix.com>,
Stefano Stabellini <stefano@aporeto.com>,
Julien Grall <julien.grall@arm.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 2/3] xen: sched_null: support for hard affinity
Date: Tue, 21 Mar 2017 09:47:10 +0100 [thread overview]
Message-ID: <1490086030.15340.12.camel@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1703201630560.11533@sstabellini-ThinkPad-X260>
[-- Attachment #1.1: Type: text/plain, Size: 3876 bytes --]
On Mon, 2017-03-20 at 16:46 -0700, Stefano Stabellini wrote:
> On Fri, 17 Mar 2017, Dario Faggioli wrote:
> >
> > --- a/xen/common/sched_null.c
> > +++ b/xen/common/sched_null.c
> > @@ -117,6 +117,14 @@ static inline struct null_dom *null_dom(const
> > struct domain *d)
> > return d->sched_priv;
> > }
> >
> > +static inline bool check_nvc_affinity(struct null_vcpu *nvc,
> > unsigned int cpu)
> > +{
> > + cpumask_and(cpumask_scratch_cpu(cpu), nvc->vcpu-
> > >cpu_hard_affinity,
> > + cpupool_domain_cpumask(nvc->vcpu->domain));
> > +
> > + return cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu));
> > +}
>
> If you make it take a struct vcpu* as first argument, it will be more
> generally usable
>
Yes, that's probably a good idea. Thanks.
> > return cpu;
> >
> > - /* If not, just go for a valid free pCPU, if any */
> > + /* If not, just go for a free pCPU, within our affinity, if
> > any */
> > cpumask_and(cpumask_scratch_cpu(cpu), &prv->cpus_free, cpus);
> > + cpumask_and(cpumask_scratch_cpu(cpu),
> > cpumask_scratch_cpu(cpu),
> > + v->cpu_hard_affinity);
>
> You can do this with one cpumask_and (in addition to the one above):
>
> cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu),
> &prv->cpus_free);
>
Mmm... right. Wow... Quite an overlook on my side! :-P
> > @@ -308,7 +320,10 @@ static unsigned int pick_cpu(struct
> > null_private *prv, struct vcpu *v)
> > * only if the pCPU is free.
> > */
> > if ( unlikely(cpu == nr_cpu_ids) )
> > - cpu = cpumask_any(cpus);
> > + {
> > + cpumask_and(cpumask_scratch_cpu(cpu), cpus, v-
> > >cpu_hard_affinity);
>
> Could the intersection be 0?
>
Not really. Because vcpu_set_hard_affinity() fails when trying to set
the affinity to something that has a zero intersection with the set of
cpus of the pool the domain is in.
Other schedulers relies on this too.
However, I need to re-check what happens if everything is ok when
changing the affinity, but then all the cpus in the affinity itself are
removed from the pool... I will do that as, as I said, this is
something general (and this area is really a can of worms... And I keep
finding weird corner cases! :-O)
> > @@ -408,8 +426,7 @@ static void null_vcpu_insert(const struct
> > scheduler *ops, struct vcpu *v)
> > */
> > vcpu_assign(prv, v, cpu);
> > }
> > - else if ( cpumask_intersects(&prv->cpus_free,
> > - cpupool_domain_cpumask(v-
> > >domain)) )
> > + else if ( cpumask_intersects(&prv->cpus_free,
> > cpumask_scratch_cpu(cpu)) )
> > {
> > spin_unlock(lock);
> > goto retry;
> > @@ -462,7 +479,7 @@ static void null_vcpu_remove(const struct
> > scheduler *ops, struct vcpu *v)
> >
> > spin_lock(&prv->waitq_lock);
> > wvc = list_first_entry_or_null(&prv->waitq, struct null_vcpu,
> > waitq_elem);
> > - if ( wvc )
> > + if ( wvc && cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu)) )
>
> shouldn't this be
>
> check_nvc_affinity(wvc, cpu)
>
> ?
>
Mmm... well, considering that I never touch cpumask_scratch_cpu() in
this function, this is clearly a bug. Will fix. :-/
Thanks and Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-21 8:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 18:42 [PATCH 0/3] The 'null' Scheduler Dario Faggioli
2017-03-17 18:42 ` [PATCH 1/3] xen: sched: introduce the 'null' semi-static scheduler Dario Faggioli
2017-03-20 23:21 ` Stefano Stabellini
2017-03-21 8:26 ` Dario Faggioli
2017-03-27 10:31 ` George Dunlap
2017-03-27 10:48 ` George Dunlap
2017-04-06 14:43 ` Dario Faggioli
2017-04-06 15:07 ` Dario Faggioli
2017-03-17 18:43 ` [PATCH 2/3] xen: sched_null: support for hard affinity Dario Faggioli
2017-03-20 23:46 ` Stefano Stabellini
2017-03-21 8:47 ` Dario Faggioli [this message]
2017-03-17 18:43 ` [PATCH 3/3] tools: sched: add support for 'null' scheduler Dario Faggioli
2017-03-20 22:28 ` Stefano Stabellini
2017-03-21 17:09 ` Wei Liu
2017-03-27 10:50 ` George Dunlap
2017-04-06 10:49 ` Dario Faggioli
2017-04-06 13:59 ` George Dunlap
2017-04-06 15:18 ` Dario Faggioli
2017-04-07 9:42 ` Wei Liu
2017-04-07 10:05 ` Dario Faggioli
2017-04-07 10:13 ` Wei Liu
2017-03-20 22:23 ` [PATCH 0/3] The 'null' Scheduler Stefano Stabellini
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=1490086030.15340.12.camel@citrix.com \
--to=dario.faggioli@citrix.com \
--cc=Jonathan.Davies@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=julien.grall@arm.com \
--cc=marcus.granado@citrix.com \
--cc=sstabellini@kernel.org \
--cc=stefano@aporeto.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).