OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz10 03/32] sched: move MAX_CPU_RATE out of CONFIG_CFS_CPULIMIT
@ 2026-08-21 16:36 Konstantin Khorenko
  2026-08-21 16:42 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
  0 siblings, 1 reply; 7+ messages in thread
From: Konstantin Khorenko @ 2026-08-21 16:36 UTC (permalink / raw)


MAX_CPU_RATE is the scale of task_group::cpu_rate, but it was defined in
the middle of the body of struct task_group, inside the block guarded by
CONFIG_CFS_CPULIMIT.  cpu_cgroup_update_vcpustat() uses it to normalize
the per-vcpu usage reported in a Container's /proc/stat, and that code is
compiled unconditionally, so CONFIG_CFS_CPULIMIT=n does not build:

  kernel/sched/cpuacct.c: error: 'MAX_CPU_RATE' undeclared
                          (first use in this function)

x86_64 defconfig is exactly such a configuration: CONFIG_VE defaults to
y, while CONFIG_CFS_BANDWIDTH - the only thing that selects
CONFIG_CFS_CPULIMIT - is off.

Move the definition out of the struct and out of the ifdef.  Nothing
else in cpu_cgroup_update_vcpustat() needs CONFIG_CFS_CPULIMIT:
tg_cpu_rate() and tg_nr_cpus() already degrade to "no limit configured",
so the vcpustat calculation keeps working and a Container simply gets
num_online_cpus() vcpus running at full rate.  Compiling the calculation
out instead would leave tg->vcpustat all zeroes, and /proc/stat inside a
Container would report no CPU time at all.

Fixes: 4e99efb641da ("sched: Port CONFIG_CFS_CPULIMIT feature")
Feature: sched: ability to limit number of CPUs available to a CT
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Reported-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 kernel/sched/sched.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1a8a0ff522cb..2a3f73933456 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -533,12 +533,19 @@ struct task_group {
 #endif
 
 #ifdef CONFIG_CFS_CPULIMIT
-#define MAX_CPU_RATE 1024
 	unsigned long cpu_rate;
 	unsigned int nr_cpus;
 #endif
 };
 
+/*
+ * The scale of task_group::cpu_rate: 1024 means one full CPU.  It is also
+ * used to normalize the per-vcpu usage reported in a Container's /proc/stat,
+ * which is done regardless of CONFIG_CFS_CPULIMIT, so keep the definition
+ * unconditional.
+ */
+#define MAX_CPU_RATE 1024
+
 #ifdef CONFIG_GROUP_SCHED_WEIGHT
 #define ROOT_TASK_GROUP_LOAD	NICE_0_LOAD
 
-- 
2.47.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-21 16:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260625220832.2201873-1-eva.kurchatova@virtuozzo.com>
2026-08-20 16:57 ` [Devel] [PATCH RHEL10 COMMIT] sched/loadavg: fix build with CONFIG_CGROUP_SCHED=n 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 ` [Devel] [PATCH vz10 01/14] sched: fix VZ build errors with CONFIG_CGROUP_SCHED=n Konstantin Khorenko
2026-08-21 16:36 [Devel] [PATCH vz10 03/32] sched: move MAX_CPU_RATE out of CONFIG_CFS_CPULIMIT Konstantin Khorenko
2026-08-21 16:42 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox