[Devel] [VZ10 06/21] ve/sched.h: Fix errors and warnings when !CONFIG_VE

Vladimir Riabchun vladimir.riabchun at virtuozzo.com
Thu May 7 22:10:18 MSK 2026


When !CONFIG_VE, we define noop cpu_cgroup_proc_* functions,
but they actually have bodies in cpuacct.c.

Move their declarations outside CONFIG_VE and inside
CONFIG_CGROUP_CPUACCT.
This fixes a ton of annoying compiler warnings:
kernel/sched/cpuacct.c: At top level:
kernel/sched/cpuacct.c:758:5: warning: no previous prototype for 'cpu_cgroup_get_stat' [-Wmissing-prototypes]
  758 | int cpu_cgroup_get_stat(struct cgroup_subsys_state *cpu_css,
      |     ^~~~~~~~~~~~~~~~~~~

Also, fix cpu_cgroup_proc_stat definition when !CONFIG_VE:
Current version misses static specifier, this violates ODR
and leads to linker errors.

https://virtuozzo.atlassian.net/browse/VSTOR-130116

Feature: !CONFIG_VE build
Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
---
 include/linux/sched.h | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 72d17528fa8f..bffd6a5cf678 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2245,10 +2245,10 @@ static inline int sched_core_idle_cpu(int cpu) { return idle_cpu(cpu); }
 extern void sched_set_stop_task(int cpu, struct task_struct *stop);
 
 struct cgroup_subsys_state;
-#ifdef CONFIG_VE
-void link_ve_root_cpu_cgroup(struct cgroup_subsys_state *css);
-void unlink_ve_root_cpu_cgroup(struct cgroup_subsys_state *css);
+
 int cpu_cgroup_proc_loadavg(struct cgroup_subsys_state *css, struct seq_file *p);
+
+#ifdef CONFIG_CGROUP_CPUACCT
 int cpu_cgroup_proc_stat_show(struct seq_file *sf, void *v);
 int cpu_cgroup_get_stat(struct cgroup_subsys_state *cpu_css,
 			struct cgroup_subsys_state *cpuacct_css,
@@ -2256,23 +2256,35 @@ int cpu_cgroup_get_stat(struct cgroup_subsys_state *cpu_css,
 int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
 			 struct cgroup_subsys_state *cpuacct_css,
 			 struct seq_file *p);
-#else /* CONFIG_VE */
-static inline void link_ve_root_cpu_cgroup(struct cgroup_subsys_state *css)
-{
-}
-static inline void unlink_ve_root_cpu_cgroup(struct cgroup_subsys_state *css)
+#else /* CONFIG_CGROUP_CPUACCT */
+static inline int cpu_cgroup_proc_stat_show(struct seq_file *sf, void *v)
 {
+	return 0;
 }
-static int cpu_cgroup_proc_stat_show(struct seq_file *sf, void *v)
+static inline int cpu_cgroup_get_stat(struct cgroup_subsys_state *cpu_css,
+			struct cgroup_subsys_state *cpuacct_css,
+			struct kernel_cpustat *kstat)
 {
 	return 0;
 }
-int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
+static inline int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css,
 			 struct cgroup_subsys_state *cpuacct_css,
 			 struct seq_file *p)
 {
 	return 0;
 }
+#endif /* CONFIG_CGROUP_CPUACCT */
+
+#ifdef CONFIG_VE
+void link_ve_root_cpu_cgroup(struct cgroup_subsys_state *css);
+void unlink_ve_root_cpu_cgroup(struct cgroup_subsys_state *css);
+#else /* CONFIG_VE */
+static inline void link_ve_root_cpu_cgroup(struct cgroup_subsys_state *css)
+{
+}
+static inline void unlink_ve_root_cpu_cgroup(struct cgroup_subsys_state *css)
+{
+}
 #endif /* CONFIG_VE */
 
 #ifdef CONFIG_MEM_ALLOC_PROFILING
-- 
2.43.0



More information about the Devel mailing list