On Mon, Mar 28, 2011 at 12:26 PM, Ying Han <yinghan@xxxxxxxxxx> wrote: > Two new stats in per-memcg memory.stat which tracks the number of > page faults and number of major page faults. > > "pgfault" > "pgmajfault" > > They are different from "pgpgin"/"pgpgout" stat which count number of > pages charged/discharged to the cgroup and have no meaning of reading/ > writing page to disk. > > It is valuable to track the two stats for both measuring application's > performance as well as the efficiency of the kernel page reclaim path. > Counting pagefaults per process is useful, but we also need the aggregated > value since processes are monitored and controlled in cgroup basis in memcg. > > Functional test: check the total number of pgfault/pgmajfault of all > memcgs and compare with global vmstat value: > > $ cat /proc/vmstat | grep fault > pgfault 1070751 > pgmajfault 553 > > $ cat /dev/cgroup/memory.stat | grep fault > pgfault 1071138 > pgmajfault 553 > total_pgfault 1071142 > total_pgmajfault 553 > > $ cat /dev/cgroup/A/memory.stat | grep fault > pgfault 199 > pgmajfault 0 > total_pgfault 199 > total_pgmajfault 0 > > Performance test: run page fault test(pft) wit 16 thread on faulting in 15G > anon pages in 16G container. There is no regression noticed on the "flt/cpu/s" > > Sample output from pft: > TAG pft:anon-sys-default: > ÂGb ÂThr CLine  User   System   Wall  Âflt/cpu/s fault/wsec > Â15  16  1   0.69s  230.99s  Â14.62s  16972.539 268876.196 > > +-------------------------------------------------------------------------+ >  ÂN      Min      Max    ÂMedian      Avg    ÂStddev > x Â10   16682.962   17344.027   16913.524   16928.812   Â166.5362 > + Â10   Â16718.92   17023.453   16907.164   16902.399   88.468851 > No difference proven at 95.0% confidence > > Signed-off-by: Ying Han <yinghan@xxxxxxxxxx> > --- > ÂDocumentation/cgroups/memory.txt |  Â4 +++ > Âfs/ncpfs/mmap.c         Â|  Â2 + > Âinclude/linux/memcontrol.h    |  18 ++++++++++++++ > Âmm/filemap.c           |  Â1 + > Âmm/memcontrol.c         Â|  47 ++++++++++++++++++++++++++++++++++++++ > Âmm/memory.c           Â|  Â2 + > Âmm/shmem.c            |  Â2 + > Â7 files changed, 76 insertions(+), 0 deletions(-) > > diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt > index b6ed61c..2db6103 100644 > --- a/Documentation/cgroups/memory.txt > +++ b/Documentation/cgroups/memory.txt > @@ -385,6 +385,8 @@ mapped_file - # of bytes of mapped file (includes tmpfs/shmem) > Âpgpgin     - # of pages paged in (equivalent to # of charging events). > Âpgpgout        Â- # of pages paged out (equivalent to # of uncharging events). > Âswap      - # of bytes of swap usage > +pgfault        Â- # of page faults. > +pgmajfault   - # of major page faults. > Âinactive_anon Â- # of bytes of anonymous memory and swap cache memory on >        ÂLRU list. > Âactive_anon  Â- # of bytes of anonymous and swap cache memory on active > @@ -406,6 +408,8 @@ total_mapped_file  - sum of all children's "cache" > Âtotal_pgpgin      - sum of all children's "pgpgin" > Âtotal_pgpgout     Â- sum of all children's "pgpgout" > Âtotal_swap       - sum of all children's "swap" > +total_pgfault     Â- sum of all children's "pgfault" > +total_pgmajfault    - sum of all children's "pgmajfault" > Âtotal_inactive_anon  Â- sum of all children's "inactive_anon" > Âtotal_active_anon   Â- sum of all children's "active_anon" > Âtotal_inactive_file  Â- sum of all children's "inactive_file" > diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c > index a7c07b4..e5d71b2 100644 > --- a/fs/ncpfs/mmap.c > +++ b/fs/ncpfs/mmap.c > @@ -16,6 +16,7 @@ > Â#include <linux/mman.h> > Â#include <linux/string.h> > Â#include <linux/fcntl.h> > +#include <linux/memcontrol.h> > > Â#include <asm/uaccess.h> > Â#include <asm/system.h> > @@ -92,6 +93,7 @@ static int ncp_file_mmap_fault(struct vm_area_struct *area, >     * -- wli >     */ >    Âcount_vm_event(PGMAJFAULT); > +    mem_cgroup_count_vm_event(area->vm_mm, PGMAJFAULT); >    Âreturn VM_FAULT_MAJOR; > Â} > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 5a5ce70..45e5268 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -24,6 +24,7 @@ struct mem_cgroup; > Âstruct page_cgroup; > Âstruct page; > Âstruct mm_struct; > +enum vm_event_item; > > Â/* Stats that can be updated by kernel. */ > Âenum mem_cgroup_page_stat_item { > @@ -147,6 +148,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, >                        Âgfp_t gfp_mask); > Âu64 mem_cgroup_get_limit(struct mem_cgroup *mem); > > +void mem_cgroup_pgfault(struct mem_cgroup *memcg, int val); > +void mem_cgroup_pgmajfault(struct mem_cgroup *memcg, int val); Do we have to expose above two functions? Isn't it enough to only mem_cgroup_count_vm_event? > +void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx); -- Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxxx For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href