Skip to content

Commit 0788116

Browse files
Juri LelliIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Claudio Scordino <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Luca Abeni <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J . Wysocki <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Viresh Kumar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 7e1a920 commit 0788116

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

kernel/sched/deadline.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,8 @@ static void update_curr_dl(struct rq *rq)
11511151
{
11521152
struct task_struct *curr = rq->curr;
11531153
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);
11551156

11561157
if (!dl_task(curr) || !on_dl_rq(dl_se))
11571158
return;
@@ -1185,9 +1186,26 @@ static void update_curr_dl(struct rq *rq)
11851186
if (dl_entity_is_special(dl_se))
11861187
return;
11871188

1188-
if (unlikely(dl_se->flags & SCHED_FLAG_RECLAIM))
1189-
delta_exec = grub_reclaim(delta_exec, rq, &curr->dl);
1190-
dl_se->runtime -= delta_exec;
1189+
/*
1190+
* For tasks that participate in GRUB, we implement GRUB-PA: the
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;
11911209

11921210
throttle:
11931211
if (dl_runtime_exceeded(dl_se) || dl_se->dl_yielded) {

kernel/sched/fair.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,8 +3089,6 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3)
30893089
return c1 + c2 + c3;
30903090
}
30913091

3092-
#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT)
3093-
30943092
/*
30953093
* Accumulate the three separate parts of the sum; d1 the remainder
30963094
* of the last (incomplete) period, d2 the span of full periods and d3

kernel/sched/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ static inline int task_has_dl_policy(struct task_struct *p)
156156
return dl_policy(p->policy);
157157
}
158158

159+
#define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT)
160+
159161
/*
160162
* !! For sched_setattr_nocheck() (kernel) only !!
161163
*

0 commit comments

Comments
 (0)