Skip to content

Commit fc975cf

Browse files
kuyo changPeter Zijlstra
authored andcommitted
sched/deadline: Fix dl_server runtime calculation formula
In our testing with 6.12 based kernel on a big.LITTLE system, we were seeing instances of RT tasks being blocked from running on the LITTLE cpus for multiple seconds of time, apparently by the dl_server. This far exceeds the default configured 50ms per second runtime. This is due to the fair dl_server runtime calculation being scaled for frequency & capacity of the cpu. Consider the following case under a Big.LITTLE architecture: Assume the runtime is: 50,000,000 ns, and Frequency/capacity scale-invariance defined as below: Frequency scale-invariance: 100 Capacity scale-invariance: 50 First by Frequency scale-invariance, the runtime is scaled to 50,000,000 * 100 >> 10 = 4,882,812 Then by capacity scale-invariance, it is further scaled to 4,882,812 * 50 >> 10 = 238,418. So it will scaled to 238,418 ns. This smaller "accounted runtime" value is what ends up being subtracted against the fair-server's runtime for the current period. Thus after 50ms of real time, we've only accounted ~238us against the fair servers runtime. This 209:1 ratio in this example means that on the smaller cpu the fair server is allowed to continue running, blocking RT tasks, for over 10 seconds before it exhausts its supposed 50ms of runtime. And on other hardware configurations it can be even worse. For the fair deadline_server, to prevent realtime tasks from being unexpectedly delayed, we really do want to use fixed time, and not scaled time for smaller capacity/frequency cpus. So remove the scaling from the fair server's accounting to fix this. Fixes: a110a81 ("sched/deadline: Deferrable dl server") Suggested-by: Peter Zijlstra <[email protected]> Suggested-by: John Stultz <[email protected]> Signed-off-by: kuyo chang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Juri Lelli <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: John Stultz <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 009836b commit fc975cf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/sched/deadline.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,9 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64
15041504
if (dl_entity_is_special(dl_se))
15051505
return;
15061506

1507-
scaled_delta_exec = dl_scaled_delta_exec(rq, dl_se, delta_exec);
1507+
scaled_delta_exec = delta_exec;
1508+
if (!dl_server(dl_se))
1509+
scaled_delta_exec = dl_scaled_delta_exec(rq, dl_se, delta_exec);
15081510

15091511
dl_se->runtime -= scaled_delta_exec;
15101512

@@ -1611,7 +1613,7 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64
16111613
*/
16121614
void dl_server_update_idle_time(struct rq *rq, struct task_struct *p)
16131615
{
1614-
s64 delta_exec, scaled_delta_exec;
1616+
s64 delta_exec;
16151617

16161618
if (!rq->fair_server.dl_defer)
16171619
return;
@@ -1624,9 +1626,7 @@ void dl_server_update_idle_time(struct rq *rq, struct task_struct *p)
16241626
if (delta_exec < 0)
16251627
return;
16261628

1627-
scaled_delta_exec = dl_scaled_delta_exec(rq, &rq->fair_server, delta_exec);
1628-
1629-
rq->fair_server.runtime -= scaled_delta_exec;
1629+
rq->fair_server.runtime -= delta_exec;
16301630

16311631
if (rq->fair_server.runtime < 0) {
16321632
rq->fair_server.dl_defer_running = 0;

0 commit comments

Comments
 (0)