Re: free: regression due to a different calculation of Used memory
Jan Rybar <[email protected]> Thu, 26 May 2022 13:50:32 +0200
| Newsgroups | gmane.linux.procps.devel |
|---|---|
| Message-ID | <CA+MoEF7+JPvbWPSM1kkBtW2Wux74ZFCHOT2D1EqN=Coox6HzmQ@mail.gmail.com> |
Hello everyone, After some inspection, I have to stand behind Michal's opinion. After discussion with our kernelist, Jerome Marchand, who stated that Shmem is a subset of Cached (and not all cache pages are easily reclaimable) - this can be tested by writing into huge file in tmpfs -, I learned that the current calculation of Used does not seem to be valid. I believe there were many reasons why this calculation changed to its current form and I realize there is rather philosophical question what 'used' memory should be considered as (whether just allocated or non-reclaimable), however, in the light of recent information, I suggest to at least add a "--pure" (or so) switch to options which enables calculation `used = total - free`, as all allocated memory is "somehow used", whether reclaimable or not. If you agree, I can send a MR with the patch (in order not to bloat gitlab with MRs under discussion), anyway I'm certainly looking forward to reading your opinion. I think it's worth mentioning that since newlib's aim is to have ABI stable library (IIRC), switching the calculation within free.c binary should be considered, should the change be accepted. But I believe if the calculation is really wrong, it ought to be corrected globally in the library. Thanks. Jan Rybar On Tue, Jun 1, 2021 at 9:46 AM Michal Hocko <[email protected]> wrote: > On Thu 29-04-21 14:30:36, Michal Hocko wrote: > > On Thu 29-04-21 22:08:31, Craig Small wrote: > [...] > > > 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). > > Should I send a patch to clarify this? > > > > 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? > > Would be a patch to change the behavior to use Total-Available at least > considered? > -- > Michal Hocko > SUSE Labs > >