[PATCH v2 2/7] sched/fair: Update rq clock before waking up new task

From: Matt Fleming
Date: Wed Sep 21 2016 - 09:38:35 EST


When initialising an entity's util and load averages we need an up to
date runqueue clock.

Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
Cc: Mike Galbraith <umgwanakikbuti@xxxxxxxxx>
Signed-off-by: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx>
---
kernel/sched/fair.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ab1cf3866a5b..7f8a61e97599 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -731,7 +731,10 @@ void post_init_entity_util_avg(struct sched_entity *se)
struct cfs_rq *cfs_rq = cfs_rq_of(se);
struct sched_avg *sa = &se->avg;
long cap = (long)(SCHED_CAPACITY_SCALE - cfs_rq->avg.util_avg) / 2;
- u64 now = cfs_rq_clock_task(cfs_rq);
+ u64 now;
+
+ update_rq_clock(rq_of(cfs_rq));
+ now = cfs_rq_clock_task(cfs_rq);

if (cap > 0) {
if (cfs_rq->avg.util_avg != 0) {
--
2.9.3