mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
sched/fair: Cleanup loop_max and loop_break
sched_nr_migrate_break is set to a fix value and never changes so we can replace it by a define SCHED_NR_MIGRATE_BREAK. Also, we adjust SCHED_NR_MIGRATE_BREAK to be aligned with the init value of sysctl_sched_nr_migrate which can be init to different values. Then, use SCHED_NR_MIGRATE_BREAK to init sysctl_sched_nr_migrate. The behavior stays unchanged unless you modify sysctl_sched_nr_migrate trough debugfs. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220825122726.20819-3-vincent.guittot@linaro.org
This commit is contained in:
parent
b0defa7ae0
commit
c59862f826
@ -142,11 +142,7 @@ __read_mostly int sysctl_resched_latency_warn_once = 1;
|
|||||||
* Number of tasks to iterate in a single balance run.
|
* Number of tasks to iterate in a single balance run.
|
||||||
* Limited because this is done with IRQs disabled.
|
* Limited because this is done with IRQs disabled.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_PREEMPT_RT
|
const_debug unsigned int sysctl_sched_nr_migrate = SCHED_NR_MIGRATE_BREAK;
|
||||||
const_debug unsigned int sysctl_sched_nr_migrate = 8;
|
|
||||||
#else
|
|
||||||
const_debug unsigned int sysctl_sched_nr_migrate = 32;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__read_mostly int scheduler_running;
|
__read_mostly int scheduler_running;
|
||||||
|
|
||||||
|
@ -8009,8 +8009,6 @@ static struct task_struct *detach_one_task(struct lb_env *env)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned int sched_nr_migrate_break = 32;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* detach_tasks() -- tries to detach up to imbalance load/util/tasks from
|
* detach_tasks() -- tries to detach up to imbalance load/util/tasks from
|
||||||
* busiest_rq, as part of a balancing operation within domain "sd".
|
* busiest_rq, as part of a balancing operation within domain "sd".
|
||||||
@ -8059,7 +8057,7 @@ static int detach_tasks(struct lb_env *env)
|
|||||||
|
|
||||||
/* take a breather every nr_migrate tasks */
|
/* take a breather every nr_migrate tasks */
|
||||||
if (env->loop > env->loop_break) {
|
if (env->loop > env->loop_break) {
|
||||||
env->loop_break += sched_nr_migrate_break;
|
env->loop_break += SCHED_NR_MIGRATE_BREAK;
|
||||||
env->flags |= LBF_NEED_BREAK;
|
env->flags |= LBF_NEED_BREAK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -10100,14 +10098,13 @@ static int load_balance(int this_cpu, struct rq *this_rq,
|
|||||||
struct rq *busiest;
|
struct rq *busiest;
|
||||||
struct rq_flags rf;
|
struct rq_flags rf;
|
||||||
struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask);
|
struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask);
|
||||||
|
|
||||||
struct lb_env env = {
|
struct lb_env env = {
|
||||||
.sd = sd,
|
.sd = sd,
|
||||||
.dst_cpu = this_cpu,
|
.dst_cpu = this_cpu,
|
||||||
.dst_rq = this_rq,
|
.dst_rq = this_rq,
|
||||||
.dst_grpmask = sched_group_span(sd->groups),
|
.dst_grpmask = sched_group_span(sd->groups),
|
||||||
.idle = idle,
|
.idle = idle,
|
||||||
.loop_break = sched_nr_migrate_break,
|
.loop_break = SCHED_NR_MIGRATE_BREAK,
|
||||||
.cpus = cpus,
|
.cpus = cpus,
|
||||||
.fbq_type = all,
|
.fbq_type = all,
|
||||||
.tasks = LIST_HEAD_INIT(env.tasks),
|
.tasks = LIST_HEAD_INIT(env.tasks),
|
||||||
@ -10216,7 +10213,7 @@ more_balance:
|
|||||||
env.dst_cpu = env.new_dst_cpu;
|
env.dst_cpu = env.new_dst_cpu;
|
||||||
env.flags &= ~LBF_DST_PINNED;
|
env.flags &= ~LBF_DST_PINNED;
|
||||||
env.loop = 0;
|
env.loop = 0;
|
||||||
env.loop_break = sched_nr_migrate_break;
|
env.loop_break = SCHED_NR_MIGRATE_BREAK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go back to "more_balance" rather than "redo" since we
|
* Go back to "more_balance" rather than "redo" since we
|
||||||
@ -10248,7 +10245,7 @@ more_balance:
|
|||||||
*/
|
*/
|
||||||
if (!cpumask_subset(cpus, env.dst_grpmask)) {
|
if (!cpumask_subset(cpus, env.dst_grpmask)) {
|
||||||
env.loop = 0;
|
env.loop = 0;
|
||||||
env.loop_break = sched_nr_migrate_break;
|
env.loop_break = SCHED_NR_MIGRATE_BREAK;
|
||||||
goto redo;
|
goto redo;
|
||||||
}
|
}
|
||||||
goto out_all_pinned;
|
goto out_all_pinned;
|
||||||
|
@ -2423,6 +2423,12 @@ extern void deactivate_task(struct rq *rq, struct task_struct *p, int flags);
|
|||||||
|
|
||||||
extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
|
extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
|
||||||
|
|
||||||
|
#ifdef CONFIG_PREEMPT_RT
|
||||||
|
#define SCHED_NR_MIGRATE_BREAK 8
|
||||||
|
#else
|
||||||
|
#define SCHED_NR_MIGRATE_BREAK 32
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const_debug unsigned int sysctl_sched_nr_migrate;
|
extern const_debug unsigned int sysctl_sched_nr_migrate;
|
||||||
extern const_debug unsigned int sysctl_sched_migration_cost;
|
extern const_debug unsigned int sysctl_sched_migration_cost;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user