} elsif ($ver == 2) {
my $mem = file_get_contents("$path/memory.current");
my $swap = file_get_contents("$path/memory.swap.current");
+ my $stat = parse_flat_keyed_file(file_get_contents("$path/memory.stat"));
chomp ($mem, $swap);
- # FIXME: For the cgv1 equivalent of `total_cache` we may need to sum up
- # the values in `memory.stat`...
-
- $res->{mem} = $mem;
+ $res->{mem} = $mem - $stat->{file};
$res->{swap} = $swap;
} elsif ($ver == 1) {
# cgroupv1 environment:
},
};
- my ($path, $ver) = $self->get_path(undef, 1);
+ my ($path, $version) = $self->get_path(undef, 1);
if (!defined($path)) {
- # container or VM most likely isn't running
- return undef;
- } elsif ($ver == 2) {
+ return $res; # container or VM most likely isn't running, retrun zero stats
+ } elsif ($version == 1) {
+ return undef; # v1 controller does not provides pressure stat
+ } elsif ($version == 2) {
for my $type (qw(cpu memory io)) {
my $stats = PVE::ProcFSTools::parse_pressure("$path/$type.pressure");
$res->{$type} = $stats if $stats;
}
} else {
- die "bad cgroup version: $ver\n";
+ die "bad cgroup version: $version\n";
}
return $res;
PVE::ProcFSTools::write_proc_entry("$path/cpu.max", 'max');
}
} elsif ($ver == 1) {
- $quota //= -1; # unlimited
- $period //= -1;
+ $quota //= -1; # default (unlimited)
+ $period //= 100_000; # default (100 ms)
PVE::ProcFSTools::write_proc_entry("$path/cpu.cfs_period_us", $period);
PVE::ProcFSTools::write_proc_entry("$path/cpu.cfs_quota_us", $quota);
} else {