From: Valentin Schneider <valentin.schneider@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
mingo@kernel.org, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com,
cai@redhat.com, vincent.donnefort@arm.com, decui@microsoft.com,
paulmck@kernel.org, vincent.guittot@linaro.org,
rostedt@goodmis.org, tj@kernel.org, peterz@infradead.org
Subject: Re: [PATCH 7/8] sched: Fix CPU hotplug / tighten is_per_cpu_kthread()
Date: Sun, 17 Jan 2021 16:57:27 +0000 [thread overview]
Message-ID: <jhjsg6z4i2w.mognet@arm.com> (raw)
In-Reply-To: <20210116113920.103635633@infradead.org>
On 16/01/21 12:30, Peter Zijlstra wrote:
> @@ -1796,13 +1796,28 @@ static inline bool rq_has_pinned_tasks(s
> */
> static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
> {
> + /* When not in the task's cpumask, no point in looking further. */
> if (!cpumask_test_cpu(cpu, p->cpus_ptr))
> return false;
>
> - if (is_per_cpu_kthread(p) || is_migration_disabled(p))
> + /* migrate_disabled() must be allowed to finish. */
> + if (is_migration_disabled(p))
> return cpu_online(cpu);
>
> - return cpu_active(cpu);
> + /* Non kernel threads are not allowed during either online or offline. */
> + if (!(p->flags & PF_KTHREAD))
> + return cpu_active(cpu);
> +
> + /* KTHREAD_IS_PER_CPU is always allowed. */
> + if (kthread_is_per_cpu(p))
> + return cpu_online(cpu);
> +
> + /* Regular kernel threads don't get to stay during offline. */
> + if (cpu_rq(cpu)->balance_callback == &balance_push_callback)
> + return cpu_active(cpu);
is_cpu_allowed(, cpu) isn't guaranteed to have cpu_rq(cpu)'s rq_lock
held, so this can race with balance_push_set(, true). This shouldn't
matter under normal circumstances as we'll have sched_cpu_wait_empty()
further down the line.
This might get ugly with the rollback faff - this is jumping the gun a
bit, but that's something we'll have to address, and I think what I'm
concerned about is close to what you mentioned in
http://lore.kernel.org/r/YAM1t2Qzr7Rib3bN@hirez.programming.kicks-ass.net
Here's what I'm thinking of:
_cpu_up() ttwu()
select_task_rq()
is_cpu_allowed()
rq->balance_callback != balance_push_callback
smpboot_unpark_threads() // FAIL
(now going down, set push here)
sched_cpu_wait_empty()
... ttwu_queue()
sched_cpu_dying()
*ARGH*
I've written some horrors on top of this series here:
https://gitlab.arm.com/linux-arm/linux-vs/-/commits/mainline/migrate_disable/stragglers/
Also, my TX2 is again in need of CPR, so in the meantime I'm running
tests on a (much) smaller machine...
> +
> + /* But are allowed during online. */
> + return cpu_online(cpu);
> }
next prev parent reply other threads:[~2021-01-17 16:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-16 11:30 [PATCH 0/8] sched: Fix hot-unplug regressions Peter Zijlstra
2021-01-16 11:30 ` [PATCH 1/8] sched/core: Print out straggler tasks in sched_cpu_dying() Peter Zijlstra
2021-01-16 11:30 ` [PATCH 2/8] workqueue: Use cpu_possible_mask instead of cpu_active_mask to break affinity Peter Zijlstra
2021-01-16 11:30 ` [PATCH 3/8] sched: Dont run cpu-online with balance_push() enabled Peter Zijlstra
2021-01-16 15:27 ` Peter Zijlstra
2021-01-16 11:30 ` [PATCH 4/8] kthread: Extract KTHREAD_IS_PER_CPU Peter Zijlstra
2021-01-16 11:30 ` [PATCH 5/8] workqueue: Tag bound workers with KTHREAD_IS_PER_CPU Peter Zijlstra
2021-01-16 11:30 ` [PATCH 6/8] workqueue: Restrict affinity change to rescuer Peter Zijlstra
2021-01-16 11:30 ` [PATCH 7/8] sched: Fix CPU hotplug / tighten is_per_cpu_kthread() Peter Zijlstra
2021-01-17 16:57 ` Valentin Schneider [this message]
2021-01-18 9:30 ` Peter Zijlstra
2021-01-16 11:30 ` [PATCH 8/8] sched: Relax the set_cpus_allowed_ptr() semantics Peter Zijlstra
2021-01-16 14:39 ` Lai Jiangshan
2021-01-16 15:19 ` Peter Zijlstra
2021-01-16 15:25 ` [PATCH 0/8] sched: Fix hot-unplug regressions Peter Zijlstra
2021-01-16 15:45 ` Paul E. McKenney
2021-01-16 18:51 ` Peter Zijlstra
2021-01-16 15:48 ` Paul E. McKenney
2021-01-18 5:28 ` Paul E. McKenney
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=jhjsg6z4i2w.mognet@arm.com \
--to=valentin.schneider@arm.com \
--cc=cai@redhat.com \
--cc=decui@microsoft.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox