From ffce2634bcbcf2b8a75125d8fe91fdeec284d7bc Mon Sep 17 00:00:00 2001 From: Tengfei Fan Date: Thu, 11 Nov 2021 09:38:18 +0800 Subject: [PATCH] sched/walt: remove task from mvp list if task in yield When a task yields, it relinquishes the cpu and scheduler is tasked to find another task. However he MVP implementation could return the same task leading to a loop where the yielded task gets to run back. To fix this, drop the MVP status of tasks that yield themselves. The MVP status is restored the next time they actually get enqueued - -likely because of a wakeup from sleep or task migration. Change-Id: Ia2a2074f18c4de56e0695ee2c5f1daf8a4eb5980 Signed-off-by: Tengfei Fan Signed-off-by: Sai Harshini Nimmala --- kernel/sched/walt/walt_cfs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/sched/walt/walt_cfs.c b/kernel/sched/walt/walt_cfs.c index 68b2d887654e..2bfc05833d59 100644 --- a/kernel/sched/walt/walt_cfs.c +++ b/kernel/sched/walt/walt_cfs.c @@ -1100,6 +1100,16 @@ static void walt_cfs_account_mvp_runtime(struct rq *rq, struct task_struct *curr walt_cfs_insert_mvp_task(wrq, wts, false); } +static void walt_cfs_mvp_do_sched_yield(void *unused, struct rq *rq) +{ + struct task_struct *curr = rq->curr; + int mvp_prio = walt_get_mvp_task_prio(curr); + + lockdep_assert_held(&rq->__lock); + if (mvp_prio != WALT_NOT_MVP) + walt_cfs_deactivate_mvp_task(curr); +} + void walt_cfs_enqueue_task(struct rq *rq, struct task_struct *p) { struct walt_rq *wrq = (struct walt_rq *) rq->android_vendor_data1; @@ -1282,4 +1292,6 @@ void walt_cfs_init(void) register_trace_android_rvh_check_preempt_wakeup(walt_cfs_check_preempt_wakeup, NULL); register_trace_android_rvh_replace_next_task_fair(walt_cfs_replace_next_task_fair, NULL); + + register_trace_android_rvh_do_sched_yield(walt_cfs_mvp_do_sched_yield, NULL); }