[pve-devel] [PATCH container 09/20] cgroup: add get_memory_stat

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Apr 6 09:55:53 CEST 2020


On Sat, Apr 04, 2020 at 08:13:10PM +0200, Thomas Lamprecht wrote:
> On 4/3/20 4:37 PM, w.bumiller at proxmox.com wrote:
> > ...
> > +# Parse some memory data from `memory.stat`
> > +sub get_memory_stat {
> > +    my ($self) = @_;
> > +
> > +    my $res = {
> > +	mem => 0,
> > +	swap => 0,
> > +    };
> > +
> > +    if (cgroup_mode() == 2) {
> > +	if (defined(my $path = $self->get_path('memory'))) {
> > +	    my $mem = file_get_contents("$path/memory.current");
> > +	    my $swap = file_get_contents("$path/memory.swap.current");
> > +
> > +	    chomp ($mem, $swap);
> > +
> > +	    # FIXME: For the cgv1 equivalent of `total_cache` we may need to sum up
> > +	    # the values in `memory.stat`...
> 
> I guess you plan to fix this, as "wrong" memory stats seem to startle our
> users quite a bit ^^

I do, just need some more cgroupv2 systems, 'cause right now I just
switch around on my host, so the cgv2 part isn't all that well-tested
yet either. Was more focused on getting the general structure out of the
way trying to not break cgv1 in the process :-)




More information about the pve-devel mailing list