]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sched/deadline: Implement GRUB accounting
authorLuca Abeni <luca.abeni@santannapisa.it>
Thu, 18 May 2017 20:13:31 +0000 (22:13 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 8 Jun 2017 08:31:51 +0000 (10:31 +0200)
According to the GRUB (Greedy Reclaimation of Unused Bandwidth)
reclaiming algorithm, the runtime is not decreased as "dq = -dt",
but as "dq = -Uact dt" (where Uact is the per-runqueue active
utilization).
Hence, this commit modifies the runtime accounting rule in
update_curr_dl() to implement the GRUB rule.

Tested-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Luca Abeni <luca.abeni@santannapisa.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Claudio Scordino <claudio@evidence.eu.com>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Juri Lelli <juri.lelli@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Link: http://lkml.kernel.org/r/1495138417-6203-5-git-send-email-luca.abeni@santannapisa.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c
kernel/sched/deadline.c
kernel/sched/sched.h

index 126339daebd7ca250282c67e055de7483dd00ecb..b68a1fa052449a96a9b0dd116831fb5154d5c62d 100644 (file)
@@ -2423,7 +2423,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
 unsigned long to_ratio(u64 period, u64 runtime)
 {
        if (runtime == RUNTIME_INF)
-               return 1ULL << 20;
+               return BW_UNIT;
 
        /*
         * Doing this here saves a lot of checks in all
@@ -2433,7 +2433,7 @@ unsigned long to_ratio(u64 period, u64 runtime)
        if (period == 0)
                return 0;
 
-       return div64_u64(runtime << 20, period);
+       return div64_u64(runtime << BW_SHIFT, period);
 }
 
 #ifdef CONFIG_SMP
index add9cba1253cf27a6ef93d7536320f1e39ecde2b..0bee537554f6dd79ef30868aa9115a0a84eab5e4 100644 (file)
@@ -917,6 +917,22 @@ int dl_runtime_exceeded(struct sched_dl_entity *dl_se)
 
 extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
 
+/*
+ * This function implements the GRUB accounting rule:
+ * according to the GRUB reclaiming algorithm, the runtime is
+ * not decreased as "dq = -dt", but as "dq = -Uact dt", where
+ * Uact is the (per-runqueue) active utilization.
+ * Since rq->dl.running_bw contains Uact * 2^BW_SHIFT, the result
+ * has to be shifted right by BW_SHIFT.
+ */
+u64 grub_reclaim(u64 delta, struct rq *rq)
+{
+       delta *= rq->dl.running_bw;
+       delta >>= BW_SHIFT;
+
+       return delta;
+}
+
 /*
  * Update the current task's runtime statistics (provided it is still
  * a -deadline task and has not been removed from the dl_rq).
@@ -959,6 +975,7 @@ static void update_curr_dl(struct rq *rq)
 
        sched_rt_avg_update(rq, delta_exec);
 
+       delta_exec = grub_reclaim(delta_exec, rq);
        dl_se->runtime -= delta_exec;
 
 throttle:
index c58f38905e0ab8f174b11abe9a3442de42bbfbb9..bb409ef401200282175bab91b2661644ceaba300 100644 (file)
@@ -1496,6 +1496,8 @@ extern void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime
 extern void init_dl_task_timer(struct sched_dl_entity *dl_se);
 extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se);
 
+#define BW_SHIFT       20
+#define BW_UNIT                (1 << BW_SHIFT)
 unsigned long to_ratio(u64 period, u64 runtime);
 
 extern void init_entity_runnable_average(struct sched_entity *se);