Add the pagefault count into memcg stats
Subsystems (6)
PATCH v2 1/1 Add the pagefault count into memcg stats
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.468851No difference proven at 95.0% confidence
--- 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(-)
Documentation/cgroups/memory.txt +4 -0
@@ -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"
fs/ncpfs/mmap.c +2 -0
@@ -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 ; }
include/linux/memcontrol.h +18 -0
@@ -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); +void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);#ifdef CONFIG_TRANSPARENT_HUGEPAGE void mem_cgroup_split_huge_fixup (struct page *head,struct page *tail);#endif
@@ -354,6 +358,20 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head, { } +static inline void mem_cgroup_pgfault (struct mem_cgroup *memcg, +int val) +{ +} + +static inline void mem_cgroup_pgmajfault (struct mem_cgroup *memcg, +int val) +{ +} + +static inline +void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx) +{ +}#endif /* CONFIG_CGROUP_MEM_CONT */ #if !defined(CONFIG_CGROUP_MEM_RES_CTLR ) || !defined(CONFIG_DEBUG_VM )
mm/filemap.c +1 -0
@@ -1683,6 +1683,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)/* No page in the page cache at all */ do_sync_mmap_readahead (vma, ra, file, offset);count_vm_event (PGMAJFAULT ); +mem_cgroup_count_vm_event (vma->vm_mm,PGMAJFAULT ); ret =VM_FAULT_MAJOR ; retry_find: page =find_get_page (mapping, offset);
mm/memcontrol.c +47 -0
83 lines not on this page · raw message
mm/memory.c +2 -0
@@ -2836,6 +2836,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,/* Had to read the page from swap area: Major fault */ ret =VM_FAULT_MAJOR ;count_vm_event (PGMAJFAULT ); +mem_cgroup_count_vm_event (mm,PGMAJFAULT ); }else if (PageHWPoison (page)) {/* * hwpoisoned dirty swapcache pages are kept for killing
@@ -3375,6 +3376,7 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,__set_current_state (TASK_RUNNING );count_vm_event (PGFAULT ); +mem_cgroup_count_vm_event (mm,PGFAULT );/* do counter updates before entering really critical section. */ check_sync_rss_stat (current);
mm/shmem.c +2 -0
@@ -1289,6 +1289,8 @@ repeat:/* here we actually do the io */ if (type && !(*type &VM_FAULT_MAJOR )) {__count_vm_event (PGMAJFAULT ); +mem_cgroup_count_vm_event (current->mm, +PGMAJFAULT ); *type |=VM_FAULT_MAJOR ; }spin_unlock (&info->lock);
Signature · 8 lines
1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. 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=mailto:"[email protected]"> [email protected] </a>
Quoted 42 lines · On Sun, 27 Mar 2011 20:26:00 -0700 Ying Han <[email protected]> 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 0Performance 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
Quoted 7 lines
+-------------------------------------------------------------------------+ 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.468851No difference proven at 95.0% confidence
Signed-off-by Ying Han <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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=mailto:"[email protected]"> [email protected] </a>
Quoted 114 lines · Ying Han
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 0Performance 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% confidenceSigned-off-by Ying Han <[email protected]>---
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(-)Documentation/cgroups/memory.txt +0
-0@@ -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
Documentation/cgroups/memory.txt +2
-0+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 activeDocumentation/cgroups/memory.txt +0
-0@@ -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"Documentation/cgroups/memory.txt +2
-0+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"fs/ncpfs/mmap.c +2
-0@@ -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; }include/linux/memcontrol.h +1
-0@@ -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 {
include/linux/memcontrol.h unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, · line 152
Quoted 5 lines
include/linux/memcontrol.h +2
-0@@ -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?
Quoted 1 line
include/linux/memcontrol.h +1
-0+void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. 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=mailto:"[email protected]"> [email protected] </a>
Quoted 118 lines · Minchan Kim
Quoted 117 lines · Ying Han
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 0Performance 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% confidenceSigned-off-by Ying Han <[email protected]>---
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(-)Documentation/cgroups/memory.txt +0
-0@@ -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
Documentation/cgroups/memory.txt +2
-0+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 activeDocumentation/cgroups/memory.txt +0
-0@@ -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"Documentation/cgroups/memory.txt +2
-0+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"fs/ncpfs/mmap.c +2
-0@@ -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; }include/linux/memcontrol.h +1
-0@@ -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);
Quoted 5 lines
include/linux/memcontrol.h unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, · line 152
Quoted 2 lines
include/linux/memcontrol.h +2
-0+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?
probably not. will send another patch.
thanks
--Ying
Quoted 8 lines
include/linux/memcontrol.h unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, · line 153
Quoted 2 lines
include/linux/memcontrol.h +1
-0+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 [email protected]. 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=mailto:"[email protected]"> [email protected] </a>