From 06de20685970998a91fe50e3d4a7e1d6a66a6688 Mon Sep 17 00:00:00 2001 From: Joel Fernandes <joelaf@google.com> Date: Wed, 21 Jun 2017 18:15:46 -0700 Subject: [PATCH] sched: rt: Avoid CPUs running top apps if possible If an RT task was running on a CPU some time back and a top-app happen to be running later, then when the RT task wakes up, we will blindly wake up the RT task on its previous CPU thus preventing the top-app from running until the RT task sleeps. RT tasks can run on any available CPU that's lower in priority than itself so we should look at all possible options under this condition. Incase no option is available, it will fallback to preempting the top-app as before. Tests: * Improvement in UiBench GLTextureView seen which gets us to the N levels. Other benchmarks show good or better performance. * No energy increases seen with UiBench GLTextureView and Camera preview. bug: 62806392 Change-Id: Ifea9157c23decc34f64ce8ab87df8ac4d1bcb3c3 Signed-off-by: Joel Fernandes <joelaf@google.com> --- kernel/sched/rt.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 4d25a1f400f0..d1c0952eb22a 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1488,6 +1488,20 @@ static bool softirq_masked(int pc) return !!((pc & SOFTIRQ_MASK)>= SOFTIRQ_DISABLE_OFFSET); } +static bool is_top_app_cpu(int cpu) +{ + bool boosted = (schedtune_cpu_boost(cpu) > 0); + + return boosted; +} + +static bool is_top_app(struct task_struct *cur) +{ + bool boosted = (schedtune_task_boost(cur) > 0); + + return boosted; +} + /* * Return whether the task on the given cpu is currently non-preemptible * while handling a potentially long softint, or if the task is likely @@ -1502,8 +1516,14 @@ task_may_not_preempt(struct task_struct *task, int cpu) struct task_struct *cpu_ksoftirqd = per_cpu(ksoftirqd, cpu); int task_pc = 0; - if (task) + if (task) { + if (is_top_app(task)) + return true; task_pc = task_preempt_count(task); + } + + if (is_top_app_cpu(cpu)) + return true; if (softirq_masked(task_pc)) return true; -- GitLab