[Devel] [PATCH vz10 24/32] sched/core: include cgroup-internal.h only where it is used

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 21 19:37:10 MSK 2026


From: Eva Kurchatova <eva.kurchatova at virtuozzo.com>

kernel/sched/core.c includes the private cgroup-internal.h for the sake of
one cgroup_task_count() call in cpu_cgroup_proc_loadavg(), which lives in
the CONFIG_CGROUP_SCHED part of the file.  The include itself is
unconditional, and it does not compile without the cgroup core:

  cgroup/cgroup-internal.h:188:22: error: invalid use of undefined type
                                   'const struct cgroup'
  cgroup/cgroup-internal.h:188:37: error: 'CSS_ONLINE' undeclared (first
                                   use in this function)

Guard the include with CONFIG_CGROUP_SCHED, the same condition as its only
user.  This does not make CONFIG_CGROUPS=n build by itself - struct
ve_struct embeds a struct cgroup_subsys_state, so ve.h needs the cgroup
core in any case - but it does keep another subsystem's private header out
of scheduler translation units that have no use for it.

Fixes: c0997a766674 ("ve/proc/loadavg: Virtualize /proc/loadavg in Containers")
Feature: statistics: loadavg virtualization
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 kernel/sched/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7d2214749245..fb2477cb1d07 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -152,7 +152,9 @@ __read_mostly unsigned int sysctl_sched_features =
 __read_mostly int sysctl_resched_latency_warn_ms = 100;
 __read_mostly int sysctl_resched_latency_warn_once = 1;
 
+#ifdef CONFIG_CGROUP_SCHED
 #include "../cgroup/cgroup-internal.h" /* For cgroup_task_count() */
+#endif
 
 /*
  * Number of tasks to iterate in a single balance run.
-- 
2.47.1



More information about the Devel mailing list