[PATCH 1/3] sched/fair: fix rounding issue for asym packing

From: Vincent Guittot
Date: Tue Aug 07 2018 - 11:56:38 EST


When check_asym_packing() is triggered, the imbalance is set to :
busiest_stat.avg_load * busiest_stat.group_capacity / SCHED_CAPACITY_SCALE
busiest_stat.avg_load also comes from a division and the final rounding
can make imbalance slightly lower than the weighted load of the cfs_rq.
But this is enough to skip the rq in find_busiest_queue and prevents asym
migration to happen.

Add 1 to the avg_load to make sure that the targeted cpu will not be
skipped unexpectidly.

Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
---
kernel/sched/fair.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 309c93f..c376cd0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7780,6 +7780,12 @@ static inline void update_sg_lb_stats(struct lb_env *env,
/* Adjust by relative CPU capacity of the group */
sgs->group_capacity = group->sgc->capacity;
sgs->avg_load = (sgs->group_load*SCHED_CAPACITY_SCALE) / sgs->group_capacity;
+ /*
+ * Prevent division rounding to make the computation of imbalance
+ * slightly less than original value and to prevent the rq to be then
+ * selected as busiest queue
+ */
+ sgs->avg_load += 1;

if (sgs->sum_nr_running)
sgs->load_per_task = sgs->sum_weighted_load / sgs->sum_nr_running;
--
2.7.4