Skip to content

Commit c59862f

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
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
1 parent b0defa7 commit c59862f

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,7 @@ __read_mostly int sysctl_resched_latency_warn_once = 1;
142142
* Number of tasks to iterate in a single balance run.
143143
* Limited because this is done with IRQs disabled.
144144
*/
145-
#ifdef CONFIG_PREEMPT_RT
146-
const_debug unsigned int sysctl_sched_nr_migrate = 8;
147-
#else
148-
const_debug unsigned int sysctl_sched_nr_migrate = 32;
149-
#endif
145+
const_debug unsigned int sysctl_sched_nr_migrate = SCHED_NR_MIGRATE_BREAK;
150146

151147
__read_mostly int scheduler_running;
152148

kernel/sched/fair.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8009,8 +8009,6 @@ static struct task_struct *detach_one_task(struct lb_env *env)
80098009
return NULL;
80108010
}
80118011

8012-
static const unsigned int sched_nr_migrate_break = 32;
8013-
80148012
/*
80158013
* detach_tasks() -- tries to detach up to imbalance load/util/tasks from
80168014
* busiest_rq, as part of a balancing operation within domain "sd".
@@ -8059,7 +8057,7 @@ static int detach_tasks(struct lb_env *env)
80598057

80608058
/* take a breather every nr_migrate tasks */
80618059
if (env->loop > env->loop_break) {
8062-
env->loop_break += sched_nr_migrate_break;
8060+
env->loop_break += SCHED_NR_MIGRATE_BREAK;
80638061
env->flags |= LBF_NEED_BREAK;
80648062
break;
80658063
}
@@ -10100,14 +10098,13 @@ static int load_balance(int this_cpu, struct rq *this_rq,
1010010098
struct rq *busiest;
1010110099
struct rq_flags rf;
1010210100
struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask);
10103-
1010410101
struct lb_env env = {
1010510102
.sd = sd,
1010610103
.dst_cpu = this_cpu,
1010710104
.dst_rq = this_rq,
1010810105
.dst_grpmask = sched_group_span(sd->groups),
1010910106
.idle = idle,
10110-
.loop_break = sched_nr_migrate_break,
10107+
.loop_break = SCHED_NR_MIGRATE_BREAK,
1011110108
.cpus = cpus,
1011210109
.fbq_type = all,
1011310110
.tasks = LIST_HEAD_INIT(env.tasks),
@@ -10216,7 +10213,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
1021610213
env.dst_cpu = env.new_dst_cpu;
1021710214
env.flags &= ~LBF_DST_PINNED;
1021810215
env.loop = 0;
10219-
env.loop_break = sched_nr_migrate_break;
10216+
env.loop_break = SCHED_NR_MIGRATE_BREAK;
1022010217

1022110218
/*
1022210219
* Go back to "more_balance" rather than "redo" since we
@@ -10248,7 +10245,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
1024810245
*/
1024910246
if (!cpumask_subset(cpus, env.dst_grpmask)) {
1025010247
env.loop = 0;
10251-
env.loop_break = sched_nr_migrate_break;
10248+
env.loop_break = SCHED_NR_MIGRATE_BREAK;
1025210249
goto redo;
1025310250
}
1025410251
goto out_all_pinned;

kernel/sched/sched.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,12 @@ extern void deactivate_task(struct rq *rq, struct task_struct *p, int flags);
24232423

24242424
extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
24252425

2426+
#ifdef CONFIG_PREEMPT_RT
2427+
#define SCHED_NR_MIGRATE_BREAK 8
2428+
#else
2429+
#define SCHED_NR_MIGRATE_BREAK 32
2430+
#endif
2431+
24262432
extern const_debug unsigned int sysctl_sched_nr_migrate;
24272433
extern const_debug unsigned int sysctl_sched_migration_cost;
24282434

0 commit comments

Comments
 (0)