Skip to content

Commit c7f7e9c

Browse files
Vineeth Pillai (Google)Peter Zijlstra
authored andcommitted
sched/dlserver: Fix dlserver time accounting
dlserver time is accounted when: - dlserver is active and the dlserver proxies the cfs task. - dlserver is active but deferred and cfs task runs after being picked through the normal fair class pick. dl_server_update is called in two places to make sure that both the above times are accounted for. But it doesn't check if dlserver is active or not. Now that we have this dl_server_active flag, we can consolidate dl_server_update into one place and all we need to check is whether dlserver is active or not. When dlserver is active there is only two possible conditions: - dlserver is deferred. - cfs task is running on behalf of dlserver. Fixes: a110a81 ("sched/deadline: Deferrable dl server") Signed-off-by: "Vineeth Pillai (Google)" <vineeth@bitbyteword.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@codethink.co.uk> # ROCK 5B Link: https://lore.kernel.org/r/20241213032244.877029-2-vineeth@bitbyteword.org
1 parent b53127d commit c7f7e9c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

kernel/sched/fair.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,6 @@ static inline void update_curr_task(struct task_struct *p, s64 delta_exec)
11591159
trace_sched_stat_runtime(p, delta_exec);
11601160
account_group_exec_runtime(p, delta_exec);
11611161
cgroup_account_cputime(p, delta_exec);
1162-
if (p->dl_server)
1163-
dl_server_update(p->dl_server, delta_exec);
11641162
}
11651163

11661164
static inline bool did_preempt_short(struct cfs_rq *cfs_rq, struct sched_entity *curr)
@@ -1237,11 +1235,16 @@ static void update_curr(struct cfs_rq *cfs_rq)
12371235
update_curr_task(p, delta_exec);
12381236

12391237
/*
1240-
* Any fair task that runs outside of fair_server should
1241-
* account against fair_server such that it can account for
1242-
* this time and possibly avoid running this period.
1238+
* If the fair_server is active, we need to account for the
1239+
* fair_server time whether or not the task is running on
1240+
* behalf of fair_server or not:
1241+
* - If the task is running on behalf of fair_server, we need
1242+
* to limit its time based on the assigned runtime.
1243+
* - Fair task that runs outside of fair_server should account
1244+
* against fair_server such that it can account for this time
1245+
* and possibly avoid running this period.
12431246
*/
1244-
if (p->dl_server != &rq->fair_server)
1247+
if (dl_server_active(&rq->fair_server))
12451248
dl_server_update(&rq->fair_server, delta_exec);
12461249
}
12471250

0 commit comments

Comments
 (0)