[PATCH] sched/rt: Rebuild domains only after successful RT sysctl writes

From: Joseph Salisbury

Date: Fri Mar 13 2026 - 14:37:28 EST


sched_rt_handler() unconditionally calls rebuild_sched_domains() on exit.

That means scheduler domains are rebuilt even for read-only sysctl access,
and also after writes that fail validation and roll back to the old RT
bandwidth values.

Track whether the write path completed validation and global RT/DL updates,
and rebuild scheduler domains only in that case.

Fixes: 440989c10f4e ("sched/deadline: Fix accounting after global limits change")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Joseph Salisbury <joseph.salisbury@xxxxxxxxxx>
---
kernel/sched/rt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 906f6c656c2e..ada9249b22cd 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2871,6 +2871,7 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
{
int old_period, old_runtime;
static DEFINE_MUTEX(mutex);
+ bool rebuild = false;
int ret;

mutex_lock(&mutex);
@@ -2895,6 +2896,7 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff

sched_rt_do_global();
sched_dl_do_global();
+ rebuild = true;
}
if (0) {
undo:
@@ -2908,7 +2910,8 @@ static int sched_rt_handler(const struct ctl_table *table, int write, void *buff
* After changing maximum available bandwidth for DEADLINE, we need to
* recompute per root domain and per cpus variables accordingly.
*/
- rebuild_sched_domains();
+ if (rebuild)
+ rebuild_sched_domains();

return ret;
}
--
2.47.3