All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
@ 2026-03-21  7:05 Cheng-Yang Chou
  2026-03-21 14:35 ` Andrea Righi
  0 siblings, 1 reply; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-03-21  7:05 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 without CONFIG_EXT_GROUP_SCHED and CONFIG_EXT_SUB_SCHED,
clang reports errors for undeclared cgroup_put() and cgroup_get() calls.
It also flags an unused err_stop_helper label.

This conditionally compiles the cgroup reference counting functions and
the error handling label to match the configurations that require them,
preventing implicit declaration errors and unused label warnings.

Tested with both configs enabled/disabled.

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>
---
 kernel/sched/ext.c | 6 ++++++
 1 file changed, 6 insertions(+)

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] 6+ messages in thread

* Re: [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-21  7:05 [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs Cheng-Yang Chou
@ 2026-03-21 14:35 ` Andrea Righi
  2026-03-21 17:31   ` Cheng-Yang Chou
  2026-03-21 19:10   ` Tejun Heo
  0 siblings, 2 replies; 6+ messages in thread
From: Andrea Righi @ 2026-03-21 14:35 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

Hi Cheng-Yang,

On Sat, Mar 21, 2026 at 03:05:15PM +0800, Cheng-Yang Chou wrote:
> When building without CONFIG_EXT_GROUP_SCHED and CONFIG_EXT_SUB_SCHED,
> clang reports errors for undeclared cgroup_put() and cgroup_get() calls.
> It also flags an unused err_stop_helper label.
> 
> This conditionally compiles the cgroup reference counting functions and
> the error handling label to match the configurations that require them,
> preventing implicit declaration errors and unused label warnings.
> 
> Tested with both configs enabled/disabled.
> 
> 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>
> ---
>  kernel/sched/ext.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> 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

CONFIG_EXT_SUB_SCHED is always defined whenever ext.c compiles, so this one
is unnecessary.

>  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

This ifdef around cgroup_get()/cgroup_put() also always evaluates to true
because EXT_SUB_SCHED is always true regardless of EXT_GROUP_SCHED.

>  	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

Ditto.

