Skip to content

Commit 9e0994c

Browse files
msrasmussenIngo Molnar
authored andcommitted
sched/fair: Avoid pulling tasks from non-overloaded higher capacity groups
For asymmetric CPU capacity systems it is counter-productive for throughput if low capacity CPUs are pulling tasks from non-overloaded CPUs with higher capacity. The assumption is that higher CPU capacity is preferred over running alone in a group with lower CPU capacity. This patch rejects higher CPU capacity groups with one or less task per CPU as potential busiest group which could otherwise lead to a series of failing load-balancing attempts leading to a force-migration. Signed-off-by: Morten Rasmussen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent bf475ce commit 9e0994c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

kernel/sched/fair.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7073,6 +7073,17 @@ group_is_overloaded(struct lb_env *env, struct sg_lb_stats *sgs)
70737073
return false;
70747074
}
70757075

7076+
/*
7077+
* group_smaller_cpu_capacity: Returns true if sched_group sg has smaller
7078+
* per-CPU capacity than sched_group ref.
7079+
*/
7080+
static inline bool
7081+
group_smaller_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
7082+
{
7083+
return sg->sgc->min_capacity * capacity_margin <
7084+
ref->sgc->min_capacity * 1024;
7085+
}
7086+
70767087
static inline enum
70777088
group_type group_classify(struct sched_group *group,
70787089
struct sg_lb_stats *sgs)
@@ -7176,6 +7187,20 @@ static bool update_sd_pick_busiest(struct lb_env *env,
71767187
if (sgs->avg_load <= busiest->avg_load)
71777188
return false;
71787189

7190+
if (!(env->sd->flags & SD_ASYM_CPUCAPACITY))
7191+
goto asym_packing;
7192+
7193+
/*
7194+
* Candidate sg has no more than one task per CPU and
7195+
* has higher per-CPU capacity. Migrating tasks to less
7196+
* capable CPUs may harm throughput. Maximize throughput,
7197+
* power/energy consequences are not considered.
7198+
*/
7199+
if (sgs->sum_nr_running <= sgs->group_weight &&
7200+
group_smaller_cpu_capacity(sds->local, sg))
7201+
return false;
7202+
7203+
asym_packing:
71797204
/* This is the busiest node in its class. */
71807205
if (!(env->sd->flags & SD_ASYM_PACKING))
71817206
return true;

0 commit comments

Comments
 (0)