All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs
@ 2026-03-22  6:39 Cheng-Yang Chou
  2026-03-22  7:13 ` Andrea Righi
  0 siblings, 1 reply; 4+ messages in thread
From: Cheng-Yang Chou @ 2026-03-22  6:39 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911, kernel test robot

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>
---
 init/Kconfig       | 2 +-
 kernel/sched/ext.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index 06abd8e272cb..487a93e34be9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 94548ee9ad85..2e7a1259bd7c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-22  6:39 [PATCH v2 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs Cheng-Yang Chou
@ 2026-03-22  7:13 ` Andrea Righi
  2026-03-22 13:48   ` [PATCH v3 " Cheng-Yang Chou
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Righi @ 2026-03-22  7:13 UTC (permalink / raw)
  To: Cheng-Yang Chou
  Cc: sched-ext, Tejun Heo, David Vernet, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai, kernel test robot

On Sun, Mar 22, 2026 at 02:39:50PM +0800, Cheng-Yang Chou wrote:
> 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>

Looks good to me.

Acked-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  init/Kconfig       | 2 +-
>  kernel/sched/ext.c | 6 ++++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/init/Kconfig b/init/Kconfig
> index 06abd8e272cb..487a93e34be9 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -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
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 94548ee9ad85..2e7a1259bd7c 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -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);
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-22  7:13 ` Andrea Righi
@ 2026-03-22 13:48   ` Cheng-Yang Chou
  2026-03-22 20:06     ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Cheng-Yang Chou @ 2026-03-22 13:48 UTC (permalink / raw)
  To: arighi; +Cc: changwoo, chia7712, jserv, lkp, sched-ext, tj, void, yphbchou0911

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>
---
Changes in v3:
- Include the changelog which was missing in v2.
- Link to v2:
  https://lore.kernel.org/r/20260322063955.951848-1-yphbchou0911@gmail.com/

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/20260321070605.691776-1-yphbchou0911@gmail.com/

 init/Kconfig       | 2 +-
 kernel/sched/ext.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index 06abd8e272cb..487a93e34be9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 94548ee9ad85..2e7a1259bd7c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-22 13:48   ` [PATCH v3 " Cheng-Yang Chou
@ 2026-03-22 20:06     ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2026-03-22 20:06 UTC (permalink / raw)
  To: Cheng-Yang Chou, Andrea Righi, sched-ext, David Vernet,
	Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, kernel test robot,
	Emil Tsalapatis, linux-kernel

Applied to sched_ext/for-7.1.

Thanks.

--
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-22 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22  6:39 [PATCH v2 sched_ext/for-7.1] sched_ext: Fix build errors and unused label warning in non-cgroup configs Cheng-Yang Chou
2026-03-22  7:13 ` Andrea Righi
2026-03-22 13:48   ` [PATCH v3 " Cheng-Yang Chou
2026-03-22 20:06     ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.