5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-25 18:03:33 +03:00

cgroup: cpu quota: fix resetting period length for v1

The CFS period µs value for cgroup v1 needs to be >= 1 µs and <= 1 s,
so resetting it to -1 (like we cab do for the quota) cannot work.

So, when the period is passed as undefined it should be set to 100ms,
i.e., the actual default value:

>  - cpu.cfs_quota_us: the total available run-time within a period (in microseconds)
>  - cpu.cfs_period_us: the length of a period (in microseconds)
>  - cpu.stat: exports throttling statistics [explained further below]
>
> The default values are:
>     cpu.cfs_period_us=100ms
>     cpu.cfs_quota=-1
-- https://www.kernel.org/doc/html/v5.14/scheduler/sched-bwc.html

This issue was there since initial addition in its original repo,
pve-container commit 26b645e2.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
 [ Thomas: add more information, adapt commit subject to reduce
   redundancy, link to new RsT based doc page with a fixed version ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Oguz Bektas 2021-10-21 16:36:19 +02:00 committed by Thomas Lamprecht
parent d94f7005ce
commit d37a718672

View File

@ -467,8 +467,8 @@ sub change_cpu_quota {
PVE::ProcFSTools::write_proc_entry("$path/cpu.max", 'max');
}
} elsif ($ver == 1) {
$quota //= -1; # unlimited
$period //= -1;
$quota //= -1; # default (unlimited)
$period //= 100_000; # default (100 ms)
PVE::ProcFSTools::write_proc_entry("$path/cpu.cfs_period_us", $period);
PVE::ProcFSTools::write_proc_entry("$path/cpu.cfs_quota_us", $quota);
} else {