lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v4 11/19] sched/core: Make migrate disable and CPU hotplug cooperative
On Thu, Oct 29, 2020 at 04:27:09PM +0000, Valentin Schneider wrote:
>
> On 23/10/20 11:12, Peter Zijlstra wrote:
> > @@ -7006,15 +7024,20 @@ static bool balance_push(struct rq *rq)
> > * Both the cpu-hotplug and stop task are in this case and are
> > * required to complete the hotplug process.
> > */
> > - if (is_per_cpu_kthread(push_task)) {
> > + if (is_per_cpu_kthread(push_task) || is_migration_disabled(push_task)) {
>
> is_migration_disabled(p) implies rq_has_pinned_tasks(task_rq(p)), right?

In general, no, in this particular case, yes. Specifically you need
migrate_disable() + schedule() in order to get nr_pinned incremented.

We just happen to run at the tail end of schedule(), so yeah, here it
works.

> So having a "simple"
>
> if (is_migration_disabled(push_task))
> return;
>
> would help simpletons like me trying to read through this.

Can do I suppose, although I'm no sure what, if anything that helps,
because then we needs yet another comment explaining things.

I ended up with the below. Is that an improvement?

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3d7d5b7b9c99..c9c69511ece4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7226,11 +7226,19 @@ static void balance_push(struct rq *rq)
lockdep_assert_held(&rq->lock);
SCHED_WARN_ON(rq->cpu != smp_processor_id());

+ /*
+ * When migrate_disable(), we'll also have nr_pinned incremented due to
+ * this being the tail end of schedule(). Therefore we do not need to wake
+ * the hotplug_wait and go straight to jail^Wexit.
+ */
+ if (is_migration_disabled(push_task))
+ return;
+
/*
* Both the cpu-hotplug and stop task are in this case and are
* required to complete the hotplug process.
*/
- if (is_per_cpu_kthread(push_task) || is_migration_disabled(push_task)) {
+ if (is_per_cpu_kthread(push_task)) {
/*
* If this is the idle task on the outgoing CPU try to wake
* up the hotplug control thread which might wait for the
\
 
 \ /
  Last update: 2020-10-29 18:34    [W:0.118 / U:2.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site