From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Fri, 21 Aug 2026 18:36:47 +0200 Subject: [Devel] [PATCH vz10 01/32] sched/loadavg: fix build with CONFIG_CGROUP_SCHED=n In-Reply-To: <20260821163718.187766-1-khorenko@virtuozzo.com> References: <20260821163718.187766-1-khorenko@virtuozzo.com> Message-ID: <20260821163718.187766-2-khorenko@virtuozzo.com> List-Id: From: Eva Kurchatova get_avenrun_tg() dereferences struct task_group, which is only defined under CONFIG_CGROUP_SCHED in kernel/sched/sched.h. Both the function and its unconditional caller are compiled regardless of that option: kernel/sched/loadavg.c is pulled into build_utility.c, and do_sysinfo() calls get_avenrun_tg() from a branch that is dead at runtime with CONFIG_VE=n but still compiled. So CONFIG_CGROUP_SCHED=n does not build: kernel/sched/loadavg.c: error: invalid use of undefined type 'struct task_group' Compile get_avenrun_tg() only when CONFIG_CGROUP_SCHED is enabled and provide a stub otherwise. The stub returns -ENOSYS, the same error the real implementation returns when there is no per-Container task group to report. do_sysinfo() ignores the return value and info->loads is already zeroed by memset(), so no caller has to change. calc_load_ve() walks the very same task_group internals, so require CONFIG_CGROUP_SCHED there as well: the dependency then stands where the code is, instead of being implied by the select list of CONFIG_VE. Fixes: c80eee4588ff ("ve/sched/loadavg: Calculate avenrun for Containers root cpu cgroups") Feature: statistics: loadavg virtualization https://virtuozzo.atlassian.net/browse/VSTOR-134732 Signed-off-by: Eva Kurchatova Signed-off-by: Konstantin Khorenko --- include/linux/sched/loadavg.h | 11 ++++++++++- kernel/sched/loadavg.c | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/linux/sched/loadavg.h b/include/linux/sched/loadavg.h index 771e753e4670..b97635dc47d4 100644 --- a/include/linux/sched/loadavg.h +++ b/include/linux/sched/loadavg.h @@ -2,6 +2,7 @@ #ifndef _LINUX_SCHED_LOADAVG_H #define _LINUX_SCHED_LOADAVG_H +#include #include /* @@ -18,8 +19,16 @@ extern unsigned long avenrun[]; /* Load averages */ extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift); struct task_group; +#ifdef CONFIG_CGROUP_SCHED extern int get_avenrun_tg(struct task_group *tg, unsigned long *loads, unsigned long offset, int shift); +#else +static inline int get_avenrun_tg(struct task_group *tg, unsigned long *loads, + unsigned long offset, int shift) +{ + return -ENOSYS; +} +#endif #define FSHIFT 11 /* nr of bits of precision */ #define FIXED_1 (1<