Review Request 128267: Include the Slab value in the Cached value

Rob Wu rob at robwu.nl
Mon Jun 20 22:54:24 UTC 2016


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128267/
-----------------------------------------------------------

Review request for Plasma.


Repository: ksysguard


Description
-------

Before this patch, Cached only counted the page cache.
With this patch, the slab is also included. This change is visible
through the APi in "mem/physical/application" and "mem/physical/cached".


Why? For the calculation of used memory (`Appl`), the Slab should not
be counted as used memory as it is a cache for kernel data structures.

free (from procps) calculates "Used" memory as follows:
MemTotal - MemFree - (Cached + Slab) - Buffers
(you can verify this using the numbers from `cat /proc/meminfo`).

This discrepancy in used memory was already noted before, at
https://mail.kde.org/pipermail/plasma-devel/2008-December/002984.html

> This "Slab" value [1] is not available from the systemmonitor. It usually 
> doesn't grow over 20MB at all anyway. I don't know how important this value 
> is, so is it a feasable solution to simply ignore this and only show used, 
> cache and buffer?

After 10 days of usage, my slab looks like this:

```
$ cat /proc/meminfo | grep Slab
Slab:            2763208 kB
```

Clearly, the slab is non-negligible and should be deducted.

The immediate reason for writing this patch is that the "Memory Status"
plasmoid displayed 4G of "memory usage" even after closing all programs.
This was confusing, especially when `free -m` showed a much lower value.


Diffs
-----

  ksysguardd/Linux/Memory.c 6b2fcab 

Diff: https://git.reviewboard.kde.org/r/128267/diff/


Testing
-------

(on ArchLinux)

Add the "Memory Status" plasmoid to the desktop if is not already there.
Note that the displayed value for "Physical memory" does not match the "Used" value as reported by `free -m`.

Build and install ksysguard after applying the patch:

```
cd build/
cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DKDE_INSTALL_LIBDIR=lib -DBUILD_TESTING=OFF
make
sudo make install
```

Then restart plasmashell


```
kquitapp5 plasmashell && kstart plasmashell
```

Look at the "Memory Status" widget on the desktop and observe that it displays a sensible value (similar to the "Used" value of `free -m`).


Thanks,

Rob Wu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160620/12c9ca07/attachment.html>


More information about the Plasma-devel mailing list