OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: Re: [Devel] [PATCH vz10 01/14] sched: fix VZ build errors with CONFIG_CGROUP_SCHED=n
Date: Fri, 21 Aug 2026 18:48:40 +0200	[thread overview]
Message-ID: <4f6d81c5-6390-4440-a46b-a1e8831d7b14@virtuozzo.com> (raw)
In-Reply-To: <20260625220832.2201873-1-eva.kurchatova@virtuozzo.com>

This patchset is superseded by 
[PATCH vz10 00/32] Fix the VZ kernel build so that KUnit can run

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 6/26/26 00:08, Eva Kurchatova wrote:
> 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 <eva.kurchatova@virtuozzo.com>
> 
> 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


      parent reply	other threads:[~2026-08-21 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260625220832.2201873-1-eva.kurchatova@virtuozzo.com>
2026-08-20 16:57 ` [Devel] [PATCH RHEL10 COMMIT] sched/loadavg: fix build " Konstantin Khorenko
2026-08-20 16:57 ` [Devel] [PATCH RHEL10 COMMIT] sched/core: guard cpu_cgrp_subsys.depends_on with CONFIG_CGROUP_CPUACCT Konstantin Khorenko
2026-08-20 16:57 ` [Devel] [PATCH RHEL10 COMMIT] sched: move MAX_CPU_RATE out of CONFIG_CFS_CPULIMIT Konstantin Khorenko
2026-08-20 16:57 ` [Devel] [PATCH RHEL10 COMMIT] sched/cpuacct: guard ve_root_tg() with CONFIG_CFS_CPULIMIT Konstantin Khorenko
     [not found] ` <20260625220832.2201873-2-eva.kurchatova@virtuozzo.com>
2026-08-21 14:03   ` [Devel] [PATCH vz10 02/14] mm: fix VZ build errors with CONFIG_MEMCG=n Konstantin Khorenko
2026-08-21 16:48 ` Konstantin Khorenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f6d81c5-6390-4440-a46b-a1e8831d7b14@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox