Skip to content

Commit 440989c

Browse files
jlelliPeter Zijlstra
authored andcommitted
sched/deadline: Fix accounting after global limits change
A global limits change (sched_rt_handler() logic) currently leaves stale and/or incorrect values in variables related to accounting (e.g. extra_bw). Properly clean up per runqueue variables before implementing the change and rebuild scheduling domains (so that accounting is also properly restored) after such a change is complete. Reported-by: Marcel Ziswiler <[email protected]> Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Marcel Ziswiler <[email protected]> # nuc & rock5b Link: https://lore.kernel.org/r/[email protected]
1 parent fcc9276 commit 440989c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

kernel/sched/deadline.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,6 +3183,9 @@ void sched_dl_do_global(void)
31833183
if (global_rt_runtime() != RUNTIME_INF)
31843184
new_bw = to_ratio(global_rt_period(), global_rt_runtime());
31853185

3186+
for_each_possible_cpu(cpu)
3187+
init_dl_rq_bw_ratio(&cpu_rq(cpu)->dl);
3188+
31863189
for_each_possible_cpu(cpu) {
31873190
rcu_read_lock_sched();
31883191

@@ -3198,7 +3201,6 @@ void sched_dl_do_global(void)
31983201
raw_spin_unlock_irqrestore(&dl_b->lock, flags);
31993202

32003203
rcu_read_unlock_sched();
3201-
init_dl_rq_bw_ratio(&cpu_rq(cpu)->dl);
32023204
}
32033205
}
32043206

kernel/sched/rt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,12 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
28862886
sched_domains_mutex_unlock();
28872887
mutex_unlock(&mutex);
28882888

2889+
/*
2890+
* After changing maximum available bandwidth for DEADLINE, we need to
2891+
* recompute per root domain and per cpus variables accordingly.
2892+
*/
2893+
rebuild_sched_domains();
2894+
28892895
return ret;
28902896
}
28912897

0 commit comments

Comments
 (0)