[PATCH pve-common] Update cpu.weight default to match documented default

Matt Corallo lpxdfsfs at mattcorallo.com
Tue Aug 16 05:57:30 CEST 2022


Proxmox documentation describes the default CPU weight as 1024 in
numerous places. However, `change_cpu_shares` was matching Linux
CGROUP2's default weight of 100. This causes VMs with CPU weights
between 100 and 1023 to be weighted more than VMs with a weight of
1024.

The fix is to simply change the default to match the Proxmox
documented default.

Signed-off-by: Matt Corallo <git at bluematt.me>
---
  src/PVE/CGroup.pm | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CGroup.pm b/src/PVE/CGroup.pm
index 44b3297..a868af1 100644
--- a/src/PVE/CGroup.pm
+++ b/src/PVE/CGroup.pm
@@ -499,8 +499,9 @@ sub change_cpu_shares {
      if (!defined($path)) {
  	die "trying to change cpu shares/weight cgroup values: container not running\n";
      } elsif ($ver == 2) {
-	# the cgroupv2 documentation defines the default to 100
-	$shares //= 100;
+	# the cgroupv2 documentation defines the default to 100, but Proxmox documented
+	# default is 1024, so we have to match that.
+	$shares //= 1024;
  	die "cpu weight (shares) must be in range [1, 10000]\n" if $shares < 1 || $shares > 10000;
  	PVE::ProcFSTools::write_proc_entry("$path/cpu.weight", $shares);
      } elsif ($ver == 1) {
-- 
2.35.1




More information about the pve-devel mailing list