[tip: sched/core] sched/rt: Move group schedulability check to sched_rt_global_validate()

tip-bot2 for Michal Koutný posted 1 patch 2 months, 1 week ago
kernel/sched/rt.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
[tip: sched/core] sched/rt: Move group schedulability check to sched_rt_global_validate()
Posted by tip-bot2 for Michal Koutný 2 months, 1 week ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     4f70a0456d090303d5a6c915dd7d9db9da56cb16
Gitweb:        https://git.kernel.org/tip/4f70a0456d090303d5a6c915dd7d9db9da56cb16
Author:        Michal Koutný <mkoutny@suse.com>
AuthorDate:    Mon, 23 Mar 2026 13:39:38 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 08 Apr 2026 13:11:44 +02:00

sched/rt: Move group schedulability check to sched_rt_global_validate()

The sched_rt_global_constraints() function is a remnant that used to set
up global RT throttling but that is no more since commit 5f6bd380c7bdb
("sched/rt: Remove default bandwidth control") and the function ended up
only doing schedulability check.
Move the check into the validation function where it fits better.
(The order of validations sched_dl_global_validate() and
sched_rt_global_validate() shouldn't matter.)

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260323-sched-rert_groups-v3-2-1e7d5ed6b249@suse.com
---
 kernel/sched/rt.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 893e54d..e16d8f1 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2832,15 +2832,7 @@ long sched_group_rt_period(struct task_group *tg)
 #ifdef CONFIG_SYSCTL
 static int sched_rt_global_constraints(void)
 {
-	int ret = 0;
-	if (!rt_group_sched_enabled())
-		return ret;
-
-	mutex_lock(&rt_constraints_mutex);
-	ret = __rt_schedulable(NULL, 0, 0);
-	mutex_unlock(&rt_constraints_mutex);
-
-	return ret;
+	return 0;
 }
 #endif /* CONFIG_SYSCTL */
 
@@ -2872,6 +2864,13 @@ static int sched_rt_global_validate(void)
 			NSEC_PER_USEC > max_rt_runtime)))
 		return -EINVAL;
 
+#ifdef CONFIG_RT_GROUP_SCHED
+	if (!rt_group_sched_enabled())
+		return 0;
+
+	scoped_guard(mutex, &rt_constraints_mutex)
+		return __rt_schedulable(NULL, 0, 0);
+#endif
 	return 0;
 }