sched/fair: Reduce cases for active balance
Active balance is triggered for a number of voluntary cases like misfit or pinned tasks cases but also after that a number of load balance attempts failed to migrate a task. There is no need to use active load balance when the group is overloaded because an overloaded state means that there is at least one waiting task. Nevertheless, the waiting task is not selected and detached until the threshold becomes higher than its load. This threshold increases with the number of failed lb (see the condition if ((load >> env->sd->nr_balance_failed) > env->imbalance) in detach_tasks()) and the waiting task will end up to be selected after a number of attempts. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com> Acked-by: Mel Gorman <mgorman@suse.de> Link: https://lkml.kernel.org/r/20210107103325.30851-4-vincent.guittot@linaro.org
This commit is contained in:
parent
8a41dfcda7
commit
e9b9734b74
@ -9512,13 +9512,32 @@ asym_active_balance(struct lb_env *env)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
voluntary_active_balance(struct lb_env *env)
|
imbalanced_active_balance(struct lb_env *env)
|
||||||
|
{
|
||||||
|
struct sched_domain *sd = env->sd;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The imbalanced case includes the case of pinned tasks preventing a fair
|
||||||
|
* distribution of the load on the system but also the even distribution of the
|
||||||
|
* threads on a system with spare capacity
|
||||||
|
*/
|
||||||
|
if ((env->migration_type == migrate_task) &&
|
||||||
|
(sd->nr_balance_failed > sd->cache_nice_tries+2))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int need_active_balance(struct lb_env *env)
|
||||||
{
|
{
|
||||||
struct sched_domain *sd = env->sd;
|
struct sched_domain *sd = env->sd;
|
||||||
|
|
||||||
if (asym_active_balance(env))
|
if (asym_active_balance(env))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (imbalanced_active_balance(env))
|
||||||
|
return 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The dst_cpu is idle and the src_cpu CPU has only 1 CFS task.
|
* The dst_cpu is idle and the src_cpu CPU has only 1 CFS task.
|
||||||
* It's worth migrating the task if the src_cpu's capacity is reduced
|
* It's worth migrating the task if the src_cpu's capacity is reduced
|
||||||
@ -9538,16 +9557,6 @@ voluntary_active_balance(struct lb_env *env)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int need_active_balance(struct lb_env *env)
|
|
||||||
{
|
|
||||||
struct sched_domain *sd = env->sd;
|
|
||||||
|
|
||||||
if (voluntary_active_balance(env))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int active_load_balance_cpu_stop(void *data);
|
static int active_load_balance_cpu_stop(void *data);
|
||||||
|
|
||||||
static int should_we_balance(struct lb_env *env)
|
static int should_we_balance(struct lb_env *env)
|
||||||
@ -9800,21 +9809,13 @@ more_balance:
|
|||||||
/* We've kicked active balancing, force task migration. */
|
/* We've kicked active balancing, force task migration. */
|
||||||
sd->nr_balance_failed = sd->cache_nice_tries+1;
|
sd->nr_balance_failed = sd->cache_nice_tries+1;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
sd->nr_balance_failed = 0;
|
sd->nr_balance_failed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (likely(!active_balance) || voluntary_active_balance(&env)) {
|
if (likely(!active_balance) || need_active_balance(&env)) {
|
||||||
/* We were unbalanced, so reset the balancing interval */
|
/* We were unbalanced, so reset the balancing interval */
|
||||||
sd->balance_interval = sd->min_interval;
|
sd->balance_interval = sd->min_interval;
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* If we've begun active balancing, start to back off. This
|
|
||||||
* case may not be covered by the all_pinned logic if there
|
|
||||||
* is only 1 task on the busy runqueue (because we don't call
|
|
||||||
* detach_tasks).
|
|
||||||
*/
|
|
||||||
if (sd->balance_interval < sd->max_interval)
|
|
||||||
sd->balance_interval *= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user