]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Fix build errors and unused label warning in non-cgroup configs
authorCheng-Yang Chou <yphbchou0911@gmail.com>
Sun, 22 Mar 2026 13:48:16 +0000 (21:48 +0800)
committerTejun Heo <tj@kernel.org>
Sun, 22 Mar 2026 20:02:11 +0000 (10:02 -1000)
When building with SCHED_CLASS_EXT=y but CGROUPS=n, clang reports errors
for undeclared cgroup_put() and cgroup_get() calls, and a warning for the
unused err_stop_helper label.

EXT_SUB_SCHED is def_bool y depending only on SCHED_CLASS_EXT, but it
fundamentally requires cgroups (cgroup_path, cgroup_get, cgroup_put,
cgroup_id, etc.). Add the missing CGROUPS dependency to EXT_SUB_SCHED in
init/Kconfig.

Guard cgroup_put() and cgroup_get() in the common paths with:
  #if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)

Guard the err_stop_helper label with #ifdef CONFIG_EXT_SUB_SCHED since
all gotos targeting it are inside that same ifdef block.

Tested with both CGROUPS enabled and disabled.

Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603210903.IrKhPd6k-lkp@intel.com/
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
init/Kconfig
kernel/sched/ext.c

index 06abd8e272cba5f01e7315f82c6ad9b24528dba4..487a93e34be9d3dc8e830390c13e146e28abf032 100644 (file)
@@ -1178,7 +1178,7 @@ endif #CGROUP_SCHED
 
 config EXT_SUB_SCHED
         def_bool y
-        depends on SCHED_CLASS_EXT
+        depends on SCHED_CLASS_EXT && CGROUPS
 
 config SCHED_MM_CID
        def_bool y
index 94548ee9ad8581ecc9aa464e47f6b9da3bf4afab..2e7a1259bd7c0318c1386ff8699feb4c732f117a 100644 (file)
@@ -6494,8 +6494,10 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
 #endif /* CONFIG_EXT_SUB_SCHED */
        return sch;
 
+#ifdef CONFIG_EXT_SUB_SCHED
 err_stop_helper:
        kthread_destroy_worker(sch->helper);
+#endif
 err_free_pcpu:
        for_each_possible_cpu(cpu) {
                if (cpu == bypass_fail_cpu)
@@ -6514,7 +6516,9 @@ err_free_ei:
 err_free_sch:
        kfree(sch);
 err_put_cgrp:
+#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
        cgroup_put(cgrp);
+#endif
        return ERR_PTR(ret);
 }
 
@@ -6603,7 +6607,9 @@ static void scx_root_enable_workfn(struct kthread_work *work)
        if (ret)
                goto err_unlock;
 
+#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
        cgroup_get(cgrp);
+#endif
        sch = scx_alloc_and_add_sched(ops, cgrp, NULL);
        if (IS_ERR(sch)) {
                ret = PTR_ERR(sch);