>  	sch = scx_alloc_and_add_sched(ops, cgrp, NULL);
>  	if (IS_ERR(sch)) {
>  		ret = PTR_ERR(sch);
> -- 

This looks like a false positive, the kernel test robot likely tested with
a manually crafted config, so I think we shouldn't apply this patch.

Thanks,
-Andrea

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

* Re: [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-21 14:35 ` Andrea Righi
@ 2026-03-21 17:31   ` Cheng-Yang Chou
  2026-03-21 19:10   ` Tejun Heo
  1 sibling, 0 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-03-21 17:31 UTC (permalink / raw)
  To: Andrea Righi
  Cc: sched-ext, Tejun Heo, David Vernet, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai, kernel test robot

On Sat, Mar 21, 2026 at 03:35:20PM +0100, Andrea Righi wrote:
> >  
> > +#ifdef CONFIG_EXT_SUB_SCHED
> >  err_stop_helper:
> >  	kthread_destroy_worker(sch->helper);
> > +#endif
> 
> CONFIG_EXT_SUB_SCHED is always defined whenever ext.c compiles, so this one
> is unnecessary.

Oh, I see the dependency below. Thanks for pointing that out.

// Kconfig
config EXT_SUB_SCHED
        def_bool y
        depends on SCHED_CLASS_EXT

> 
> >  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
> 
> This ifdef around cgroup_get()/cgroup_put() also always evaluates to true
> because EXT_SUB_SCHED is always true regardless of EXT_GROUP_SCHED.

Understood, sorry for the noise.

> >  	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
> 
> Ditto.
> 
> >  	sch = scx_alloc_and_add_sched(ops, cgrp, NULL);
> >  	if (IS_ERR(sch)) {
> >  		ret = PTR_ERR(sch);
> > -- 
> 
> This looks like a false positive, the kernel test robot likely tested with
> a manually crafted config, so I think we shouldn't apply this patch.


-- 
Thanks,
Cheng-Yang

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

* Re: [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-21 14:35 ` Andrea Righi
  2026-03-21 17:31   ` Cheng-Yang Chou
@ 2026-03-21 19:10   ` Tejun Heo
  2026-03-21 23:26     ` Andrea Righi
  2026-03-22  6:43     ` Cheng-Yang Chou
  1 sibling, 2 replies; 6+ messages in thread
From: Tejun Heo @ 2026-03-21 19:10 UTC (permalink / raw)
  To: Cheng-Yang Chou, Andrea Righi
  Cc: sched-ext, David Vernet, Changwoo Min, Ching-Chun Huang,
	Chia-Ping Tsai, kernel test robot, Emil Tsalapatis, linux-kernel

Hello,

On Sat, Mar 21, 2026 at 03:35:20PM +0100, Andrea Righi wrote:
> This looks like a false positive, the kernel test robot likely tested
> with a manually crafted config, so I think we shouldn't apply this
> patch.

It's not a false positive. CONFIG_SCHED_CLASS_EXT doesn't depend on
CONFIG_CGROUPS in Kconfig, so SCHED_CLASS_EXT=y with CGROUPS=n is a
valid config. I reproduced the build failure using the bot's config.

The issue is that CONFIG_EXT_SUB_SCHED is def_bool y depending only on
SCHED_CLASS_EXT, so it's always on. But EXT_SUB_SCHED fundamentally
needs cgroups (cgroup_path, cgroup_get, cgroup_put, cgroup_id, etc.),
so the missing dependency is there.

Cheng-Yang, can you send a v2 with the following approach?

1. Add CGROUPS dependency to EXT_SUB_SCHED in init/Kconfig:

    config EXT_SUB_SCHED
            def_bool y
   -        depends on SCHED_CLASS_EXT
   +        depends on SCHED_CLASS_EXT && CGROUPS

2. Guard err_stop_helper with #ifdef CONFIG_EXT_SUB_SCHED (only
   jumped to from within CONFIG_EXT_SUB_SCHED code):

   +#ifdef CONFIG_EXT_SUB_SCHED
    err_stop_helper:
            kthread_destroy_worker(sch->helper);
   +#endif
    err_free_pcpu:

3. Guard cgroup_get/cgroup_put in common paths with the existing
   CONFIG_EXT_GROUP_SCHED || CONFIG_EXT_SUB_SCHED pattern (matching
   the root_cgroup() / sch_cgroup() stubs):

    err_put_cgrp:
   +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
            cgroup_put(cgrp);
   +#endif

   and:

   +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
            cgroup_get(cgrp);
   +#endif
            sch = scx_alloc_and_add_sched(ops, cgrp, NULL);

I verified this builds clean with both CGROUPS=y and CGROUPS=n.

Thanks.

--
tejun

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

* Re: [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-21 19:10   ` Tejun Heo
@ 2026-03-21 23:26     ` Andrea Righi
  2026-03-22  6:43     ` Cheng-Yang Chou
  1 sibling, 0 replies; 6+ messages in thread
From: Andrea Righi @ 2026-03-21 23:26 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Cheng-Yang Chou, sched-ext, David Vernet, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai, kernel test robot,
	Emil Tsalapatis, linux-kernel

Hi,

On Sat, Mar 21, 2026 at 09:10:03AM -1000, Tejun Heo wrote:
> Hello,
> 
> On Sat, Mar 21, 2026 at 03:35:20PM +0100, Andrea Righi wrote:
> > This looks like a false positive, the kernel test robot likely tested
> > with a manually crafted config, so I think we shouldn't apply this
> > patch.
> 
> It's not a false positive. CONFIG_SCHED_CLASS_EXT doesn't depend on
> CONFIG_CGROUPS in Kconfig, so SCHED_CLASS_EXT=y with CGROUPS=n is a
> valid config. I reproduced the build failure using the bot's config.
> 
> The issue is that CONFIG_EXT_SUB_SCHED is def_bool y depending only on
> SCHED_CLASS_EXT, so it's always on. But EXT_SUB_SCHED fundamentally
> needs cgroups (cgroup_path, cgroup_get, cgroup_put, cgroup_id, etc.),
> so the missing dependency is there.

Ah you guys are right! I was assuming that you can't have
CONFIG_SCHED_CLASS_EXT=y and CONFIG_CGROUPS=n, but that's just wrong.

So ignore my comment and sorry for the noise.

> 
> Cheng-Yang, can you send a v2 with the following approach?
> 
> 1. Add CGROUPS dependency to EXT_SUB_SCHED in init/Kconfig:
> 
>     config EXT_SUB_SCHED
>             def_bool y
>    -        depends on SCHED_CLASS_EXT
>    +        depends on SCHED_CLASS_EXT && CGROUPS
> 
> 2. Guard err_stop_helper with #ifdef CONFIG_EXT_SUB_SCHED (only
>    jumped to from within CONFIG_EXT_SUB_SCHED code):
> 
>    +#ifdef CONFIG_EXT_SUB_SCHED
>     err_stop_helper:
>             kthread_destroy_worker(sch->helper);
>    +#endif
>     err_free_pcpu:
> 
> 3. Guard cgroup_get/cgroup_put in common paths with the existing
>    CONFIG_EXT_GROUP_SCHED || CONFIG_EXT_SUB_SCHED pattern (matching
>    the root_cgroup() / sch_cgroup() stubs):
> 
>     err_put_cgrp:
>    +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
>             cgroup_put(cgrp);
>    +#endif
> 
>    and:
> 
>    +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
>             cgroup_get(cgrp);
>    +#endif
>             sch = scx_alloc_and_add_sched(ops, cgrp, NULL);
> 
> I verified this builds clean with both CGROUPS=y and CGROUPS=n.

And this looks good also on my side.

Thanks,
-Andrea

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

* Re: [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs
  2026-03-21 19:10   ` Tejun Heo
  2026-03-21 23:26     ` Andrea Righi
@ 2026-03-22  6:43     ` Cheng-Yang Chou
  1 sibling, 0 replies; 6+ messages in thread
From: Cheng-Yang Chou @ 2026-03-22  6:43 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrea Righi, sched-ext, David Vernet, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai, kernel test robot,
	Emil Tsalapatis, linux-kernel

Hi Tejun,

On Sat, Mar 21, 2026 at 09:10:03AM -1000, Tejun Heo wrote:
> Hello,
> 
> On Sat, Mar 21, 2026 at 03:35:20PM +0100, Andrea Righi wrote:
> > This looks like a false positive, the kernel test robot likely tested
> > with a manually crafted config, so I think we shouldn't apply this
> > patch.
> 
> It's not a false positive. CONFIG_SCHED_CLASS_EXT doesn't depend on
> CONFIG_CGROUPS in Kconfig, so SCHED_CLASS_EXT=y with CGROUPS=n is a
> valid config. I reproduced the build failure using the bot's config.
> 
> The issue is that CONFIG_EXT_SUB_SCHED is def_bool y depending only on
> SCHED_CLASS_EXT, so it's always on. But EXT_SUB_SCHED fundamentally
> needs cgroups (cgroup_path, cgroup_get, cgroup_put, cgroup_id, etc.),
> so the missing dependency is there.
> 
> Cheng-Yang, can you send a v2 with the following approach?
> 
> 1. Add CGROUPS dependency to EXT_SUB_SCHED in init/Kconfig:
> 
>     config EXT_SUB_SCHED
>             def_bool y
>    -        depends on SCHED_CLASS_EXT
>    +        depends on SCHED_CLASS_EXT && CGROUPS
> 
> 2. Guard err_stop_helper with #ifdef CONFIG_EXT_SUB_SCHED (only
>    jumped to from within CONFIG_EXT_SUB_SCHED code):
> 
>    +#ifdef CONFIG_EXT_SUB_SCHED
>     err_stop_helper:
>             kthread_destroy_worker(sch->helper);
>    +#endif
>     err_free_pcpu:
> 
> 3. Guard cgroup_get/cgroup_put in common paths with the existing
>    CONFIG_EXT_GROUP_SCHED || CONFIG_EXT_SUB_SCHED pattern (matching
>    the root_cgroup() / sch_cgroup() stubs):
> 
>     err_put_cgrp:
>    +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
>             cgroup_put(cgrp);
>    +#endif
> 
>    and:
> 
>    +#if defined(CONFIG_EXT_GROUP_SCHED) || defined(CONFIG_EXT_SUB_SCHED)
>             cgroup_get(cgrp);
>    +#endif
>             sch = scx_alloc_and_add_sched(ops, cgrp, NULL);
> 
> I verified this builds clean with both CGROUPS=y and CGROUPS=n.
> 
> Thanks.
> 
> --
> tejun

I have sent a v2 patch.
Thanks for explaining the dependency issue!

Link to v2:
https://lore.kernel.org/r/20260322063955.951848-1-yphbchou0911@gmail.com/

-- 
Thanks,
Cheng-Yang

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21  7:05 [PATCH] sched_ext: Fix build errors and unused label warning in non-cgroup configs Cheng-Yang Chou
2026-03-21 14:35 ` Andrea Righi
2026-03-21 17:31   ` Cheng-Yang Chou
2026-03-21 19:10   ` Tejun Heo
2026-03-21 23:26     ` Andrea Righi
2026-03-22  6:43     ` Cheng-Yang Chou

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.