[PATCH v2 1/7] sched/fair: Update the rq clock before detaching tasks

From: Matt Fleming
Date: Wed Sep 21 2016 - 09:40:07 EST


detach_task_cfs_rq() may indirectly call rq_clock() to inform the
cpufreq code that the rq utilisation has changed. In which case, we
need to update the rq 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 986c10c25176..ab1cf3866a5b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8484,7 +8484,10 @@ static void detach_task_cfs_rq(struct task_struct *p)
{
struct sched_entity *se = &p->se;
struct cfs_rq *cfs_rq = cfs_rq_of(se);
- u64 now = cfs_rq_clock_task(cfs_rq);
+ u64 now;
+
+ update_rq_clock(task_rq(p));
+ now = cfs_rq_clock_task(cfs_rq);

if (!vruntime_normalized(p)) {
/*
--
2.9.3