All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: "Justin T. Weaver" <jtweaver@hawaii.edu>, xen-devel@lists.xen.org
Cc: george.dunlap@eu.citrix.com, henric@hawaii.edu
Subject: Re: [PATCH v4 2/5] sched: credit2: respect per-vcpu hard affinity
Date: Sat, 19 Sep 2015 00:12:30 +0200	[thread overview]
Message-ID: <1442614350.2691.59.camel@citrix.com> (raw)
In-Reply-To: <1436775223-6397-3-git-send-email-jtweaver@hawaii.edu>


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

And here we are, finally... :-/

On Sun, 2015-07-12 at 22:13 -1000, Justin T. Weaver wrote:
> by making sure that vcpus only run on the pcpu(s) they are allowed to
> run on based on their hard affinity cpu masks.
> 
> Signed-off-by: Justin T. Weaver <jtweaver@hawaii.edu>
>
So, this patch looks now good to me. I've found:
 - a few style issues (indentation)
 - a comment that I would reword
 - a trivial code issue (details below)

With all these addressed, this patch is:

Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

> ---
> Changes in v4:
>  * Renamed scratch_mask to _scratch_mask
>  * Renamed csched2_cpumask to scratch_mask
>  * Removed "else continue" in function choose_cpu's for_each_cpu loop
> to make
>    the code less confusing
>  * Added an ASSERT that triggers if _scratch_mask[cpu] is NULL after
>    allocation in function csched2_alloc_pdata
>
> [...]
>
>  * Changed "run queue" in several comments to "runqueue"
>  * Renamed function valid_vcpu_migration to vcpu_is_migrateable
>  * Made condition check in function vcpu_is_migrateable "positive"
>
Ok, thanks for this really detailed list of what's changed in v4. It's
very thorough, and, AFAICT, it really covers all the review comments
that I can find about, when looking back at v3 submission.

> --- a/xen/common/sched_credit2.c
> +++ b/xen/common/sched_credit2.c

> @@ -1091,45 +1131,55 @@ choose_cpu(const struct scheduler *ops,
> struct vcpu *vc)
>          {
>              printk("%s: Runqueue migrate aborted because target
> runqueue disappeared!\n",
>                     __func__);
> -            /* Fall-through to normal cpu pick */
>          }
>          else
>          {
> -            d2printk("%pv +\n", svc->vcpu);
> -            new_cpu = cpumask_cycle(vc->processor, &svc->migrate_rqd
> ->active);
> -            goto out_up;
> +            cpumask_and(scratch_mask, vc->cpu_hard_affinity,
> +                &svc->migrate_rqd->active);
>
Indentation.

          cpumask_and(scratch_mask, vc->cpu_hard_affinity,
                      &svc->migrate_rqd->active);

> @@ -1138,12 +1188,14 @@ choose_cpu(const struct scheduler *ops,
> struct vcpu *vc)
>          }
>      }
>  
> -    /* We didn't find anyone (most likely because of spinlock
> contention); leave it where it is */
> +    /* We didn't find anyone (most likely because of spinlock
> contention). */
>      if ( min_rqi == -1 )
> -        new_cpu = vc->processor;
> +        new_cpu = get_fallback_cpu(svc);
>      else
>      {
> -        new_cpu = cpumask_cycle(vc->processor, &prv
> ->rqd[min_rqi].active);
> +        cpumask_and(scratch_mask, vc->cpu_hard_affinity,
> +            &prv->rqd[min_rqi].active);
>
Here as well.
 
> @@ -1223,7 +1275,12 @@ static void migrate(const struct scheduler
> *ops,
>              on_runq=1;
>          }
>          __runq_deassign(svc);
> -        svc->vcpu->processor = cpumask_any(&trqd->active);
> +
> +        cpumask_and(scratch_mask, svc->vcpu->cpu_hard_affinity,
> +            &trqd->active);
>
And here.

> @@ -1237,6 +1294,17 @@ static void migrate(const struct scheduler
> *ops,
>      }
>  }
>  
> +/*
> + * Migration of svc to runqueue rqd is a valid option if svc is not
> already
> + * flagged to migrate and if svc is allowed to run on at least one
> of the
> + * pcpus assigned to rqd based on svc's hard affinity mask.
> + */
> +static bool_t vcpu_is_migrateable(struct csched2_vcpu *svc,
> +                                  struct csched2_runqueue_data *rqd)
> +{
> +    return !test_bit(__CSFLAG_runq_migrate_request, &svc->flags)
> +        && cpumask_intersects(svc->vcpu->cpu_hard_affinity, &rqd
> ->active);
>
This one, I'd make it look like this:

    return !test_bit(__CSFLAG_runq_migrate_request, &svc-flags) &&
           cpumask_intersects(svc->vcpu->cpu_hard_affinity, &rqd->active);


> @@ -1415,11 +1480,20 @@ csched2_vcpu_migrate(
>  
>      /* Check if new_cpu is valid */
>      BUG_ON(!cpumask_test_cpu(new_cpu, &CSCHED2_PRIV(ops)
> ->initialized));
> +    ASSERT(cpumask_test_cpu(new_cpu, vc->cpu_hard_affinity));
>  
>      trqd = RQD(ops, new_cpu);
>  
> +    /*
> +     * Without the processor assignment after the else, vc may be
> assigned to
> +     * a processor it is not allowed to run on. In that case,
> runq_candidate
> +     * might only get called for the old cpu, and vc will not get to
> run due
> +     * to the hard affinity check.
> +     */
>      if ( trqd != svc->rqd )
>          migrate(ops, svc, trqd, NOW());
> +    else
> +        vc->processor = new_cpu;
>  }
>  
About the comment. I don't like it expressing would happen if a
specific piece of code, that is there, were missing. I'd go for
something like this:

"Do the actual movement toward new_cpu, and update vc->processor. If we
are changing runqueue, migrate() takes care of everything. If we are
not changing runqueue, we need to update vc->processor here. In fact,
if, for instance, we are here because the vcpu's hard affinity is being
changed, we don't want to risk leaving vc->processor pointing to a pcpu
where the vcpu can't run any longer"

> @@ -2047,6 +2125,9 @@ static void init_pcpu(const struct scheduler
> *ops, int cpu)
>  
>      spin_unlock_irqrestore(&prv->lock, flags);
>  
> +    free_cpumask_var(_scratch_mask[cpu]);
> +    _scratch_mask[cpu] = NULL;
> +
>      return;
>  }
> 
And here we are: this is the only issue in the code (i.e., not about
comment wording or style issues) that I've found.

