From 1093a9bfdbd2ec8f4eab207d2ecc33efd84c4b83 Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Fri, 25 Jun 2021 18:31:30 -0700 Subject: [PATCH] ANDROID: sched: select fallback rq must check for allowed cpus select_fallback_rq() must return a cpu that is valid for the task. However, when nid is not -1, it skips checking for task_cpu_possible_mask(). This causes a problem when execve-ing 32 bit apps on an asymmetric system where not all cpus are 32 bit capable. During execve-ing the task is marked as 32 bit long before its affinity mask is restricted. If the cpu goes offline during this time, select_fallback_rq() could return a 64 bit only cpu, which __migrate_tasks()/ is_cpu_allowed() rejects. migrate_tasks() will therefore continue to pick the same task repeatedly, where __migrate_tasks() rejects the cpu chosen by select_fallback_rq() every time, leading to an infinite loop. Correct the issue by updating select_fallback_rq() for the case where nid is not -1, ensuring that the returned cpu is always valid for this task. Bug: 192050156 Change-Id: Ia073a8395a02485f6d1c1daa0f3ce9e2029cb1f4 Signed-off-by: Stephen Dickey --- kernel/sched/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 64288d005bb4..46a113c8bc2e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2482,9 +2482,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p) /* Look for allowed, online CPU in same node. */ for_each_cpu(dest_cpu, nodemask) { - if (!cpu_active(dest_cpu)) - continue; - if (cpumask_test_cpu(dest_cpu, p->cpus_ptr)) + if (is_cpu_allowed(p, dest_cpu)) return dest_cpu; } }