Re: [PATCH V5 6/6] proc: show MADV_FREE pages info in smaps
From: Michal Hocko
Date: Tue Mar 07 2017 - 07:20:19 EST
On Fri 03-03-17 16:10:27, Andrew Morton wrote:
> On Thu, 2 Mar 2017 17:30:54 +0100 Michal Hocko <mhocko@xxxxxxxxxx> wrote:
>
> > > It's not that I think you're wrong: it *is* an implementation detail.
> > > But we take a bit of incoherency from batching all over the place, so
> > > it's a little odd to take a stand over this particular instance of it
> > > - whether demanding that it'd be fixed, or be documented, which would
> > > only suggest to users that this is special when it really isn't etc.
> >
> > I am not aware of other counter printed in smaps that would suffer from
> > the same problem, but I haven't checked too deeply so I might be wrong.
> >
> > Anyway it seems that I am alone in my position so I will not insist.
> > If we have any bug report then we can still fix it.
>
> A single lru_add_drain_all() right at the top level (in smaps_show()?)
> won't kill us
I do not think we want to put lru_add_drain_all cost to a random
process reading /proc/<pid>/smaps. If anything the one which does the
madvise should be doing this.
> and should significantly improve this issue. And it
> might accidentally make some of the other smaps statistics more
> accurate as well.
>
> If not, can we please have a nice comment somewhere appropriate which
> explains why LazyFree is inaccurate and why we chose to leave it that
> way?
Yeah, I would appreciate the comment more. What about the following
---
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 45853e116eef..0b58b317dc76 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -444,7 +444,9 @@ a mapping associated with a file may contain anonymous pages: when MAP_PRIVATE
and a page is modified, the file page is replaced by a private anonymous copy.
"LazyFree" shows the amount of memory which is marked by madvise(MADV_FREE).
The memory isn't freed immediately with madvise(). It's freed in memory
-pressure if the memory is clean.
+pressure if the memory is clean. Please note that the printed value might
+be lower than the real value due to optimizations used in the current
+implementation. If this is not desirable please file a bug report.
"AnonHugePages" shows the ammount of memory backed by transparent hugepage.
"ShmemPmdMapped" shows the ammount of shared (shmem/tmpfs) memory backed by
huge pages.
--
Michal Hocko
SUSE Labs