[pve-devel] [PATCH qemu-server v4 2/4] vmstatus: add memhost for host view of vm mem consumption
Lukas Wagner
l.wagner at proxmox.com
Tue Jul 29 14:49:58 CEST 2025
On Sat Jul 26, 2025 at 3:06 AM CEST, Aaron Lauterer wrote:
> + my $fh = IO::File->new("/sys/fs/cgroup/qemu.slice/${vmid}.scope/cgroup.procs", "r");
> + if ($fh) {
> + while (my $childPid = <$fh>) {
> + chomp($childPid);
nit: should be snake_case
> + open(my $SMAPS_FH, '<', "/proc/$childPid/smaps_rollup")
> + or die "failed to open PSS memory-stat from process - $!\n";
> +
> + while (my $line = <$SMAPS_FH>) {
> + if ($line =~ m/^Pss:\s+([0-9]+) kB$/) {
> + $d->{memhost} = $d->{memhost} + int($1) * 1024;
Why do you sum up $d->{memhost} with the thing you just read from /proc?
As far as I can tell memhost should always be zero at this point....
> + last;
... and also you break here from the loop, so even if there were two Pss
lines, you wouldn't add them up.
Am I missing something? :)
> + }
> + }
> + close $SMAPS_FH;
> + }
> + }
> + close($fh);
> +
> my $pressures = PVE::ProcFSTools::read_cgroup_pressure("qemu.slice/${vmid}.scope");
> $d->{pressurecpusome} = $pressures->{cpu}->{some}->{avg10} * 1;
> $d->{pressurecpufull} = $pressures->{cpu}->{full}->{avg10} * 1;
> @@ -2707,7 +2732,6 @@ sub vmstatus {
> } else {
> $d->{cpu} = $old->{cpu};
> }
> -
> }
>
> return $res if !$full;
More information about the pve-devel
mailing list