[pve-devel] [PATCH common 2/4] add functions to retrieve pressures for vm/ct

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jun 2 16:39:30 CEST 2025


Am 23.05.25 um 18:37 schrieb Aaron Lauterer:
> From: Folke Gleumes <f.gleumes at proxmox.com>
> 
> Originally-by: Folke Gleumes <f.gleumes at proxmox.com>
> [AL: rebased on current master]
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
>  src/PVE/ProcFSTools.pm | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
> index f9fe3f0..382e6c5 100644
> --- a/src/PVE/ProcFSTools.pm
> +++ b/src/PVE/ProcFSTools.pm
> @@ -151,6 +151,28 @@ sub parse_pressure {
>      return $res;
>  }
>  
> +sub read_qemu_pressure {
> +    my ($vmid) = @_;
> +
> +    my $res = {};
> +    foreach my $type (qw(cpu memory io)) {
> +	my $stats = parse_pressure("/sys/fs/cgroup/qemu.slice/$vmid.scope/$type.pressure");

There is a SysFSTools module ;-)

But OK, the parse_pressure method is here, so finish I guess.

I'd rather have this more generic though, as you got just two copies of the
same code going on here, and nothing here is specific to qemu or lxc; every
cgroup has these.

So I'd rather switch this over to a single

sub read_cgroup_pressure {
    my ($cgroup_path) = @_;

    my $res = {};
    for my $type (qw(cpu memory io)) {
        my $stats = parse_pressure("/sys/fs/cgroup/${cgroup_path}/${type}.pressure");
        $res->{$type} = $stats if $stats;
    }
    return $res;
}

If we want to abstract away the base cgroup that would be a job for a
pve-guest-common interface and respective implementation in pve-container
and qemu-server, but it's probably fine to just assemble the path where
needed (manager I'd figure?), in any case not worse than hard-coding it in
a dependency leave node like here.

> +	$res->{$type} = $stats if $stats;
> +    }
> +    return $res;
> +}
> +
> +sub read_lxc_pressure {
> +    my ($vmid) = @_;
> +
> +    my $res = {};
> +    foreach my $type (qw(cpu memory io)) {
> +	my $stats = parse_pressure("/sys/fs/cgroup/lxc/$vmid/$type.pressure");
> +	$res->{$type} = $stats if $stats;
> +    }
> +    return $res;
> +}
> +
>  sub read_pressure {
>      my $res = {};
>      foreach my $type (qw(cpu memory io)) {





More information about the pve-devel mailing list