diff options
author | Alex Shi <alex.shi@intel.com> | 2013-06-19 22:18:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-06-27 04:07:32 -0400 |
commit | 282cf499f03ec1754b6c8c945c9674b02631fb0f (patch) | |
tree | a3f0c1ad7b760cf327ff566aa90efc41b71d3c4b /kernel/sched | |
parent | a75cdaa915e42ef0e6f38dc7f2a6a1deca91d648 (diff) |
sched: Fix sleep time double accounting in enqueue entity
The woken migrated task will __synchronize_entity_decay(se); in
migrate_task_rq_fair, then it needs to set
`se->avg.last_runnable_update -= (-se->avg.decay_count) << 20' before
update_entity_load_avg, in order to avoid sleep time is updated twice
for se.avg.load_avg_contrib in both __syncchronize and
update_entity_load_avg.
However if the sleeping task is woken up from the same cpu, it miss
the last_runnable_update before update_entity_load_avg(se, 0, 1), then
the sleep time was used twice in both functions. So we need to remove
the double sleep time accounting.
Paul also contributed some code comments in this commit.
Signed-off-by: Alex Shi <alex.shi@intel.com>
Reviewed-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1371694737-29336-5-git-send-email-alex.shi@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/fair.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e1602a0fdbf8..9bbc303598ea 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -1571,7 +1571,13 @@ static inline void enqueue_entity_load_avg(struct cfs_rq *cfs_rq, | |||
1571 | } | 1571 | } |
1572 | wakeup = 0; | 1572 | wakeup = 0; |
1573 | } else { | 1573 | } else { |
1574 | __synchronize_entity_decay(se); | 1574 | /* |
1575 | * Task re-woke on same cpu (or else migrate_task_rq_fair() | ||
1576 | * would have made count negative); we must be careful to avoid | ||
1577 | * double-accounting blocked time after synchronizing decays. | ||
1578 | */ | ||
1579 | se->avg.last_runnable_update += __synchronize_entity_decay(se) | ||
1580 | << 20; | ||
1575 | } | 1581 | } |
1576 | 1582 | ||
1577 | /* migrated tasks did not contribute to our blocked load */ | 1583 | /* migrated tasks did not contribute to our blocked load */ |