From: Chris Redpath Date: Thu, 5 Dec 2013 15:49:32 +0000 (+0000) Subject: sched: reset blocked load decay_count during synchronization X-Git-Tag: firefly_0821_release~3680^2~16^2^2~25 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f720a920e88f1ec79db8c9f0031f61c610e40b02;p=firefly-linux-kernel-4.4.55.git sched: reset blocked load decay_count during synchronization If an entity happens to sleep for less than one tick duration the tracked load associated with that entity can be decayed by an unexpectedly large amount if it is later migrated to a different CPU. This can interfere with correct scheduling when entity load is used for decision making. The reason for this is that when an entity is dequeued and enqueued quickly, such that se.avg.decay_count and cfs_rq.decay_counter do not differ when that entity is enqueued again, __synchronize_entity_decay skips the calculation step and also skips clearing the decay_count. At a later time that entity may be migrated and its load will be decayed incorrectly. All users of this function expect decay_count to be zero'ed after use. Signed-off-by: Chris Redpath Signed-off-by: Jon Medhurst --- diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8a4a02740f0a..1d6394b96160 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1453,12 +1453,9 @@ static inline u64 __synchronize_entity_decay(struct sched_entity *se) u64 decays = atomic64_read(&cfs_rq->decay_counter); decays -= se->avg.decay_count; - if (!decays) - return 0; - - se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays); + if (decays) + se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays); se->avg.decay_count = 0; - return decays; }