Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched: Add RT_GROUP WARN checks for non-root task_groups

With CONFIG_RT_GROUP_SCHED but runtime disabling of RT_GROUPs we expect
the existence of the root task_group only and all rt_sched_entity'ies
should be queued on root's rt_rq.

If we get a non-root RT_GROUP something went wrong.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250310170442.504716-9-mkoutny@suse.com

authored by

Michal Koutný and committed by
Peter Zijlstra
87f1fb77 d6809c2f

+12 -2
+12 -2
kernel/sched/rt.c
··· 176 176 177 177 static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq) 178 178 { 179 + /* Cannot fold with non-CONFIG_RT_GROUP_SCHED version, layout */ 180 + WARN_ON(!rt_group_sched_enabled() && rt_rq->tg != &root_task_group); 179 181 return rt_rq->rq; 180 182 } 181 183 182 184 static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se) 183 185 { 186 + WARN_ON(!rt_group_sched_enabled() && rt_se->rt_rq->tg != &root_task_group); 184 187 return rt_se->rt_rq; 185 188 } 186 189 ··· 191 188 { 192 189 struct rt_rq *rt_rq = rt_se->rt_rq; 193 190 191 + WARN_ON(!rt_group_sched_enabled() && rt_rq->tg != &root_task_group); 194 192 return rt_rq->rq; 195 193 } 196 194 ··· 508 504 509 505 static inline struct task_group *next_task_group(struct task_group *tg) 510 506 { 511 - if (!rt_group_sched_enabled()) 507 + if (!rt_group_sched_enabled()) { 508 + WARN_ON(tg != &root_task_group); 512 509 return NULL; 510 + } 513 511 514 512 do { 515 513 tg = list_entry_rcu(tg->list.next, ··· 2613 2607 { 2614 2608 struct rt_rq *rt_rq; 2615 2609 2616 - #ifdef CONFIG_RT_GROUP_SCHED 2610 + #ifdef CONFIG_RT_GROUP_SCHED // XXX maybe add task_rt_rq(), see also sched_rt_period_rt_rq 2617 2611 rt_rq = task_group(p)->rt_rq[cpu]; 2612 + WARN_ON(!rt_group_sched_enabled() && rt_rq->tg != &root_task_group); 2618 2613 #else 2619 2614 rt_rq = &cpu_rq(cpu)->rt; 2620 2615 #endif ··· 2723 2716 */ 2724 2717 if (rt_bandwidth_enabled() && !runtime && 2725 2718 tg->rt_bandwidth.rt_runtime && tg_has_rt_tasks(tg)) 2719 + return -EBUSY; 2720 + 2721 + if (WARN_ON(!rt_group_sched_enabled() && tg != &root_task_group)) 2726 2722 return -EBUSY; 2727 2723 2728 2724 total = to_ratio(period, runtime);