How come this hunk is in init_pcpu()? Shouldn't it live in
csched2_free_pdata()? I think it should...

From the look of things, it is probably the result of a rebase of the
patch which went slightly wrong, without you noticing it. :-)

> @@ -2061,6 +2142,16 @@ csched2_alloc_pdata(const struct scheduler
> *ops, int cpu)
>          printk("%s: cpu %d not online yet, deferring
> initializatgion\n",
>                 __func__, cpu);
>  
> +    /*
> +     * For each new pcpu, allocate a cpumask_t for use throughout
> the
> +     * scheduler to avoid putting any cpumask_t structs on the
> stack.
>
"to avoid putting too many cpumask_t structs on the stack"

In fact, there are some already, and we're not removing them, we're
just avoiding adding more of them

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: 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

  reply	other threads:[~2015-09-18 22:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13  8:13 [PATCH v4 0/5] sched: credit2: introduce per-vcpu hard and soft affinity Justin T. Weaver
2015-07-13  8:13 ` [PATCH v4 1/5] sched: factor out VCPU2ONLINE to common header file Justin T. Weaver
2015-09-17 15:26   ` Dario Faggioli
2015-07-13  8:13 ` [PATCH v4 2/5] sched: credit2: respect per-vcpu hard affinity Justin T. Weaver
2015-09-18 22:12   ` Dario Faggioli [this message]
2015-07-13  8:13 ` [PATCH v4 3/5] sched: factor out per-vcpu affinity related code to common header file Justin T. Weaver
2015-07-13  8:13 ` [PATCH v4 4/5] sched: credit2: add soft affinity awareness to function get_fallback_cpu Justin T. Weaver
2015-07-13  8:13 ` [PATCH v4 5/5] sched: credit2: add soft affinity awareness to function runq_tickle Justin T. Weaver
2015-07-13 15:43 ` [PATCH v4 0/5] sched: credit2: introduce per-vcpu hard and soft affinity Dario Faggioli
2015-09-14  9:03 ` 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=1442614350.2691.59.camel@citrix.com \
    --to=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=henric@hawaii.edu \
    --cc=jtweaver@hawaii.edu \
    --cc=xen-devel@lists.xen.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.