linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Benjamin Segall <bsegall@google.com>,
	Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Valentin Schneider <valentin.schneider@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched, fair: try to prevent migration thread from preempting non-cfs task
Date: Wed, 16 Jun 2021 17:45:36 +0800	[thread overview]
Message-ID: <CALOAHbDPXjcgw37_yrR_A6kgJOuopjr409YnHKcMrgwN=uazpg@mail.gmail.com> (raw)
In-Reply-To: <YMmlAP/QhE6SWhCF@hirez.programming.kicks-ass.net>

On Wed, Jun 16, 2021 at 3:15 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, Jun 16, 2021 at 09:44:46AM +0800, Yafang Shao wrote:
> > On Wed, Jun 16, 2021 at 4:35 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > On Tue, Jun 15, 2021 at 08:15:51PM +0800, Yafang Shao wrote:
> > > > ---
> > > >  kernel/sched/fair.c | 14 ++++++++++++++
> > > >  1 file changed, 14 insertions(+)
> > > >
> > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > > index 3248e24a90b0..597c7a940746 100644
> > > > --- a/kernel/sched/fair.c
> > > > +++ b/kernel/sched/fair.c
> > > > @@ -9797,6 +9797,20 @@ static int load_balance(int this_cpu, struct rq *this_rq,
> > > >                       /* Record that we found at least one task that could run on this_cpu */
> > > >                       env.flags &= ~LBF_ALL_PINNED;
> > > >
> > > > +                     /*
> > > > +                      * There may be a race between load balance starting migration
> > > > +                      * thread to pull the cfs running thread and the RT thread
> > > > +                      * waking up and preempting cfs task before migration threads
> > > > +                      * which then preempt the RT thread.
> > > > +                      * We'd better do the last minute check before starting
> > > > +                      * migration thread to avoid preempting latency-sensitive thread.
> > > > +                      */
> > > > +                     if (busiest->curr->sched_class != &fair_sched_class) {
> > > > +                             raw_spin_unlock_irqrestore(&busiest->lock,
> > > > +                                                        flags);
> > >
> > > This won't apply.
> > >
> > > Also, there's still a race window, you've just shrunk it, not fixed it.
> > > Busiest can reschedule between the mandatory rq unlock and doing the
> > > stopper wakeup.
> > >
> > > An actual fix might be to have the active migration done by a FIFO-1
> > > task, instead of stopper. The obvious down-side is that that would mean
> > > spawning yet another per-cpu kthread.
> > >
> >
> > The stopper and the migration thread are different threads in the earlier days.
> > commit 969c79215a35 ("sched: replace migration_thread with cpu_stop")
> > merged them into one thread.
>
> Yes, I know, I was there. But that's not what I'm saying, we need the
> migration thread to be super high perio for other cases. That change
> still makes sense.
>
> > Regarding the priority of stopper (with highest priority) and
> > migration (higher than CFS, but lower than RT) , keeping them in one
> > single thread seems not a good way.
>
> I never suggested as such.
>
> Only the active migration of CFS can be done by a FIFO-1 task (the
> lowest prio that is higher than CFS) and possible the numa balancing
> thing.
>
> Other migrations will still need to use stopper, and as such you'll keep
> having interference from stopper.
>
> The suggestion was adding a cfs_migration thread, specifically for
> active balance (and maybe numa). Just not sure the cost of carrying yet
> another per-cpu kernel thread is worth the benefit.

Thanks for the clarification.

-- 
Thanks
Yafang

      parent reply	other threads:[~2021-06-16  9:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 12:15 [PATCH] sched, fair: try to prevent migration thread from preempting non-cfs task Yafang Shao
2021-06-15 14:55 ` Valentin Schneider
2021-06-15 15:45   ` Vincent Guittot
2021-06-15 16:39     ` Valentin Schneider
2021-06-15 20:35 ` Peter Zijlstra
2021-06-16  1:44   ` Yafang Shao
2021-06-16  7:15     ` Peter Zijlstra
2021-06-16  7:29       ` Vincent Guittot
2021-06-16  8:29         ` Peter Zijlstra
2021-06-16  9:49           ` Yafang Shao
2021-06-16  9:45       ` Yafang Shao [this message]

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='CALOAHbDPXjcgw37_yrR_A6kgJOuopjr409YnHKcMrgwN=uazpg@mail.gmail.com' \
    --to=laoar.shao@gmail.com \
    --cc=bristot@redhat.com \
    --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=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=valentin.schneider@arm.com \
    --cc=vincent.guittot@linaro.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).