2020-07-15 20:05:29 +00:00
|
|
|
From 18a4d5ba2aee960585e70cbbb404d7607da4a434 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <18a4d5ba2aee960585e70cbbb404d7607da4a434.1594742967.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <832f7d97d6b989a5b4860dd2dbec58ad6ad5ab81.1594742966.git.zanussi@kernel.org>
|
|
|
|
References: <832f7d97d6b989a5b4860dd2dbec58ad6ad5ab81.1594742966.git.zanussi@kernel.org>
|
2020-02-21 18:07:43 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Date: Thu, 12 Dec 2019 10:53:59 +0100
|
2020-07-15 20:05:29 +00:00
|
|
|
Subject: [PATCH 314/329] sched: migrate_enable: Busy loop until the migration
|
2020-02-21 18:07:43 +00:00
|
|
|
request is completed
|
2020-07-15 20:05:29 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.132-rt59.tar.xz
|
2020-02-21 18:07:43 +00:00
|
|
|
|
|
|
|
[ Upstream commit 140d7f54a5fff02898d2ca9802b39548bf7455f1 ]
|
|
|
|
|
|
|
|
If user task changes the CPU affinity mask of a running task it will
|
|
|
|
dispatch migration request if the current CPU is no longer allowed. This
|
|
|
|
might happen shortly before a task enters a migrate_disable() section.
|
|
|
|
Upon leaving the migrate_disable() section, the task will notice that
|
|
|
|
the current CPU is no longer allowed and will will dispatch its own
|
|
|
|
migration request to move it off the current CPU.
|
|
|
|
While invoking __schedule() the first migration request will be
|
|
|
|
processed and the task returns on the "new" CPU with "arg.done = 0". Its
|
|
|
|
own migration request will be processed shortly after and will result in
|
|
|
|
memory corruption if the stack memory, designed for request, was used
|
|
|
|
otherwise in the meantime.
|
|
|
|
|
|
|
|
Spin until the migration request has been processed if it was accepted.
|
|
|
|
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
|
|
|
|
---
|
|
|
|
kernel/sched/core.c | 7 +++++--
|
|
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
2020-07-15 20:05:29 +00:00
|
|
|
index 8f0870474a82..fee3b5427f8b 100644
|
2020-02-21 18:07:43 +00:00
|
|
|
--- a/kernel/sched/core.c
|
|
|
|
+++ b/kernel/sched/core.c
|
2020-07-15 20:05:29 +00:00
|
|
|
@@ -7322,7 +7322,7 @@ void migrate_enable(void)
|
2020-02-21 18:07:43 +00:00
|
|
|
|
|
|
|
WARN_ON(smp_processor_id() != cpu);
|
|
|
|
if (!is_cpu_allowed(p, cpu)) {
|
|
|
|
- struct migration_arg arg = { p };
|
|
|
|
+ struct migration_arg arg = { .task = p };
|
|
|
|
struct cpu_stop_work work;
|
|
|
|
struct rq_flags rf;
|
|
|
|
|
2020-07-15 20:05:29 +00:00
|
|
|
@@ -7335,7 +7335,10 @@ void migrate_enable(void)
|
2020-02-21 18:07:43 +00:00
|
|
|
&arg, &work);
|
|
|
|
tlb_migrate_finish(p->mm);
|
|
|
|
__schedule(true);
|
|
|
|
- WARN_ON_ONCE(!arg.done && !work.disabled);
|
|
|
|
+ if (!work.disabled) {
|
|
|
|
+ while (!arg.done)
|
|
|
|
+ cpu_relax();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-02-21 18:07:43 +00:00
|
|
|
|