[Devel] [PATCH vz10 v4 1/3] sched: Clean up vCPU handling logic
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Mar 19 16:12:43 MSK 2026
On 3/19/26 10:47, Dmitry Sepp wrote:
> The idea behind the change is to transition from the existing spatial
> vCPU handling approach that introduces costly modification to the
> scheduling logic to ensure the requested CPU count is obeyed (10%+
> performance drop in some tests) to temporal isolation that can be
> provided by the cgroup2 cpu.max.
>
> Drop the legacy unneeded vCPU handling code. Remove the 'cpu.rate'
> control in favor of the internal calculation based on 'quota' and
> 'period' from 'cpu.max'. As 'cpu.max' is not implicitly used to set the
> rate, do not override nr_cpus when handling writes to 'cpu.max'.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-124385
>
> Signed-off-by: Dmitry Sepp <dmitry.sepp at virtuozzo.com>
> ---
> include/linux/sched.h | 6 -
> include/linux/sched/topology.h | 5 -
> kernel/sched/core.c | 98 +-------
> kernel/sched/fair.c | 408 ---------------------------------
> kernel/sched/sched.h | 10 -
> 5 files changed, 12 insertions(+), 515 deletions(-)
>
...
>
> -static int tg_set_cpu_limit(struct task_group *tg,
> - unsigned long cpu_rate, unsigned int nr_cpus)
> +static int tg_set_cpu_limit(struct task_group *tg, unsigned int nr_cpus)
> {
> int ret;
> unsigned long rate;
> + unsigned long cpu_rate = tg->cpu_rate;
> u64 quota = RUNTIME_INF;
> u64 burst = tg_get_cfs_burst(tg);
> u64 period = default_cfs_period();
> @@ -10090,21 +10041,6 @@ static int tg_set_cpu_limit(struct task_group *tg,
> return ret;
> }
>
static int tg_set_cpu_limit(struct task_group *tg, unsigned int nr_cpus)
{
int ret;
unsigned long rate;
unsigned long cpu_rate = tg->cpu_rate;
u64 quota = RUNTIME_INF;
u64 burst = tg_get_cfs_burst(tg);
u64 period = default_cfs_period();
rate = (cpu_rate && nr_cpus) ?
min_t(unsigned long, cpu_rate, nr_cpus * MAX_CPU_RATE) :
max_t(unsigned long, cpu_rate, nr_cpus * MAX_CPU_RATE);
if (rate) {
quota = div_u64(period * rate, MAX_CPU_RATE);
quota = max(quota, min_cfs_quota_period);
}
cpus_read_lock();
mutex_lock(&cfs_constraints_mutex);
ret = __tg_set_cfs_bandwidth(tg, period, quota, burst);
if (!ret) {
tg->cpu_rate = cpu_rate;
// the line above is a no-op.
// i will apply the patch as is but in case this was not intended, please fix it with an incremental patch
tg->nr_cpus = nr_cpus;
}
mutex_unlock(&cfs_constraints_mutex);
cpus_read_unlock();
return ret;
}
More information about the Devel
mailing list