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

Aaron Lauterer a.lauterer at proxmox.com
Wed Jul 9 13:22:57 CEST 2025


From: Folke Gleumes <f.gleumes at proxmox.com>

Originally-by: Folke Gleumes <f.gleumes at proxmox.com>
[AL:
    rebased on current master
    merged into single function for generic cgroups
]
Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---

Notes:
    while the read_cgroup_pressure function would fit better into
    SysFSTools.pm I have kept it in ProcFSTools.pm for now, mainly because
    we currently don't use ProcFSTools in SysFSTools, and the actual
    function to parse the contents of the pressure files in in ProcFSTools.
    
    If that would not be an issue, we could also move the
    read_cgroup_pressure function to SysFSTools
    
    changes since
    RFC:
    * instead of dedicated functions for CTs and VMs we use a more generic
      for cgroups in general

 src/PVE/ProcFSTools.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
index f342890..f28372b 100644
--- a/src/PVE/ProcFSTools.pm
+++ b/src/PVE/ProcFSTools.pm
@@ -151,6 +151,17 @@ sub parse_pressure {
     return $res;
 }
 
+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;
+}
+
 sub read_pressure {
     my $res = {};
     foreach my $type (qw(cpu memory io)) {
-- 
2.39.5





More information about the pve-devel mailing list