diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:06:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:06:00 +0000 |
commit | b15a952c52a6825376d3e7f6c1bf5c886c6d8b74 (patch) | |
tree | 1500f2f8f276908a36d8126cb632c0d6b1276764 /debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch | |
parent | Adding upstream version 5.10.209. (diff) | |
download | linux-debian.tar.xz linux-debian.zip |
Adding debian version 5.10.209-2.debian/5.10.209-2debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch')
-rw-r--r-- | debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch b/debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch new file mode 100644 index 000000000..19fcddc66 --- /dev/null +++ b/debian/patches-rt/0023-sched-core-Add-missing-completion-for-affine_move_ta.patch @@ -0,0 +1,79 @@ +From 5188e4c01f37c8c179cf88261297d546f5d2502e Mon Sep 17 00:00:00 2001 +From: Valentin Schneider <valentin.schneider@arm.com> +Date: Fri, 13 Nov 2020 11:24:14 +0000 +Subject: [PATCH 023/323] sched/core: Add missing completion for + affine_move_task() waiters +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.10/older/patches-5.10.204-rt100.tar.xz + +Qian reported that some fuzzer issuing sched_setaffinity() ends up stuck on +a wait_for_completion(). The problematic pattern seems to be: + + affine_move_task() + // task_running() case + stop_one_cpu(); + wait_for_completion(&pending->done); + +Combined with, on the stopper side: + + migration_cpu_stop() + // Task moved between unlocks and scheduling the stopper + task_rq(p) != rq && + // task_running() case + dest_cpu >= 0 + + => no complete_all() + +This can happen with both PREEMPT and !PREEMPT, although !PREEMPT should +be more likely to see this given the targeted task has a much bigger window +to block and be woken up elsewhere before the stopper runs. + +Make migration_cpu_stop() always look at pending affinity requests; signal +their completion if the stopper hits a rq mismatch but the task is +still within its allowed mask. When Migrate-Disable isn't involved, this +matches the previous set_cpus_allowed_ptr() vs migration_cpu_stop() +behaviour. + +Fixes: 6d337eab041d ("sched: Fix migrate_disable() vs set_cpus_allowed_ptr()") +Reported-by: Qian Cai <cai@redhat.com> +Signed-off-by: Valentin Schneider <valentin.schneider@arm.com> +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> +Link: https://lore.kernel.org/lkml/8b62fd1ad1b18def27f18e2ee2df3ff5b36d0762.camel@redhat.com +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/sched/core.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 7d67a0e03f9a..c1e52319669d 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -1941,7 +1941,7 @@ static int migration_cpu_stop(void *data) + else + p->wake_cpu = dest_cpu; + +- } else if (dest_cpu < 0) { ++ } else if (dest_cpu < 0 || pending) { + /* + * This happens when we get migrated between migrate_enable()'s + * preempt_enable() and scheduling the stopper task. At that +@@ -1951,6 +1951,17 @@ static int migration_cpu_stop(void *data) + * more likely. + */ + ++ /* ++ * The task moved before the stopper got to run. We're holding ++ * ->pi_lock, so the allowed mask is stable - if it got ++ * somewhere allowed, we're done. ++ */ ++ if (pending && cpumask_test_cpu(task_cpu(p), p->cpus_ptr)) { ++ p->migration_pending = NULL; ++ complete = true; ++ goto out; ++ } ++ + /* + * When this was migrate_enable() but we no longer have an + * @pending, a concurrent SCA 'fixed' things and we should be +-- +2.43.0 + |