From 4ef9aa1b493e00a7abd3872dd0b7b86e8a2a1c9c Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 6 Feb 2023 12:29:54 +0000 Subject: [PATCH] Revert "ANDROID: sched: Move scratch_mask to a percpu variable" This reverts commit 08ef1640273d065319a0766084b85893eb2f6379. This series is responsible for a functional regression with task affinity failing to take into account offline CPUs. Although this has been reported upstream, work to fix the problem is ongoing and we're better off reverting these changes from android13-5.15. Link: https://lore.kernel.org/lkml/20230131221719.3176-1-will@kernel.org/ Signed-off-by: Will Deacon Bug: 263926519 Bug: 264940090 Change-Id: I521119817f3e6c107984197a8c0b170430f5b702 --- kernel/sched/core.c | 12 +++--------- kernel/sched/sched.h | 3 +++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a4a9e0ce7a6f..ef48b8600f0f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -58,9 +58,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_stat_blocked); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); EXPORT_SYMBOL_GPL(runqueues); -/* Scratch cpumask to be temporarily used under rq_lock */ -DEFINE_PER_CPU(cpumask_var_t, scratch_mask); - #ifdef CONFIG_SCHED_DEBUG /* * Debugging: various feature bits @@ -2975,20 +2972,18 @@ static int __set_cpus_allowed_ptr_locked(struct task_struct *p, static int __set_cpus_allowed_ptr(struct task_struct *p, struct affinity_context *ctx) { - struct cpumask *cpus; struct rq_flags rf; struct rq *rq; rq = task_rq_lock(p, &rf); - cpus = per_cpu(scratch_mask, rq->cpu); /* * Masking should be skipped if SCA_USER or any of the SCA_MIGRATE_* * flags are set. */ if (p->user_cpus_ptr && !(ctx->flags & (SCA_USER | SCA_MIGRATE_ENABLE | SCA_MIGRATE_DISABLE)) && - cpumask_and(cpus, ctx->new_mask, p->user_cpus_ptr)) - ctx->new_mask = cpus; + cpumask_and(rq->scratch_mask, ctx->new_mask, p->user_cpus_ptr)) + ctx->new_mask = rq->scratch_mask; return __set_cpus_allowed_ptr_locked(p, ctx, rq, &rf); } @@ -9655,8 +9650,6 @@ void __init sched_init(void) cpumask_size(), GFP_KERNEL, cpu_to_node(i)); per_cpu(select_idle_mask, i) = (cpumask_var_t)kzalloc_node( cpumask_size(), GFP_KERNEL, cpu_to_node(i)); - per_cpu(scratch_mask, i) = (cpumask_var_t)kzalloc_node( - cpumask_size(), GFP_KERNEL, cpu_to_node(i)); } #endif /* CONFIG_CPUMASK_OFFSTACK */ @@ -9762,6 +9755,7 @@ void __init sched_init(void) rq->core_cookie = 0UL; #endif + zalloc_cpumask_var_node(&rq->scratch_mask, GFP_KERNEL, cpu_to_node(i)); } set_load_weight(&init_task, false); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 5f536dd51918..ca78455a6027 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1130,6 +1130,9 @@ struct rq { unsigned int core_forceidle_seq; #endif + /* Scratch cpumask to be temporarily used under rq_lock */ + cpumask_var_t scratch_mask; + ANDROID_VENDOR_DATA_ARRAY(1, 96); ANDROID_OEM_DATA_ARRAY(1, 16);