From 5ca19b7ae16cbe499556896f2eddc6dbc469eaac Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Fri, 12 Aug 2022 16:37:20 -0700 Subject: [PATCH] kernel/sched/walt: rd->pd not getting updated soon enough If the energy model is not updated by the time rebalance_domains is called for the first time, the root domain -> perf_domain values will get erased completely, and will be invalid. The responsibility for this race is outside of the walt module. walt_find_energy_efficient_cpu() relies upon rd->pd being valid and cannot function properly without it. This is critical to proper walt functionality and it cannot move forward without it. Decisvely catch the failure. Change-Id: Iee8030afd487dcee1d9cc18c2d655ecc26938279 Signed-off-by: Stephen Dickey --- kernel/sched/walt/walt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index 5f4bd7949cc5..be0db1478575 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -4559,6 +4559,7 @@ static void walt_init(struct work_struct *work) { struct ctl_table_header *hdr; static atomic_t already_inited = ATOMIC_INIT(0); + struct root_domain *rd = cpu_rq(cpumask_first(cpu_active_mask))->rd; int i; might_sleep(); @@ -4600,6 +4601,11 @@ static void walt_init(struct work_struct *work) } topology_clear_scale_freq_source(SCALE_FREQ_SOURCE_ARCH, cpu_online_mask); + + if (!rcu_dereference(rd->pd)) + WALT_BUG(WALT_BUG_WALT, NULL, + "root domain's perf-domain values not initialized rd->pd=%d.", + rd->pd); } static DECLARE_WORK(walt_init_work, walt_init);