From 3da009b2504099c7ef50fd76ca78176cd927baed Mon Sep 17 00:00:00 2001 From: Ashay Jaiswal Date: Fri, 17 Nov 2023 10:41:28 +0530 Subject: [PATCH] sched: walt: crash system if UTRA is called without runqueue lock "update_task_ravg" is expected to be called with runqueue lock held by the caller, induce a panic if UTRA is called for a runqueue without it being locked. Also, add an early runqueue lock check in "__walt_irq_work_locked" to dump debug data and induce system crash. Change-Id: Ie7bb29a7845004b3c64541b32295bb61bbe32aba Signed-off-by: Ashay Jaiswal Signed-off-by: Shaleen Agrawal --- kernel/sched/walt/walt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index ac0e325346d4..03160e4eb13e 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -2359,6 +2359,14 @@ static void walt_update_task_ravg(struct task_struct *p, struct rq *rq, int even if (!wrq->window_start || wts->mark_start == wallclock) return; + if (unlikely(!raw_spin_is_locked(&rq->__lock))) { + printk_deferred("WALT-BUG CPU%d: %s task %s(%d) unlocked access for cpu=%d suspende=%d last_clk=%llu stack[%pS <== %pS <== %pS]\n", + raw_smp_processor_id(), __func__, p->comm, p->pid, rq->cpu, + walt_clock_suspended, sched_clock_last, + (void *)CALLER_ADDR0, (void *)CALLER_ADDR1, (void *)CALLER_ADDR2); + WALT_PANIC(1); + } + walt_lockdep_assert_rq(rq, p); old_window_start = update_window_start(rq, wallclock, event); @@ -4270,6 +4278,15 @@ static inline void __walt_irq_work_locked(bool is_migration, bool is_asym_migrat if (rq->curr) { /* only update ravg for locked cpus */ if (cpumask_intersects(lock_cpus, &cluster->cpus)) { + if (unlikely(!raw_spin_is_locked(&rq->__lock))) { + printk_deferred("WALT-BUG %s unlocked cpu=%d is_migration=%d is_asym_migration=%d is_shared_rail_migration=%d lock_cpus=%*pbl suspended=%d last_clk=%llu stack[%pS <= %pS <= %pS]\n", + __func__, rq->cpu, is_migration, is_asym_migration, + is_shared_rail_migration, + cpumask_pr_args(lock_cpus), walt_clock_suspended, + sched_clock_last, (void *)CALLER_ADDR0, + (void *)CALLER_ADDR1, (void *)CALLER_ADDR2); + WALT_PANIC(1); + } walt_update_task_ravg(rq->curr, rq, TASK_UPDATE, wc, 0); account_load_subtractions(rq);