All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Guittot <vincent.guittot@linaro.org>
To: Valentin Schneider <valentin.schneider@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>
Subject: Re: [PATCH] sched/fair: prefer prev cpu in asymmetric wakeup path
Date: Fri, 23 Oct 2020 09:15:48 +0200	[thread overview]
Message-ID: <CAKfTPtCysU8OikyOqYLsoYEiBjyQbuw_X9RjJWh3NFO89=5RFQ@mail.gmail.com> (raw)
In-Reply-To: <jhjzh4ep31l.mognet@arm.com>

On Thu, 22 Oct 2020 at 19:46, Valentin Schneider
<valentin.schneider@arm.com> wrote:
>
>
> On 22/10/20 16:33, Vincent Guittot wrote:
> > On Thu, 22 Oct 2020 at 16:53, Valentin Schneider
> > <valentin.schneider@arm.com> wrote:
> >> > @@ -6170,7 +6170,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
> >> >   * maximize capacity.
> >> >   */
> >> >  static int
> >> > -select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
> >> > +select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int prev, int target)
> >> >  {
> >> >       unsigned long best_cap = 0;
> >> >       int cpu, best_cpu = -1;
> >> > @@ -6178,9 +6178,22 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
> >> >
> >> >       sync_entity_load_avg(&p->se);
> >> >
> >> > +     if ((available_idle_cpu(target) || sched_idle_cpu(target)) &&
> >> > +         task_fits_capacity(p, capacity_of(target)))
> >> > +             return target;
> >> > +
> >>
> >> I think we still need to check for CPU affinity here.
> >
> > yes good point
> >
> >>
> >> >       cpus = this_cpu_cpumask_var_ptr(select_idle_mask);
> >> >       cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
> >> >
> >> > +     /*
> >> > +      * If the previous CPU belongs to this asymmetric domain and is idle,
> >> > +      * check it 1st as it's the best candidate.
> >> > +      */
> >> > +     if (prev != target && cpumask_test_cpu(prev, cpus) &&
> >> > +         (available_idle_cpu(prev) || sched_idle_cpu(prev)) &&
> >> > +         task_fits_capacity(p, capacity_of(prev)))
> >> > +             return prev;
> >> > +
> >> >       for_each_cpu_wrap(cpu, cpus, target) {
> >>
> >> So we prioritize target over prev, like the rest of the
> >> select_idle_sibling() family. Here however we apply the same acceptability
> >> function to target, prev and the loop body, so perhaps we could simplify
> >> this to:
> >
> > My 1st implementation was similar to you proposal below but i finally
> > decided to strictly follow the same sequence as symmetric which:
> > - checks target
> > - then prev cpu
> > - and finally uses target as the starting point of the loop for
> > looking for another cpu
> >
> > Using prev as the starting point of the loop will change which cpu
> > will be selected but I don't have a strong opinion if this will make a
> > real difference at the end because bit position doesn't imply any
> > relation with others cpus.
> >
>
> Yep, also one difference with the symmetric path here is that the first
> checks against target & prev use exactly the same criteria as the loop
> body, so we shouldn't feel shy about doing this here.
>
> > So I'm fine to go with your proposal below
> >
> > Also I wonder if i should also add the test of p->recent_used_cpu and
> > the per cpu kthread optimization, which benefit XFS IIRC.
> >
>
> If we head down that route it would be nice to reuse the existing
> conditions (rather than copy and tweak them) and move the asymmetric loop
> further down. Maybe with something like (with a better name though):

Yes, That would ensure that asymmetric will stay align symmetric.

I 'm going to look at this for the next version

>
>   static inline bool asym_task_fits_capacity(struct task_struct *p, int cpu)
>   {
>           if (!static_branch_unlikely(&sched_asym_cpucapacity))
>                   return true;
>
>           return task_fits_capacity(p, capacity_of(cpu));
>   }
>
> and we could && that to the existing cases. Food for thought.
>
> >>
> >>   if (accept(target))
> >>       return target;
> >>
> >>   ...
> >>
> >>   for_each_cpu_wrap(cpu, cpus, prev) {
> >>       ...
> >>   }
> >>
> >> That way we evaluate target twice only if it isn't a direct candidate
> >> (but might be a fallback one).
> >>
> >> >               unsigned long cpu_cap = capacity_of(cpu);
> >> >
> >> > @@ -6223,7 +6236,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
> >> >               if (!sd)
> >> >                       goto symmetric;
> >> >
> >> > -             i = select_idle_capacity(p, sd, target);
> >> > +             i = select_idle_capacity(p, sd, prev, target);
> >> >               return ((unsigned)i < nr_cpumask_bits) ? i : target;
> >> >       }

  reply	other threads:[~2020-10-23  7:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 13:43 [PATCH] sched/fair: prefer prev cpu in asymmetric wakeup path Vincent Guittot
2020-10-22 14:53 ` Valentin Schneider
2020-10-22 15:33   ` Vincent Guittot
2020-10-22 17:45     ` Valentin Schneider
2020-10-23  7:15       ` Vincent Guittot [this message]
2020-10-23 17:14     ` Dietmar Eggemann
2020-10-26  8:27       ` Vincent Guittot

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='CAKfTPtCysU8OikyOqYLsoYEiBjyQbuw_X9RjJWh3NFO89=5RFQ@mail.gmail.com' \
    --to=vincent.guittot@linaro.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=valentin.schneider@arm.com \
    /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.