From c5f0aec546c4950d94acc367a631ec4db437c622 Mon Sep 17 00:00:00 2001 From: Friedrich Weber Date: Wed, 12 Mar 2025 16:15:04 +0100 Subject: [PATCH] fix #2413: pvestatd: read ballooning RAM usage target from node config 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 Tested-by: Stoiko Ivanov Reviewed-by: Stoiko Ivanov Link: https://lore.kernel.org/r/20250312151506.128311-3-f.weber@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);