Re: free: regression due to a different calculation of Used memory

Craig Small <[email protected]> Sat, 28 May 2022 07:00:54 +1000
Newsgroups gmane.linux.procps.devel
Message-ID <CALy8Cw5Zvk8W8ixzqYNhG6KWiSfkKGs2sfNmqMF1BMGx0x+eTw@mail.gmail.com>
Hi Jan,
 Are you looking at the newlib branch or the master one? For clarity, I'm
talking about newlib. I'm also not really sure what you're suggesting needs
changing.

libproc exposes both MEM_CACHED and MEM_CACHED_ALL with the former being
only what the Cached: line has while the second adds SReclaimable:
free and top use the second value for their cached figures.

We currently have the situation where we have:

Used = Total - Free - Cached - SReclaimable - Buffers

This is the same calculation currently used by the old library.
I suggest you also read:
https://www.freelists.org/post/procps/OmegaPhilxxxxxxxxxxxxx-Bug799716-free-considers-cached-to-include-SUnreclaim
https://github.com/brndnmtthws/conky/issues/130

Jaromir back in 2014  made a change where Cached got Slabs added to it
(commit 6cb75efef85f735b72e6c96f197f358f511f8ed9), that got fixed in 2015
by me to only include SReclaimable (commit
05d751c4f076a2f0118b914c5e51cfbb4762ad8e).
The Jaromir change is the one Michal is talking about.
The email thread is found at
https://www.freelists.org/post/procps/kb-main-available-etc,14

To me saying X gives me a value of A but Y gives me a value of B is saying
one should change but not one.
If you are after a definition, free(1) has one for you. You first need to
say why these need to change first before we change the code. You need to
say why things were wrong in 2014 or perhaps things have changed since
then. Were you talking with the RedHat kernel team like Jaromir? Can they
explain why they think the change is needed as the 2014 change was partly
informed from that group before.

 - Craig