From 6c47bb351ead4e19c6e20c88d1c2a1c9ae40bc99 Mon Sep 17 00:00:00 2001 From: Shaleen Agrawal Date: Thu, 3 Jun 2021 10:11:03 -0700 Subject: [PATCH] sched:walt: register restricted tracehooks for race with pause The current code in force_compatible_cpus_allowed_ptr() holds just the cpus_read_lock, i.e. serializes with the second step of pause. However it doesn't serialize with the first step. IOW, a CPUX chosen in __set_cpus_allowed_ptr_locked() may end up getting deactivated in the pause first and stopper ends up returning early in __migrate_tasks() leaving the 32bit task on an invalid CPU. A simple fix is to serialize force_compatible_cpus_allowed_ptr() with pause first step. Add a cpu_maps_update_begin/done() in force_compatible_cpus_allowed_ptr(). Change-Id: I24e7838ee9813b4336bfcebc823e498c3606c793 Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/walt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index dd925a739681..f27eaa2ccff4 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -4115,6 +4115,20 @@ static void android_rvh_build_perf_domains(void *unused, bool *eas_check) *eas_check = true; } +static void android_rvh_force_compatible_pre(void *unused, void *unused2) +{ + if (unlikely(walt_disabled)) + return; + cpu_maps_update_begin(); +} + +static void android_rvh_force_compatible_post(void *unused, void *unused2) +{ + if (unlikely(walt_disabled)) + return; + cpu_maps_update_done(); +} + static void register_walt_hooks(void) { register_trace_android_rvh_wake_up_new_task(android_rvh_wake_up_new_task, NULL); @@ -4144,6 +4158,8 @@ static void register_walt_hooks(void) register_trace_android_rvh_sched_exec(android_rvh_sched_exec, NULL); register_trace_android_rvh_build_perf_domains(android_rvh_build_perf_domains, NULL); register_trace_cpu_frequency_limits(walt_cpu_frequency_limits, NULL); + register_trace_android_rvh_force_compatible_pre(android_rvh_force_compatible_pre, NULL); + register_trace_android_rvh_force_compatible_post(android_rvh_force_compatible_post, NULL); } atomic64_t walt_irq_work_lastq_ws;