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: Do not construct nor expose RT_GROUP_SCHED structures if disabled

Thanks to kernel cmdline being available early, before any
cgroup hierarchy exists, we can achieve the RT_GROUP_SCHED boottime
disabling goal by simply skipping any creation (and destruction) of
RT_GROUP data and its exposure via RT attributes.

We can do this thanks to previously placed runtime guards that would
redirect all operations to root_task_group's data when RT_GROUP_SCHED
disabled.

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

authored by

Michal Koutný and committed by
Peter Zijlstra
d6809c2f 277e0909

+33 -12
+24 -12
kernel/sched/core.c
··· 9867 9867 .seq_show = cpu_cfs_local_stat_show, 9868 9868 }, 9869 9869 #endif 9870 - #ifdef CONFIG_RT_GROUP_SCHED 9871 - { 9872 - .name = "rt_runtime_us", 9873 - .read_s64 = cpu_rt_runtime_read, 9874 - .write_s64 = cpu_rt_runtime_write, 9875 - }, 9876 - { 9877 - .name = "rt_period_us", 9878 - .read_u64 = cpu_rt_period_read_uint, 9879 - .write_u64 = cpu_rt_period_write_uint, 9880 - }, 9881 - #endif 9882 9870 #ifdef CONFIG_UCLAMP_TASK_GROUP 9883 9871 { 9884 9872 .name = "uclamp.min", ··· 9885 9897 }; 9886 9898 9887 9899 #ifdef CONFIG_RT_GROUP_SCHED 9900 + static struct cftype rt_group_files[] = { 9901 + { 9902 + .name = "rt_runtime_us", 9903 + .read_s64 = cpu_rt_runtime_read, 9904 + .write_s64 = cpu_rt_runtime_write, 9905 + }, 9906 + { 9907 + .name = "rt_period_us", 9908 + .read_u64 = cpu_rt_period_read_uint, 9909 + .write_u64 = cpu_rt_period_write_uint, 9910 + }, 9911 + { } /* Terminate */ 9912 + }; 9913 + 9888 9914 # ifdef CONFIG_RT_GROUP_SCHED_DEFAULT_DISABLED 9889 9915 DEFINE_STATIC_KEY_FALSE(rt_group_sched); 9890 9916 # else ··· 9921 9919 return 1; 9922 9920 } 9923 9921 __setup("rt_group_sched=", setup_rt_group_sched); 9922 + 9923 + static int __init cpu_rt_group_init(void) 9924 + { 9925 + if (!rt_group_sched_enabled()) 9926 + return 0; 9927 + 9928 + WARN_ON(cgroup_add_legacy_cftypes(&cpu_cgrp_subsys, rt_group_files)); 9929 + return 0; 9930 + } 9931 + subsys_initcall(cpu_rt_group_init); 9924 9932 #endif /* CONFIG_RT_GROUP_SCHED */ 9925 9933 9926 9934 static int cpu_extra_stat_show(struct seq_file *sf,
+9
kernel/sched/rt.c
··· 193 193 194 194 void unregister_rt_sched_group(struct task_group *tg) 195 195 { 196 + if (!rt_group_sched_enabled()) 197 + return; 198 + 196 199 if (tg->rt_se) 197 200 destroy_rt_bandwidth(&tg->rt_bandwidth); 198 201 } ··· 203 200 void free_rt_sched_group(struct task_group *tg) 204 201 { 205 202 int i; 203 + 204 + if (!rt_group_sched_enabled()) 205 + return; 206 206 207 207 for_each_possible_cpu(i) { 208 208 if (tg->rt_rq) ··· 250 244 struct rt_rq *rt_rq; 251 245 struct sched_rt_entity *rt_se; 252 246 int i; 247 + 248 + if (!rt_group_sched_enabled()) 249 + return 1; 253 250 254 251 tg->rt_rq = kcalloc(nr_cpu_ids, sizeof(rt_rq), GFP_KERNEL); 255 252 if (!tg->rt_rq)