sched/hotplug: Ensure only per-cpu kthreads run during hotplug
authorPeter Zijlstra <peterz@infradead.org>
Fri, 11 Sep 2020 07:54:27 +0000 (09:54 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 10 Nov 2020 17:38:57 +0000 (18:38 +0100)
commit2558aacff8586699bcd248b406febb28b0a25de2
treec8f47dc0cfccccadbc30bad72f842a0d12cf5a40
parent565790d28b1e33ee2f77bad5348b99f6dfc366fd
sched/hotplug: Ensure only per-cpu kthreads run during hotplug

In preparation for migrate_disable(), make sure only per-cpu kthreads
are allowed to run on !active CPUs.

This is ran (as one of the very first steps) from the cpu-hotplug
task which is a per-cpu kthread and completion of the hotplug
operation only requires such tasks.

This constraint enables the migrate_disable() implementation to wait
for completion of all migrate_disable regions on this CPU at hotplug
time without fear of any new ones starting.

This replaces the unlikely(rq->balance_callbacks) test at the tail of
context_switch with an unlikely(rq->balance_work), the fast path is
not affected.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Link: https://lkml.kernel.org/r/20201023102346.292709163@infradead.org
kernel/sched/core.c
kernel/sched/sched.h