sched/deadline: Make update_curr_dl() more accurate

"Linux Kernel Mailing List" <[email protected]> Thu, 15 Feb 2018 17:37:49 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/6fe0ce1eb04f99a1eb1eb6e7f775666966cf6c80
Commit:     6fe0ce1eb04f99a1eb1eb6e7f775666966cf6c80
Parent:     6a546c7e69ff0b69581377cc70d7e8a601b98fce
Refname:    refs/heads/master
Author:     Wen Yang <[email protected]>
AuthorDate: Tue Feb 6 09:55:48 2018 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue Feb 13 11:44:40 2018 +0100

    sched/deadline: Make update_curr_dl() more accurate
    
    rq->clock_task may be updated between the two calls of
    rq_clock_task() in update_curr_dl(). Calling rq_clock_task() only
    once makes it more accurate and efficient, taking update_curr() as
    reference.
    
    Suggested-by: Peter Zijlstra <[email protected]>
    Signed-off-by: Wen Yang <[email protected]>
    Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
    Reviewed-by: Jiang Biao <[email protected]>
    Cc: Linus Torvalds <[email protected]>
    Cc: Thomas Gleixner <[email protected]>
    Cc: [email protected]
    Link: http://lkml.kernel.org/r/[email protected]
    Signed-off-by: Ingo Molnar <[email protected]>
---
 kernel/sched/deadline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 9bb0e0c412ec..9df09782025c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1153,6 +1153,7 @@ static void update_curr_dl(struct rq *rq)
 	struct sched_dl_entity *dl_se = &curr->dl;
 	u64 delta_exec, scaled_delta_exec;
 	int cpu = cpu_of(rq);
+	u64 now;
 
 	if (!dl_task(curr) || !on_dl_rq(dl_se))
 		return;
@@ -1165,7 +1166,8 @@ static void update_curr_dl(struct rq *rq)
 	 * natural solution, but the full ramifications of this
 	 * approach need further study.
 	 */
-	delta_exec = rq_clock_task(rq) - curr->se.exec_start;
+	now = rq_clock_task(rq);
+	delta_exec = now - curr->se.exec_start;
 	if (unlikely((s64)delta_exec <= 0)) {
 		if (unlikely(dl_se->dl_yielded))
 			goto throttle;
@@ -1178,7 +1180,7 @@ static void update_curr_dl(struct rq *rq)
 	curr->se.sum_exec_runtime += delta_exec;
 	account_group_exec_runtime(curr, delta_exec);
 
-	curr->se.exec_start = rq_clock_task(rq);
+	curr->se.exec_start = now;
 	cgroup_account_cputime(curr, delta_exec);
 
 	sched_rt_avg_update(rq, delta_exec);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html