From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Thu, 20 Aug 2026 18:57:16 +0200 Subject: [Devel] [PATCH RHEL10 COMMIT] sched/loadavg: fix build with CONFIG_CGROUP_SCHED=n In-Reply-To: <20260625220832.2201873-1-eva.kurchatova@virtuozzo.com> Message-ID: <202608201657.67KGvGOf829038@hci8VM.finist.virtuozzo.com> List-Id: The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git after rh10-6.12.0-211.39.1.16.6.vz10 ------> commit f869ffa52901a2949cf1554e573e3500b9f85f32 Author: Eva Kurchatova Date: Thu Aug 20 18:42:45 2026 +0200 sched/loadavg: fix build with CONFIG_CGROUP_SCHED=n 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 instead of relying on CONFIG_VE selecting it. 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 --- 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<