From 51542a1e24def1997fcd71d7e0816aafb6f5b7a3 Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Thu, 15 Jul 2021 16:02:16 -0700 Subject: [PATCH] sched/walt_rt: Honor sync wakeups The current code does not honor sync wakeup. Make it do that. Change-Id: I509fd704accdebd32ad2281c26a23e2044c6dc09 Signed-off-by: Stephen Dickey --- kernel/sched/walt/walt_rt.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/kernel/sched/walt/walt_rt.c b/kernel/sched/walt/walt_rt.c index 5ae1936151ad..ce424b08e804 100644 --- a/kernel/sched/walt/walt_rt.c +++ b/kernel/sched/walt/walt_rt.c @@ -110,13 +110,26 @@ static inline bool walt_rt_task_fits_capacity(struct task_struct *p, int cpu) } #endif +/* + * walt specific should_honor_rt_sync (see rt.c). this will honor + * the sync flag regardless of whether the current waker is cfs or rt + */ +static inline bool walt_should_honor_rt_sync(struct rq *rq, struct task_struct *p, + bool sync) +{ + return sync && + p->prio <= rq->rt.highest_prio.next && + rq->rt.rt_nr_running <= 2; +} + static void walt_select_task_rq_rt(void *unused, struct task_struct *task, int cpu, int sd_flag, int wake_flags, int *new_cpu) { struct task_struct *curr; - struct rq *rq; + struct rq *rq, *this_cpu_rq; bool may_not_preempt; - int ret, target = -1; + bool sync = !!(wake_flags && WF_SYNC); + int ret, target = -1, this_cpu; struct cpumask *lowest_mask; if (unlikely(walt_disabled)) @@ -126,6 +139,19 @@ static void walt_select_task_rq_rt(void *unused, struct task_struct *task, int c if (sd_flag != SD_BALANCE_WAKE && sd_flag != SD_BALANCE_FORK) return; + this_cpu = raw_smp_processor_id(); + this_cpu_rq = cpu_rq(this_cpu); + + /* + * Respect the sync flag as long as the task can run on this CPU. + */ + if (sysctl_sched_sync_hint_enable && cpu_active(this_cpu) && + cpumask_test_cpu(this_cpu, task->cpus_ptr) && + walt_should_honor_rt_sync(this_cpu_rq, task, sync)) { + *new_cpu = this_cpu; + return; + } + *new_cpu = cpu; /* previous CPU as back up */ rq = cpu_rq(cpu);