ANDROID: sched/rt: Add schedtune accounting to rt task enqueue/dequeue
authorChris Redpath <chris.redpath@arm.com>
Mon, 9 Jul 2018 15:54:02 +0000 (16:54 +0100)
committerChris Redpath <chris.redpath@arm.com>
Fri, 20 Jul 2018 10:10:29 +0000 (10:10 +0000)
rt tasks are currently not eligible for schedtune boosting. Make it so
by adding enqueue/dequeue hooks.

For rt tasks, schedtune only acts as a frequency boosting framework, it
has no impact on placement decisions and the prefer_idle attribute is
not used.

Also prepare schedutil use of boosted util for rt task boosting

With this change, schedtune accounting will include rt class tasks,
however boosting currently only applies to the utilization provided by
fair class tasks. Sum up the tracked CPU utilization applying boost to
the aggregate util instead - this includes RT task util in the boosting
if any tasks are runnable.

Scenario 1, considering one CPU:
1x rt task running, util 250, boost 0
1x cfs task runnable, util 250, boost 50
 previous util=250+(50pct_boosted_250) = 887
 new      util=50_pct_boosted_500      = 762

Scenario 2, considering one CPU:
1x rt task running, util 250, boost 50
1x cfs task runnable, util 250, boost 0
 previous util=250+250                 = 500
 new      util=50_pct_boosted_500      = 762

Scenario 3, considering one CPU:
1x rt task running, util 250, boost 50
1x cfs task runnable, util 250, boost 50
 previous util=250+(50pct_boosted_250) = 887
 new      util=50_pct_boosted_500      = 762

Scenario 4:
1x rt task running, util 250, boost 50
 previous util=250                 = 250
 new      util=50_pct_boosted_250  = 637

Change-Id: Ie287cbd0692468525095b5024db9faac8b2f4878
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
kernel/sched/cpufreq_schedutil.c
kernel/sched/fair.c
kernel/sched/rt.c

index 7560daeda9ccdcf67f46d497e0c4c6eb4a3d66e8..d70794a6ee83f906a259e37e44f3936b50f368b7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "sched.h"
 
-unsigned long boosted_cpu_util(int cpu);
+unsigned long boosted_cpu_util(int cpu, unsigned long other_util);
 
 #define SUGOV_KTHREAD_PRIORITY 50
 
@@ -216,7 +216,7 @@ static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu)
 
        rt = sched_get_rt_rq_util(cpu);
 
-       *util = boosted_cpu_util(cpu) + rt;
+       *util = boosted_cpu_util(cpu, rt);
        *util = min(*util, max_cap);
        *max = max_cap;
 }
index 8862fadbef9796fd9a2c3bc3b96a97238189f066..5e828914bf9172aaaed611e7f495ffed898541ca 100644 (file)
@@ -5173,11 +5173,11 @@ static inline void update_overutilized_status(struct rq *rq)
        rcu_read_unlock();
 }
 
-unsigned long boosted_cpu_util(int cpu);
+unsigned long boosted_cpu_util(int cpu, unsigned long other_util);
 #else
 
 #define update_overutilized_status(rq) do {} while (0)
-#define boosted_cpu_util(cpu) cpu_util_freq(cpu)
+#define boosted_cpu_util(cpu, other_util) cpu_util_freq(cpu)
 
 #endif /* CONFIG_SMP */
 
@@ -6644,9 +6644,9 @@ schedtune_task_margin(struct task_struct *task)
 #endif /* CONFIG_SCHED_TUNE */
 
 unsigned long
-boosted_cpu_util(int cpu)
+boosted_cpu_util(int cpu, unsigned long other_util)
 {
-       unsigned long util = cpu_util_freq(cpu);
+       unsigned long util = cpu_util_freq(cpu) + other_util;
        long margin = schedtune_cpu_margin(util, cpu);
 
        trace_sched_boost_cpu(cpu, util, margin);
index 0adcb226f30c17b000b23ae8963f7428c692f04e..69222ceeb0b19117ad9a91a53e4c5e90a6f07d66 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/slab.h>
 #include <linux/irq_work.h>
+#include "tune.h"
 
 #include "walt.h"
 
@@ -1324,6 +1325,8 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags)
 {
        struct sched_rt_entity *rt_se = &p->rt;
 
+       schedtune_enqueue_task(p, cpu_of(rq));
+
        if (flags & ENQUEUE_WAKEUP)
                rt_se->timeout = 0;
 
@@ -1338,6 +1341,8 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags)
 {
        struct sched_rt_entity *rt_se = &p->rt;
 
+       schedtune_dequeue_task(p, cpu_of(rq));
+
        update_curr_rt(rq);
        dequeue_rt_entity(rt_se, flags);
        walt_dec_cumulative_runnable_avg(rq, p);