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: Skip non-root task_groups with disabled RT_GROUP_SCHED

First, we want to prevent placement of RT tasks on non-root rt_rqs which
we achieve in the task migration code that'd fall back to
root_task_group's rt_rq.

Second, we want to work with only root_task_group's rt_rq when iterating
all "real" rt_rqs when RT_GROUP is disabled. To achieve this we keep
root_task_group as the first one on the task_groups and break out
quickly.

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-6-mkoutny@suse.com

authored by

Michal Koutný and committed by
Peter Zijlstra
61d3164f e34e0131

+14 -4
+1 -1
kernel/sched/core.c
··· 9020 9020 unsigned long flags; 9021 9021 9022 9022 spin_lock_irqsave(&task_group_lock, flags); 9023 - list_add_rcu(&tg->list, &task_groups); 9023 + list_add_tail_rcu(&tg->list, &task_groups); 9024 9024 9025 9025 /* Root should already exist: */ 9026 9026 WARN_ON(!parent);
+6 -3
kernel/sched/rt.c
··· 495 495 496 496 static inline struct task_group *next_task_group(struct task_group *tg) 497 497 { 498 + if (!rt_group_sched_enabled()) 499 + return NULL; 500 + 498 501 do { 499 502 tg = list_entry_rcu(tg->list.next, 500 503 typeof(struct task_group), list); ··· 510 507 } 511 508 512 509 #define for_each_rt_rq(rt_rq, iter, rq) \ 513 - for (iter = container_of(&task_groups, typeof(*iter), list); \ 514 - (iter = next_task_group(iter)) && \ 515 - (rt_rq = iter->rt_rq[cpu_of(rq)]);) 510 + for (iter = &root_task_group; \ 511 + iter && (rt_rq = iter->rt_rq[cpu_of(rq)]); \ 512 + iter = next_task_group(iter)) 516 513 517 514 #define for_each_sched_rt_entity(rt_se) \ 518 515 for (; rt_se; rt_se = rt_se->parent)
+7
kernel/sched/sched.h
··· 2165 2165 #endif 2166 2166 2167 2167 #ifdef CONFIG_RT_GROUP_SCHED 2168 + /* 2169 + * p->rt.rt_rq is NULL initially and it is easier to assign 2170 + * root_task_group's rt_rq than switching in rt_rq_of_se() 2171 + * Clobbers tg(!) 2172 + */ 2173 + if (!rt_group_sched_enabled()) 2174 + tg = &root_task_group; 2168 2175 p->rt.rt_rq = tg->rt_rq[cpu]; 2169 2176 p->rt.parent = tg->rt_se[cpu]; 2170 2177 #endif