Re: [PATCH 3/7] memcg: add memory.scan_stat

From: KAMEZAWA Hiroyuki
Date: Sun Jun 19 2011 - 19:48:39 EST


On Fri, 17 Jun 2011 15:04:18 -0700
Ying Han <yinghan@xxxxxxxxxx> wrote:

> On Wed, Jun 15, 2011 at 8:53 PM, KAMEZAWA Hiroyuki
> <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> > From e08990dd9ada13cf236bec1ef44b207436434b8e Mon Sep 17 00:00:00 2001
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> > Date: Wed, 15 Jun 2011 14:11:01 +0900
> > Subject: [PATCH 3/7] memcg: add memory.scan_stat
> >
> > commit log of commit 0ae5e89 " memcg: count the soft_limit reclaim in..."
> > says it adds scanning stats to memory.stat file. But it doesn't because
> > we considered we needed to make a concensus for such new APIs.
> >
> > This patch is a trial to add memory.scan_stat. This shows
> > Â- the number of scanned pages
> > Â- the number of recleimed pages
> > Â- the number of elaplsed time (including sleep/pause time)
> > Âfor both of direct/soft reclaim and shrinking caused by changing limit
> > Âor force_empty.
> >
> > The biggest difference with oringinal Ying's one is that this file
> > can be reset by some write, as
> >
> > Â# echo 0 ...../memory.scan_stat
> >
> > [kamezawa@bluextal ~]$ cat /cgroup/memory/A/memory.scan_stat
> > scanned_pages_by_limit 358470
> > freed_pages_by_limit 180795
> > elapsed_ns_by_limit 21629927
> > scanned_pages_by_system 0
> > freed_pages_by_system 0
> > elapsed_ns_by_system 0
> > scanned_pages_by_shrink 76646
> > freed_pages_by_shrink 38355
> > elappsed_ns_by_shrink 31990670
> > total_scanned_pages_by_limit 358470
> > total_freed_pages_by_limit 180795
> > total_elapsed_ns_by_hierarchical 216299275
> > total_scanned_pages_by_system 0
> > total_freed_pages_by_system 0
> > total_elapsed_ns_by_system 0
> > total_scanned_pages_by_shrink 76646
> > total_freed_pages_by_shrink 38355
> > total_elapsed_ns_by_shrink 31990670
> >
> > total_xxxx is for hierarchy management.
> >
> > This will be useful for further memcg developments and need to be
> > developped before we do some complicated rework on LRU/softlimit
> > management.
>
> Agreed. Actually we are also looking into adding a per-memcg API for
> adding visibility of
> page reclaim path. It would be helpful for us to settle w/ the API first.
>
> I am not a fan of names, but how about
> "/dev/cgroup/memory/memory.reclaim_stat" ?
>

Hm, ok, I have no favorite.


> >
> > Now, scan/free/elapsed_by_system is incomplete but future works of
> > Johannes at el. will fill remaining information and then, we can
> > look into problems of isolation between memcgs.
> >
> > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> > ---
> > ÂDocumentation/cgroups/memory.txt | Â 33 +++++++++
> > Âinclude/linux/memcontrol.h    |  16 ++++
> > Âinclude/linux/swap.h       |  Â6 -
> > Âmm/memcontrol.c         Â| Â135 +++++++++++++++++++++++++++++++++++++--
> > Âmm/vmscan.c           Â|  27 ++++++-
> > Â5 files changed, 199 insertions(+), 18 deletions(-)
> >
> > Index: mmotm-0615/Documentation/cgroups/memory.txt
> > ===================================================================
> > --- mmotm-0615.orig/Documentation/cgroups/memory.txt
> > +++ mmotm-0615/Documentation/cgroups/memory.txt
> > @@ -380,7 +380,7 @@ will be charged as a new owner of it.
> >
> > Â5.2 stat file
> >
> > -memory.stat file includes following statistics
> > +5.2.1 memory.stat file includes following statistics
> >
> > Â# per-memory cgroup local status
> > Âcache     Â- # of bytes of page cache memory.
> > @@ -438,6 +438,37 @@ Note:
> > Â Â Â Â file_mapped is accounted only when the memory cgroup is owner of page
> > Â Â Â Â cache.)
> >
> > +5.2.2 memory.scan_stat
> > +
> > +memory.scan_stat includes statistics information for memory scanning and
> > +freeing, reclaiming. The statistics shows memory scanning information since
> > +memory cgroup creation and can be reset to 0 by writing 0 as
> > +
> > + #echo 0 > ../memory.scan_stat
> > +
> > +This file contains following statistics.
> > +
> > +scanned_pages_by_limit - # of scanned pages at hitting limit.
> > +freed_pages_by_limit  - # of freed pages at hitting limit.
>
> How those stats different from Johannes's patch? I feel we should keep
> them into this API instead of memory.stat
> "pgscan_direct_limit"
> "pgreclaim_direct_limit"
>

It's unclear the unit of number from that name.
And, I can't find what it means "direct_limit". Only "limit" is meaningful.



> > +elapsed_ns_by_limit  Â- nano sec of elappsed time at LRU scan at
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âhitting limit.(this includes sleep time.)
>
>
> > +
> > +scanned_pages_by_system    Â- # of scanned pages by the kernel.
> > + Â Â Â Â Â Â Â Â Â Â Â Â (Now, this value means global memory reclaim
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â caused by system memory shortage with a hint
> > + Â Â Â Â Â Â Â Â Â Â Â Â Âof softlimit. "No soft limit" case will be
> > + Â Â Â Â Â Â Â Â Â Â Â Â Âsupported in future.)
> > +freed_pages_by_system Â- # of freed pages by the kernel.
>
> The same for the following which I assume the same meaning with:
> "pgscan_direct_hierarchy"
> "pgreclaim_direct_hierarchy"
>

Doesn't make sense. What hierarchy means, here?

Above 2 is for showing "amount of scanned/reclaimed memory by system's memory
pressure".
(But now, it just shows "softlimit" information until Johannes' work comes.)

For hierarchy information, I have "total_xxxx_by_xxxx" parameter.

> > +elapsed_ns_by_system  - nano sec of elappsed time by kernel.
> > +
> > +scanned_pages_by_shrink    Â- # of scanned pages by shrinking.
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (i.e. changes of limit, force_empty, etc.)
> > +freed_pages_by_shrink Â- # of freed pages by shirkining.
>
> So those stats are not included in the ones above?
>

Yes.

Thanks,
-Kame



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/