From: Valentin Schneider <valentin.schneider@arm.com>
To: Qais Yousef <qais.yousef@arm.com>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@kernel.org, bigeasy@linutronix.de, swood@redhat.com,
peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, vincent.donnefort@arm.com, tj@kernel.org
Subject: Re: [RFC PATCH] sched/core: Fix premature p->migration_pending completion
Date: Fri, 05 Feb 2021 11:02:27 +0000 [thread overview]
Message-ID: <jhj1rdu3hh8.mognet@arm.com> (raw)
In-Reply-To: <20210204153040.qqkoa5sjztqeskoc@e107158-lin>
On 04/02/21 15:30, Qais Yousef wrote:
> On 02/03/21 18:59, Valentin Schneider wrote:
>> On 03/02/21 17:23, Qais Yousef wrote:
>> > On 01/27/21 19:30, Valentin Schneider wrote:
>> >> Initial conditions:
>> >> victim.cpus_mask = {CPU0, CPU1}
>> >>
>> >> CPU0 CPU1 CPU<don't care>
>> >>
>> >> switch_to(victim)
>> >> set_cpus_allowed(victim, {CPU1})
>> >> kick CPU0 migration_cpu_stop({.dest_cpu = CPU1})
>> >> switch_to(stopper/0)
>> >> // e.g. CFS load balance
>> >> move_queued_task(CPU0, victim, CPU1);
>> >> switch_to(victim)
>> >> set_cpus_allowed(victim, {CPU0});
>> >> task_rq_unlock();
>> >> migration_cpu_stop(dest_cpu=CPU1)
>> >
>> > This migration stop is due to set_cpus_allowed(victim, {CPU1}), right?
>> >
>>
>> Right
>>
>> >> task_rq(p) != rq && pending
>> >> kick CPU1 migration_cpu_stop({.dest_cpu = CPU1})
>> >>
>> >> switch_to(stopper/1)
>> >> migration_cpu_stop(dest_cpu=CPU1)
>> >
>> > And this migration stop is due to set_cpus_allowed(victim, {CPU0}), right?
>> >
>>
>> Nein! This is a retriggering of the "current" stopper (triggered by
>> set_cpus_allowed(victim, {CPU1})), see the tail of that
>>
>> else if (dest_cpu < 0 || pending)
>>
>> branch in migration_cpu_stop(), is what I'm trying to hint at with that
>>
>> task_rq(p) != rq && pending
>
> Okay I see. But AFAIU, the work will be queued in order. So we should first
> handle the set_cpus_allowed_ptr(victim, {CPU0}) before the retrigger, no?
>
> So I see migration_cpu_stop() running 3 times
>
> 1. because of set_cpus_allowed(victim, {CPU1}) on CPU0
> 2. because of set_cpus_allowed(victim, {CPU0}) on CPU1
> 3. because of retrigger of '1' on CPU0
>
On that 'CPU<don't care>' lane, I intentionally included task_rq_unlock()
but not 'kick CPU1 migration_cpu_stop({.dest_cpu = CPU0})'. IOW, there is
nothing in that trace that queues a stopper work for 2. - it *will* happen
at some point, but harm will already have been done.
The migrate_task_to() example is potentially worse, because it doesn't rely
on which stopper work gets enqueued first - only that an extra affinity
change happens before the first stopper work grabs the pi_lock and completes.
prev parent reply other threads:[~2021-02-05 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 19:30 [RFC PATCH] sched/core: Fix premature p->migration_pending completion Valentin Schneider
[not found] ` <BN8PR12MB2978A9A4435A01EDC97D27E89ABA9@BN8PR12MB2978.namprd12.prod.outlook.com>
2021-01-28 18:56 ` Valentin Schneider
2021-02-03 17:23 ` Qais Yousef
2021-02-03 18:59 ` Valentin Schneider
2021-02-04 15:30 ` Qais Yousef
2021-02-05 11:02 ` Valentin Schneider [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=jhj1rdu3hh8.mognet@arm.com \
--to=valentin.schneider@arm.com \
--cc=bigeasy@linutronix.de \
--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@kernel.org \
--cc=peterz@infradead.org \
--cc=qais.yousef@arm.com \
--cc=rostedt@goodmis.org \
--cc=swood@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vincent.donnefort@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.