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 <f.weber@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Link: https://lore.kernel.org/r/20250312151506.128311-3-f.weber@proxmox.com
This commit is contained in:
Friedrich Weber 2025-03-12 16:15:04 +01:00 committed by Thomas Lamprecht
parent cca3eaded2
commit c5f0aec546

View File

@ -15,6 +15,7 @@ use PVE::CpuSet;
use Filesys::Df; use Filesys::Df;
use PVE::INotify; use PVE::INotify;
use PVE::Network; use PVE::Network;
use PVE::NodeConfig;
use PVE::Cluster qw(cfs_read_file); use PVE::Cluster qw(cfs_read_file);
use PVE::Storage; use PVE::Storage;
use PVE::QemuServer; 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 #$hostmeminfo->{memtotal} = int(2*1024*1024*1024/0.8); # you can set this to test
my $hostfreemem = $hostmeminfo->{memtotal} - $hostmeminfo->{memused}; my $hostfreemem = $hostmeminfo->{memtotal} - $hostmeminfo->{memused};
# try to use ~80% host memory; goal is the change amount required to achieve that # try to keep host memory usage at a certain percentage (= target), default is 80%
my $goal = int($hostmeminfo->{memtotal} * 0.8 - $hostmeminfo->{memused}); my $config = PVE::NodeConfig::load_config($nodename);
$log->("host goal: $goal free: $hostfreemem total: $hostmeminfo->{memtotal}\n"); 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 $maxchange = 100*1024*1024;
my $res = PVE::AutoBalloon::compute_alg1($vmstatus, $goal, $maxchange); my $res = PVE::AutoBalloon::compute_alg1($vmstatus, $goal, $maxchange);