public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v3 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem
@ 2022-01-14  7:44 Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Derumier @ 2022-01-14  7:44 UTC (permalink / raw)
  To: pve-devel

Hi,this is a resend of patches from last year.

vm pressure stats && true host cpu/mem usage is really needed to implement correct
balancing.


This add new cgroups value stats.

hostcpu/hostmem give the real cpu/mem usage of a vm, including vhost-net.


Changelog v3:

  - rebase on last master

Changelog v2:
 - rebase on last master
 - use new pressure code from pve-common


Alexandre Derumier (3):
  vmstatus: add hostcpu value
  vmstatus: add hostmem value
  vmstatus: add pressure stats

 PVE/QemuServer.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH v3 qemu-server 1/3] vmstatus: add hostcpu value
  2022-01-14  7:44 [pve-devel] [PATCH v3 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
@ 2022-01-14  7:44 ` Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2022-01-14  7:44 UTC (permalink / raw)
  To: pve-devel

---
 PVE/QemuServer.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0071a06..65115ba 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2877,8 +2877,11 @@ sub vmstatus {
 
 	my $pstat = PVE::ProcFSTools::read_proc_pid_stat($pid);
 	next if !$pstat; # not running
+	my $cgroups = PVE::QemuServer::CGroup->new($vmid);
+	my $hostcpustat = $cgroups->get_cpu_stat();
 
 	my $used = $pstat->{utime} + $pstat->{stime};
+	my $hostused = $hostcpustat->{utime} + $hostcpustat->{stime};
 
 	$d->{uptime} = int(($uptime - $pstat->{starttime})/$cpuinfo->{user_hz});
 
@@ -2892,6 +2895,9 @@ sub vmstatus {
 		time => $ctime,
 		used => $used,
 		cpu => 0,
+		hostused => $hostused,
+		hostcpu => 0,
+
 	    };
 	    next;
 	}
@@ -2900,15 +2906,20 @@ sub vmstatus {
 
 	if ($dtime > 1000) {
 	    my $dutime = $used -  $old->{used};
+	    my $dhostutime = $hostused -  $old->{hostused};
 
 	    $d->{cpu} = (($dutime/$dtime)* $cpucount) / $d->{cpus};
+	    $d->{hostcpu} = (($dhostutime/$dtime)* $cpucount) / $d->{cpus};
 	    $last_proc_pid_stat->{$pid} = {
 		time => $ctime,
 		used => $used,
 		cpu => $d->{cpu},
+		hostused => $hostused,
+		hostcpu => $d->{hostcpu},
 	    };
 	} else {
 	    $d->{cpu} = $old->{cpu};
+	    $d->{hostcpu} = $old->{hostcpu};
 	}
     }
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH v3 qemu-server 2/3] vmstatus: add hostmem value
  2022-01-14  7:44 [pve-devel] [PATCH v3 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
@ 2022-01-14  7:44 ` Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2022-01-14  7:44 UTC (permalink / raw)
  To: pve-devel

---
 PVE/QemuServer.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 65115ba..6d4027b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2888,6 +2888,11 @@ sub vmstatus {
 	if ($pstat->{vsize}) {
 	    $d->{mem} = int(($pstat->{rss}/$pstat->{vsize})*$d->{maxmem});
 	}
+	if (defined(my $hostmemstat = $cgroups->get_memory_stat())) {
+	    $d->{hostmem} = $hostmemstat->{mem};
+	} else {
+	    $d->{hostmem} = 0;
+	}
 
 	my $old = $last_proc_pid_stat->{$pid};
 	if (!$old) {
-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH v3 qemu-server 3/3] vmstatus: add pressure stats
  2022-01-14  7:44 [pve-devel] [PATCH v3 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
  2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
@ 2022-01-14  7:44 ` Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2022-01-14  7:44 UTC (permalink / raw)
  To: pve-devel

---
 PVE/QemuServer.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6d4027b..e4b6765 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2926,6 +2926,8 @@ sub vmstatus {
 	    $d->{cpu} = $old->{cpu};
 	    $d->{hostcpu} = $old->{hostcpu};
 	}
+
+	$d->{pressure} = $cgroups->get_pressure_stat();
     }
 
     return $res if !$full;
-- 
2.30.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-14  7:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  7:44 [pve-devel] [PATCH v3 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
2022-01-14  7:44 ` [pve-devel] [PATCH v3 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier

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