]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/deadline: Fix accounting after global limits change
authorJuri Lelli <juri.lelli@redhat.com>
Fri, 27 Jun 2025 11:51:16 +0000 (13:51 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 14 Jul 2025 08:59:33 +0000 (10:59 +0200)
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 <marcel.ziswiler@codethink.co.uk>
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@codethink.co.uk> # nuc & rock5b
Link: https://lore.kernel.org/r/20250627115118.438797-4-juri.lelli@redhat.com
kernel/sched/deadline.c
kernel/sched/rt.c

index 0abffe3860e3e38c95596e8ac2d746df01114e62..9c7d9528d5fa5bc87d510e2145ff1af89f169f6a 100644 (file)
@@ -3183,6 +3183,9 @@ void sched_dl_do_global(void)
        if (global_rt_runtime() != RUNTIME_INF)
                new_bw = to_ratio(global_rt_period(), global_rt_runtime());
 
+       for_each_possible_cpu(cpu)
+               init_dl_rq_bw_ratio(&cpu_rq(cpu)->dl);
+
        for_each_possible_cpu(cpu) {
                rcu_read_lock_sched();
 
@@ -3198,7 +3201,6 @@ void sched_dl_do_global(void)
                raw_spin_unlock_irqrestore(&dl_b->lock, flags);
 
                rcu_read_unlock_sched();
-               init_dl_rq_bw_ratio(&cpu_rq(cpu)->dl);
        }
 }
 
index 15d5855c542cb90a6cd76a08b2c4c65aaed7d2eb..be6e9bcbe82b6f03a1da0fe4bdcfe2c2598b190d 100644 (file)
@@ -2886,6 +2886,12 @@ undo:
        sched_domains_mutex_unlock();
        mutex_unlock(&mutex);
 
+       /*
+        * After changing maximum available bandwidth for DEADLINE, we need to
+        * recompute per root domain and per cpus variables accordingly.
+        */
+       rebuild_sched_domains();
+
        return ret;
 }