[pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config

Friedrich Weber f.weber at proxmox.com
Wed Mar 12 16:15:04 CET 2025


Currently, the automatic memory management (ballooning) performed by
pvestatd targets 80% memory usage. Users have reported that this
target is unnecessarily low on hosts with large amounts of RAM.

Thus, read the target from the node config option `ballooning-target`.
Also change the ballooning debug log output to include the target.

Signed-off-by: Friedrich Weber <f.weber at proxmox.com>
---
 PVE/Service/pvestatd.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 7fa003fe..d80c62da 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -15,6 +15,7 @@ use PVE::CpuSet;
 use Filesys::Df;
 use PVE::INotify;
 use PVE::Network;
+use PVE::NodeConfig;
 use PVE::Cluster qw(cfs_read_file);
 use PVE::Storage;
 use PVE::QemuServer;
@@ -215,9 +216,12 @@ sub auto_balloning {
     #$hostmeminfo->{memtotal} = int(2*1024*1024*1024/0.8); # you can set this to test
     my $hostfreemem = $hostmeminfo->{memtotal} - $hostmeminfo->{memused};
 
-    # try to use ~80% host memory; goal is the change amount required to achieve that
-    my $goal = int($hostmeminfo->{memtotal} * 0.8 - $hostmeminfo->{memused});
-    $log->("host goal: $goal free: $hostfreemem total: $hostmeminfo->{memtotal}\n");
+    # try to keep host memory usage at a certain percentage (= target), default is 80%
+    my $config = PVE::NodeConfig::load_config($nodename);
+    my $target = int($config->{'ballooning-target'} // 80);
+    # goal is the change amount required to achieve that
+    my $goal = int($hostmeminfo->{memtotal} * $target / 100 - $hostmeminfo->{memused});
+    $log->("target: $target%% host goal: $goal free: $hostfreemem total: $hostmeminfo->{memtotal}\n");
 
     my $maxchange = 100*1024*1024;
     my $res = PVE::AutoBalloon::compute_alg1($vmstatus, $goal, $maxchange);
-- 
2.39.5





More information about the pve-devel mailing list