public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/4] fix #2413: pvestatd: read ballooning RAM usage target from node config
Date: Wed, 12 Mar 2025 16:15:04 +0100	[thread overview]
Message-ID: <20250312151506.128311-3-f.weber@proxmox.com> (raw)
In-Reply-To: <20250312151506.128311-1-f.weber@proxmox.com>

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>
---
 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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-03-12 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 15:15 [pve-devel] [PATCH manager/docs 0/4] fix #2413: make target for ballooning configurable Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH manager 1/4] node: options: add config option for ballooning target Friedrich Weber
2025-03-12 15:15 ` Friedrich Weber [this message]
2025-03-12 15:15 ` [pve-devel] [PATCH manager 3/4] ui: node options: allow editing the ballooning RAM usage target Friedrich Weber
2025-03-12 15:15 ` [pve-devel] [PATCH docs 4/4] pvenode: document ballooning-target node option Friedrich Weber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250312151506.128311-3-f.weber@proxmox.com \
    --to=f.weber@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal