Guard VZ-specific code that depends on struct task_group, root_task_group, cpu_cgrp_id and cpuacct_cgrp_id with the appropriate Kconfig options.
Without CONFIG_CGROUP_SCHED: - struct task_group is incomplete, so get_avenrun_tg() and calc_load_ve() fail to compile. - cpu_cgrp_id is undeclared, so the link_ve_root_cpu_cgroup() call in cgroup_mark_ve_roots() does not build. Without CONFIG_CGROUP_CPUACCT: - cpuacct_cgrp_id is undeclared, so the cpu_cgrp_subsys.depends_on initializer fails. - cpu_cgroup_update_vcpustat() uses MAX_CPU_RATE which requires CONFIG_CFS_CPULIMIT. Add a static inline stub for get_avenrun_tg() when CONFIG_CGROUP_SCHED is disabled, tighten the guards on calc_load_ve() to require both CONFIG_VE and CONFIG_CGROUP_SCHED, and wrap cpu_cgroup_update_vcpustat() with CONFIG_CFS_CPULIMIT. Signed-off-by: Eva Kurchatova <[email protected]> https://virtuozzo.atlassian.net/browse/VSTOR-134732 Feature: fix kunit --- include/linux/sched/loadavg.h | 10 +++++++++- kernel/sched/core.c | 2 ++ kernel/sched/cpuacct.c | 5 +++++ kernel/sched/loadavg.c | 6 ++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/sched/loadavg.h b/include/linux/sched/loadavg.h index 771e753e4670..f019a7306600 100644 --- a/include/linux/sched/loadavg.h +++ b/include/linux/sched/loadavg.h @@ -18,8 +18,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 -1; +} +#endif #define FSHIFT 11 /* nr of bits of precision */ #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ @@ -51,7 +59,7 @@ extern unsigned long calc_load_n(unsigned long load, unsigned long exp, extern bool calc_global_load(void); -#ifdef CONFIG_VE +#if defined(CONFIG_VE) && defined(CONFIG_CGROUP_SCHED) extern void calc_load_ve(void); #else #define calc_load_ve() do { } while (0) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d5b4d8c97a0c..7d2214749245 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10441,7 +10441,9 @@ struct cgroup_subsys cpu_cgrp_subsys = { .dfl_cftypes = cpu_files, .early_init = true, .threaded = true, +#ifdef CONFIG_CGROUP_CPUACCT .depends_on = 1 << cpuacct_cgrp_id, +#endif }; #endif /* CONFIG_CGROUP_SCHED */ diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 01a2b2c3c5b7..98c13ff2bac8 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -542,6 +542,7 @@ static void fixup_vcpustat_delta(struct kernel_cpustat *cur, cur->cpustat[CPUTIME_STEAL] = 0; } +#ifdef CONFIG_CFS_CPULIMIT static void cpu_cgroup_update_vcpustat(struct cgroup_subsys_state *cpu_css, struct cgroup_subsys_state *cpuacct_css) { @@ -632,6 +633,10 @@ static void cpu_cgroup_update_vcpustat(struct cgroup_subsys_state *cpu_css, out_unlock: spin_unlock(&tg->vcpustat_lock); } +#else +static inline void cpu_cgroup_update_vcpustat(struct cgroup_subsys_state *cpu_css, + struct cgroup_subsys_state *cpuacct_css) {} +#endif int cpu_cgroup_proc_stat(struct cgroup_subsys_state *cpu_css, struct cgroup_subsys_state *cpuacct_css, diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c index bc0b6bcdae2d..c4ca3c83f1cf 100644 --- a/kernel/sched/loadavg.c +++ b/kernel/sched/loadavg.c @@ -78,6 +78,7 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift) loads[2] = (avenrun[2] + offset) << shift; } +#ifdef CONFIG_CGROUP_SCHED int get_avenrun_tg(struct task_group *tg, unsigned long *loads, unsigned long offset, int shift) { @@ -93,6 +94,7 @@ int get_avenrun_tg(struct task_group *tg, unsigned long *loads, return 0; } +#endif long calc_load_fold_active(struct rq *this_rq, long adjust) { @@ -109,7 +111,7 @@ long calc_load_fold_active(struct rq *this_rq, long adjust) return delta; } -#ifdef CONFIG_VE +#if defined(CONFIG_VE) && defined(CONFIG_CGROUP_SCHED) extern struct list_head ve_root_list; extern raw_spinlock_t load_ve_lock; @@ -166,7 +168,7 @@ void calc_load_ve(void) kstat_glob.nr_unint_avg[2] = calc_load(kstat_glob.nr_unint_avg[2], EXP_15, nr_unint); write_seqcount_end(&kstat_glob.nr_unint_avg_seq); } -#endif /* CONFIG_VE */ +#endif /* CONFIG_VE && CONFIG_CGROUP_SCHED */ /** * fixed_power_int - compute: x^n, in O(log n) time -- 2.54.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
