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

"Michal Hocko" <[email protected]> (Redacted sender "mhocko" for DMARC) Thu, 29 Apr 2021 14:30:36 +0200
Newsgroups gmane.linux.procps.devel
Message-ID <[email protected]>
On Thu 29-04-21 22:08:31, Craig Small wrote:
> On Tue, 6 Apr 2021 at 16:57, Michal Hocko <[email protected]>
> wrote:
> 
> > Slab part was merely something I've spotted in the referenced commit and
> > not something that is causing the main problem. That is indeed ths
> > swap backed page cache. More on that below.
> >
> > If there is no clear semantic behind the value then it likely shouldn't
> > try to be clever. I do understand that many people are confused by their
> > system consuming a lot of memory for caching. This is not something new
> > and I am afraid that hiding that fact from them is just going to
> > continue confusion elsewhere. As you can see by this bug report.
> >
> It's (what is used memory) been a problem since  I started using Linux and
> that version started with 0, I can remember back then "Linux uses much more
> memory".
> Doesn't help here, but as you say its a long-standing problem.
> 
> > Cache includes tmpfs which is file backed not memory
> >
> > No, this is not quite right. tmpfs/shmem is a general concept for
> > shared memory with swap as a backing storage. That can be MAP_SHARED |
> > MAP_ANON
> > mapping, tmpfs mounted filesystem, memfd, System V shm  and many others.
> >
> 
> proc(5) says Cached (as in the line /proc/meminfo ) is only based on disk,
> or in its words
>   "In-memory cache for files read from the disk (the page cache).  Doesn't
> include SwapCached."
> 
> Is the man page incorrect?

yes and no. It is correct in the sense that swapcache is explicitly
excluded but it is not fully correct claiming it is disk backed file
cache. Because it includes shmem which is a filesystem which is not
backed by disk (except for the swapout).

A proper wording would be: In-memory cache for filesystem content (both
disk based as memory based like shmem). Doesn't include Swap cache and
buffer cache which are presented separately (SwapCached resp. Buffers).

> I think that's the main difference now.  Ideally this could be settled by
> the kernel exposing MemUsed in /proc/meminfo and everyone can use that
> (it's how available was solved).

Why Total-Available doesn't serve that purpose already?
-- 
Michal Hocko
SUSE Labs