All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Valentin Schneider <valentin.schneider@arm.com>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Qais Yousef <qais.yousef@arm.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Quentin Perret <qperret@google.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	kernel-team@android.com
Subject: Re: [PATCH 2/2] sched: Plug race between SCA, hotplug and migration_cpu_stop()
Date: Wed, 2 Jun 2021 16:26:29 +0100	[thread overview]
Message-ID: <20210602152629.GF31179@willie-the-truck> (raw)
In-Reply-To: <87h7ihfrlf.mognet@arm.com>

On Tue, Jun 01, 2021 at 05:59:56PM +0100, Valentin Schneider wrote:
> On 26/05/21 21:57, Valentin Schneider wrote:
> > +		dest_cpu = arg->dest_cpu;
> > +		if (task_on_rq_queued(p)) {
> > +			/*
> > +			 * A hotplug operation could have happened between
> > +			 * set_cpus_allowed_ptr() and here, making dest_cpu no
> > +			 * longer allowed.
> > +			 */
> > +			if (!is_cpu_allowed(p, dest_cpu))
> > +				dest_cpu = select_fallback_rq(cpu_of(rq), p);
> > +			/*
> > +			 * dest_cpu can be victim of hotplug between is_cpu_allowed()
> > +			 * and here. However, per the synchronize_rcu() in
> > +			 * sched_cpu_deactivate(), it can't have gone lower than
> > +			 * CPUHP_AP_ACTIVE, so it's safe to punt it over and let
> > +			 * balance_push() route it elsewhere.
> > +			 */
> > +			update_rq_clock(rq);
> > +			rq = move_queued_task(rq, &rf, p, dest_cpu);
> 
> So, while digesting this I started having doubts vs pcpu kthreads since
> they're allowed on online CPUs. The bogus scenario here would be picking a
> !active && online CPU, and see it go !online before the move_queued_task().
> 
> Now, to transition from online -> !online, we have to go through
> take_cpu_down() which is issued via a stop_machine() call. This means the
> transition can't happen until all online CPUs are running the stopper task
> and reach MULTI_STOP_RUN.
> 
> migration_cpu_stop() being already a stopper callback should thus make it
> "atomic" vs takedown_cpu(), meaning the above should be fine.

I'd be more inclined to agree with your reasoning if migration_cpu_stop()
couldn't itself call stop_one_cpu_nowait() to queue more work for the
stopper thread. What guarantees that takedown_cpu() can't queue its stopper
work in the middle of that?

Will

  reply	other threads:[~2021-06-02 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 20:57 [PATCH 0/2] sched: SCA vs hotplug vs stopper races fixes Valentin Schneider
2021-05-26 20:57 ` [PATCH 1/2] sched: Don't defer CPU pick to migration_cpu_stop() Valentin Schneider
2021-06-01 14:04   ` [tip: sched/core] " tip-bot2 for Valentin Schneider
2021-05-26 20:57 ` [PATCH 2/2] sched: Plug race between SCA, hotplug and migration_cpu_stop() Valentin Schneider
2021-05-27  9:12   ` Peter Zijlstra
2021-06-01 16:59   ` Valentin Schneider
2021-06-02 15:26     ` Will Deacon [this message]
2021-06-02 19:43       ` Valentin Schneider
2021-06-22 13:51         ` Will Deacon
2021-06-24  9:33           ` Valentin Schneider

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=20210602152629.GF31179@willie-the-truck \
    --to=will@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=qais.yousef@arm.com \
    --cc=qperret@google.com \
    --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 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.