]> git.proxmox.com Git - pve-manager.git/commitdiff
api: ceph: improve reporting of ceph OSD memory usage
authorStefan Hanreich <s.hanreich@proxmox.com>
Mon, 4 Sep 2023 09:18:07 +0000 (11:18 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Sep 2023 11:53:35 +0000 (13:53 +0200)
Currently we are using the MemoryCurrent property of the OSD service
to determine the used memory of a Ceph OSD. This includes, among other
things, the memory used by buffers [1]. Since BlueFS uses buffered
I/O, this can lead to extremely high values shown in the UI.

Instead we are now reading the PSS value from the proc filesystem,
which should more accurately reflect the amount of memory currently
used by the Ceph OSD.

Aaron and I decided on PSS over RSS, since this should give a better
idea of used memory - particularly when using a large amount of OSDs
on one host, since the OSDs share some of the pages.

[1] https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Aaron Lauterer <a.lauterer@proxmox.com>
PVE/API2/Ceph/OSD.pm
www/manager6/ceph/OSDDetails.js

index ded3599047bf65f1e9a8f916d57b6b46ba137029..38980297158b4f4cfd3699284838367f09a615b4 100644 (file)
@@ -687,13 +687,10 @@ __PACKAGE__->register_method ({
 
        my $raw = '';
        my $pid;
-       my $memory;
        my $parser = sub {
            my $line = shift;
            if ($line =~ m/^MainPID=([0-9]*)$/) {
                $pid = $1;
-           } elsif ($line =~ m/^MemoryCurrent=([0-9]*|\[not set\])$/) {
-               $memory = $1 eq "[not set]" ? 0 : $1;
            }
        };
 
@@ -702,12 +699,26 @@ __PACKAGE__->register_method ({
            'show',
            "ceph-osd\@${osdid}.service",
            '--property',
-           'MainPID,MemoryCurrent',
+           'MainPID',
        ];
        run_command($cmd, errmsg => 'fetching OSD PID and memory usage failed', outfunc => $parser);
 
        $pid = defined($pid) ? int($pid) : undef;
-       $memory = defined($memory) ? int($memory) : undef;
+
+       my $memory = 0;
+       if ($pid && $pid > 0) {
+           open (my $SMAPS, '<', "/proc/$pid/smaps_rollup")
+               or die "failed to read PSS memory-stat from process - $!\n";
+
+           while (my $line = <$SMAPS>) {
+               if ($line =~ m/^Pss:\s+([0-9]+) kB$/) {
+                   $memory = $1 * 1024;
+                   last;
+               }
+           }
+
+           close $SMAPS;
+       }
 
        my $data = {
            osd => {
index f0765d4fee923c79cff0f579020b5712b11a4e24..3b1c1d9c08f078cc54cab2c7058e562179607b7b 100644 (file)
@@ -148,7 +148,7 @@ Ext.define('PVE.CephOsdDetails', {
                                {
                                    xtype: 'text',
                                    name: 'mem_usage',
-                                   text: gettext('Memory usage'),
+                                   text: gettext('Memory usage (PSS)'),
                                    renderer: Proxmox.Utils.render_size,
                                },
                                {