diff options
author | Juri Lelli <juri.lelli@arm.com> | 2017-12-04 05:23:25 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-01-10 06:53:35 -0500 |
commit | 07881166a892fa4908ac4924660a7793f75d6544 (patch) | |
tree | 0d92caf015cf48751c8f0d6e93d9a4c2b0b27720 | |
parent | 7e1a9208f6c7e66bb4e5d2ed18dfd191230f431b (diff) |
sched/deadline: Make bandwidth enforcement scale-invariant
Apply frequency and CPU scale-invariance correction factor to bandwidth
enforcement (similar to what we already do to fair utilization tracking).
Each delta_exec gets scaled considering current frequency and maximum
CPU capacity; which means that the reservation runtime parameter (that
need to be specified profiling the task execution at max frequency on
biggest capacity core) gets thus scaled accordingly.
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Claudio Scordino <claudio@evidence.eu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luca Abeni <luca.abeni@santannapisa.it>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: alessio.balsini@arm.com
Cc: bristot@redhat.com
Cc: dietmar.eggemann@arm.com
Cc: joelaf@google.com
Cc: juri.lelli@redhat.com
Cc: mathieu.poirier@linaro.org
Cc: morten.rasmussen@arm.com
Cc: patrick.bellasi@arm.com
Cc: rjw@rjwysocki.net
Cc: rostedt@goodmis.org
Cc: tkjos@android.com
Cc: tommaso.cucinotta@santannapisa.it
Cc: vincent.guittot@linaro.org
Link: http://lkml.kernel.org/r/20171204102325.5110-9-juri.lelli@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/sched/deadline.c | 26 | ||||
-rw-r--r-- | kernel/sched/fair.c | 2 | ||||
-rw-r--r-- | kernel/sched/sched.h | 2 |
3 files changed, 24 insertions, 6 deletions
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 54a0dc1424a9..9bb0e0c412ec 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
@@ -1151,7 +1151,8 @@ static void update_curr_dl(struct rq *rq) | |||
1151 | { | 1151 | { |
1152 | struct task_struct *curr = rq->curr; | 1152 | struct task_struct *curr = rq->curr; |
1153 | struct sched_dl_entity *dl_se = &curr->dl; | 1153 | struct sched_dl_entity *dl_se = &curr->dl; |
1154 | u64 delta_exec; | 1154 | u64 delta_exec, scaled_delta_exec; |
1155 | int cpu = cpu_of(rq); | ||
1155 | 1156 | ||
1156 | if (!dl_task(curr) || !on_dl_rq(dl_se)) | 1157 | if (!dl_task(curr) || !on_dl_rq(dl_se)) |
1157 | return; | 1158 | return; |
@@ -1185,9 +1186,26 @@ static void update_curr_dl(struct rq *rq) | |||
1185 | if (dl_entity_is_special(dl_se)) | 1186 | if (dl_entity_is_special(dl_se)) |
1186 | return; | 1187 | return; |
1187 | 1188 | ||
1188 | if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM)) | 1189 | /* |
1189 | delta_exec = grub_reclaim(delta_exec, rq, &curr->dl); | 1190 | * For tasks that participate in GRUB, we implement GRUB-PA: the |
1190 | dl_se->runtime -= delta_exec; | 1191 | * spare reclaimed bandwidth is used to clock down frequency. |
1192 | * | ||
1193 | * For the others, we still need to scale reservation parameters | ||
1194 | * according to current frequency and CPU maximum capacity. | ||
1195 | */ | ||
1196 | if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM)) { | ||
1197 | scaled_delta_exec = grub_reclaim(delta_exec, | ||
1198 | rq, | ||
1199 | &curr->dl); | ||
1200 | } else { | ||
1201 | unsigned long scale_freq = arch_scale_freq_capacity(cpu); | ||
1202 | unsigned long scale_cpu = arch_scale_cpu_capacity(NULL, cpu); | ||
1203 | |||
1204 | scaled_delta_exec = cap_scale(delta_exec, scale_freq); | ||
1205 | scaled_delta_exec = cap_scale(scaled_delta_exec, scale_cpu); | ||
1206 | } | ||
1207 | |||
1208 | dl_se->runtime -= scaled_delta_exec; | ||
1191 | 1209 | ||
1192 | throttle: | 1210 | throttle: |
1193 | if (dl_runtime_exceeded(dl_se) || dl_se->dl_yielded) { | 1211 | if (dl_runtime_exceeded(dl_se) || dl_se->dl_yielded) { |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 14859757bff0..1070803cb423 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -3089,8 +3089,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3) | |||
3089 | return c1 + c2 + c3; | 3089 | return c1 + c2 + c3; |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | #define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) | ||
3093 | |||
3094 | /* | 3092 | /* |
3095 | * Accumulate the three separate parts of the sum; d1 the remainder | 3093 | * Accumulate the three separate parts of the sum; d1 the remainder |
3096 | * of the last (incomplete) period, d2 the span of full periods and d3 | 3094 | * of the last (incomplete) period, d2 the span of full periods and d3 |
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e122c89bdbdd..2e95505e23c6 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -156,6 +156,8 @@ static inline int task_has_dl_policy(struct task_struct *p) | |||
156 | return dl_policy(p->policy); | 156 | return dl_policy(p->policy); |
157 | } | 157 | } |
158 | 158 | ||
159 | #define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) | ||
160 | |||
159 | /* | 161 | /* |
160 | * !! For sched_setattr_nocheck() (kernel) only !! | 162 | * !! For sched_setattr_nocheck() (kernel) only !! |
161 | * | 163 | * |