Skip to contentSkip to conversation

sched_ext: Fix build errors and unused label warning in non-cgroup configs

PATCH Superseded Cheng-Yang Chou 3 participants 4 messages Mar 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched_ext: Fix build errors and unused label warning in non-cgroup configs

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")
---
 init/Kconfig       | 2 +-
 kernel/sched/ext.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
init/Kconfig +1 -1
index 06abd8e272cb..487a93e34be9 100644
@@ -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
kernel/sched/ext.c +6 -0
index 94548ee9ad85..2e7a1259bd7c 100644
@@ -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 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
 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);
Signature · 1 line
2.48.1
reviewer Acked-by on v2 1/1
#1 lore raw
Quoted 15 lines · Cheng-Yang Chou

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.

Quoted 6 lines

Tested with both CGROUPS enabled and disabled.

Fixes ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")

Looks good to me.

Thanks,
-Andrea

Quoted 56 lines
---
 init/Kconfig       | 2 +-
 kernel/sched/ext.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
init/Kconfig +1 -1
index 06abd8e272cb..487a93e34be9 100644
@@ -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
kernel/sched/ext.c +6 -0
index 94548ee9ad85..2e7a1259bd7c 100644
@@ -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 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
 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);
Signature · 1 line
2.48.1
#2 lore raw

PATCH v3 1/1 sched_ext: Fix build errors and unused label warning in non-cgroup configs

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.

---
Changes in v3:
- Include the changelog which was missing in v2.
- Link to v2:
https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Add missing CGROUPS dependency to EXT_SUB_SCHED in init/Kconfig. (Tejun Heo)
- Refine commit message to clarify why CGROUPS is required. (Tejun Heo)
- Link to v1:
https://lore.kernel.org/r/[email protected]/

 init/Kconfig       | 2 +-
 kernel/sched/ext.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
init/Kconfig +1 -1
index 06abd8e272cb..487a93e34be9 100644
@@ -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
kernel/sched/ext.c +6 -0
index 94548ee9ad85..2e7a1259bd7c 100644
@@ -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 @@ static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops,
 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);
Signature · 1 line
2.48.1
reviewer Applied
#3 lore raw

Applied to sched_ext/for-7.1.

Thanks.

--
tejun