Add the pagefault count into memcg stats.
Subsystems (6)
PATCH 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"
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.
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 1069962 pgmajfault 553 total_pgfault 1069966 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.67s 232.11s 14.68s 16892.130 267796.518
$ ./ministat mmotm.txt mmotm_fault.txt
x mmotm.txt (w/o patch)
+ mmotm_fault.txt (w/ patch)
+-------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 10 16682.962 17344.027 16913.524 16928.812 166.5362
+ 10 16696.49 17480.09 16949.143 16951.448 223.56288
No difference proven at 95.0% confidence--- Documentation/cgroups/memory.txt | 4 +++ fs/ncpfs/mmap.c | 2 + include/linux/memcontrol.h | 22 +++++++++++++++ mm/filemap.c | 1 + mm/memcontrol.c | 54 ++++++++++++++++++++++++++++++++++++++ mm/memory.c | 2 + mm/shmem.c | 1 + 7 files changed, 86 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_pgmajfault_from_mm (area->vm_mm);return VM_FAULT_MAJOR ; }
include/linux/memcontrol.h +22 -0
@@ -147,6 +147,11 @@ 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_pgfault_from_mm (struct mm_struct *mm); +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE void mem_cgroup_split_huge_fixup (struct page *head,struct page *tail);#endif
@@ -354,6 +359,23 @@ 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_pgfault_from_mm (struct mm_struct *mm) +{ +} + +static inline void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ +}#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_pgmajfault_from_mm (vma->vm_mm); ret =VM_FAULT_MAJOR ; retry_find: page =find_get_page (mapping, offset);
mm/memcontrol.c +54 -0
90 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_pgmajfault_from_mm (mm); }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_pgfault_from_mm (mm);/* do counter updates before entering really critical section. */ check_sync_rss_stat (current);
mm/shmem.c +1 -0
@@ -1289,6 +1289,7 @@ repeat:/* here we actually do the io */ if (type && !(*type &VM_FAULT_MAJOR )) {__count_vm_event (PGMAJFAULT ); +mem_cgroup_pgmajfault_from_mm (current->mm); *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 45 lines · On Sat, 26 Mar 2011 17:14:44 -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"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.
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 1069962 pgmajfault 553 total_pgfault 1069966 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.67s 232.11s 14.68s 16892.130 267796.518$ ./ministat mmotm.txt mmotm_fault.txt x mmotm.txt (w/o patch) + mmotm_fault.txt (w/ patch) +-------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 10 16682.962 17344.027 16913.524 16928.812 166.5362 + 10 16696.49 17480.09 16949.143 16951.448 223.56288 No difference proven at 95.0% confidence
Quoted 1 line
Signed-off-by Ying Han <[email protected]>
Hmm, maybe useful ? (It's good to describe what is difference with PGPGIN) Especially, you should show why this is useful than per process pgfault count. What I thought of this, I thought that I need per-process information, finally... and didn't add this.
Anyway, I have a request for the style of the function. (see below)
Quoted 45 lines
--- Documentation/cgroups/memory.txt | 4 +++ fs/ncpfs/mmap.c | 2 + include/linux/memcontrol.h | 22 +++++++++++++++ mm/filemap.c | 1 + mm/memcontrol.c | 54 ++++++++++++++++++++++++++++++++++++++ mm/memory.c | 2 + mm/shmem.c | 1 + 7 files changed, 86 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 +1
-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>
fs/ncpfs/mmap.c static int ncp_file_mmap_fault(struct vm_area_struct *area, · line 96
Quoted 4 lines
fs/ncpfs/mmap.c +1
-0@@ -92,6 +93,7 @@ static int ncp_file_mmap_fault(struct vm_area_struct *area,* -- wli */ count_vm_event (PGMAJFAULT ); +mem_cgroup_pgmajfault_from_mm (area->vm_mm);
Could you do this as mem_cgroup_count_vm_event(area->vm_mm, PGMAJFAULT) ?
<snip>
Quoted 24 lines
fs/ncpfs/mmap.c +24
-0+void mem_cgroup_pgfault_from_mm (struct mm_struct *mm) +{ +struct mem_cgroup *mem; + +if (!mm) +return ; + +rcu_read_lock (); + mem =mem_cgroup_from_task (rcu_dereference (mm->owner)); +if (unlikely (!mem)) + goto out; +mem_cgroup_pgfault (mem,1 ); + +out: +rcu_read_unlock (); +} + +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ +struct mem_cgroup *mem; + +if (!mm) +return ; +
fs/ncpfs/mmap.c static int ncp_file_mmap_fault(struct vm_area_struct *area,
Quoted 10 lines
fs/ncpfs/mmap.c +10
-0+rcu_read_lock (); + mem =mem_cgroup_from_task (rcu_dereference (mm->owner)); +if (unlikely (!mem)) + goto out; +mem_cgroup_pgmajfault (mem,1 ); +out: +rcu_read_unlock (); +} +EXPORT_SYMBOL (mem_cgroup_pgmajfault_from_mm); +
Then, you can do above 2 in a function.
Thanks,
-Kame
--
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 48 lines · KAMEZAWA Hiroyuki
Quoted 45 lines · On Sat, 26 Mar 2011 17:14:44 -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"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.
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 1069962 pgmajfault 553 total_pgfault 1069966 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.67s 232.11s 14.68s 16892.130 267796.518$ ./ministat mmotm.txt mmotm_fault.txt x mmotm.txt (w/o patch) + mmotm_fault.txt (w/ patch) +-------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 10 16682.962 17344.027 16913.524 16928.812 166.5362 + 10 16696.49 17480.09 16949.143 16951.448 223.56288 No difference proven at 95.0% confidence
Quoted 8 lines
Quoted 1 line
Signed-off-by Ying Han <[email protected]>Hmm, maybe useful ? (It's good to describe what is difference with PGPGIN) Especially, you should show why this is useful than per process pgfault count. What I thought of this, I thought that I need per-process information, finally... and didn't add this.
Anyway, I have a request for the style of the function. (see below)
Thanks for your comment, and I will post V2 shortly.
Quoted 44 lines
Quoted 44 lines
---
Documentation/cgroups/memory.txt | 4 +++
fs/ncpfs/mmap.c | 2 +include/linux/memcontrol.h| 22 +++++++++++++++mm/filemap.c| 1 +
mm/memcontrol.c | 54 ++++++++++++++++++++++++++++++++++++++mm/memory.c| 2 +
mm/shmem.c | 1 +7 files changed, 86 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 +1
-0@@ -16,6 +16,7 @@ #include <linux/mman.h> #include <linux/string.h> #include <linux/fcntl.h> +#include <linux/memcontrol.h>
Quoted 9 lines
fs/ncpfs/mmap.c static int ncp_file_mmap_fault(struct vm_area_struct *area, · line 96
Quoted 7 lines
fs/ncpfs/mmap.c +1
-0#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_pgmajfault_from_mm(area->vm_mm);Could you do this as mem_cgroup_count_vm_event(area->vm_mm, PGMAJFAULT) ?
will be included in V2.
Quoted 31 lines
<snip>
Quoted 28 lines
fs/ncpfs/mmap.c +28
-0+void mem_cgroup_pgfault_from_mm (struct mm_struct *mm) +{ + struct mem_cgroup *mem; + + if (!mm) + return; + + rcu_read_lock(); + mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); + if (unlikely(!mem)) + goto out; + mem_cgroup_pgfault(mem, 1); + +out: + rcu_read_unlock(); +} + +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ + struct mem_cgroup *mem; + + if (!mm) + return; + + rcu_read_lock(); + mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); + if (unlikely(!mem)) + goto out;
Quoted 8 lines
fs/ncpfs/mmap.c
Quoted 6 lines
+
mem_cgroup_pgmajfault(mem, 1);fs/ncpfs/mmap.c +5
-0+out: + rcu_read_unlock(); +} +EXPORT_SYMBOL (mem_cgroup_pgmajfault_from_mm); +Then, you can do above 2 in a function.
--Ying
Quoted 6 lines
Thanks,
-Kame
--
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 185 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"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.
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 1069962 pgmajfault 553 total_pgfault 1069966 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.67s 232.11s 14.68s 16892.130 267796.518$ ./ministat mmotm.txt mmotm_fault.txt x mmotm.txt (w/o patch) + mmotm_fault.txt (w/ patch) +-------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 10 16682.962 17344.027 16913.524 16928.812 166.5362 + 10 16696.49 17480.09 16949.143 16951.448 223.56288 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 | 22 +++++++++++++++ mm/filemap.c | 1 + mm/memcontrol.c | 54 ++++++++++++++++++++++++++++++++++++++ mm/memory.c | 2 + mm/shmem.c | 1 + 7 files changed, 86 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_pgmajfault_from_mm (area->vm_mm);return VM_FAULT_MAJOR ; }include/linux/memcontrol.h +22
-0@@ -147,6 +147,11 @@ 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_pgfault_from_mm (struct mm_struct *mm); +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE void mem_cgroup_split_huge_fixup (struct page *head,struct page *tail);#endif @@ -354,6 +359,23 @@ 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_pgfault_from_mm (struct mm_struct *mm) +{ +} + +static inline void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ +}#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_pgmajfault_from_mm (vma->vm_mm); ret =VM_FAULT_MAJOR ; retry_find: page =find_get_page (mapping, offset);mm/memcontrol.c +13
-0@@ -94,6 +94,8 @@ enum mem_cgroup_events_index {MEM_CGROUP_EVENTS_PGPGIN ,/* # of pages paged in */ MEM_CGROUP_EVENTS_PGPGOUT ,/* # of pages paged out */ MEM_CGROUP_EVENTS_COUNT ,/* # of pages paged in/out */ +MEM_CGROUP_EVENTS_PGFAULT ,/* # of page-faults */ +MEM_CGROUP_EVENTS_PGMAJFAULT ,/* # of major page-faults */ MEM_CGROUP_EVENTS_NSTATS, };/* @@ -585,6 +587,16 @@ static void mem_cgroup_swap_statistics(struct mem_cgroup *mem,this_cpu_add (mem->stat->count[MEM_CGROUP_STAT_SWAPOUT ], val); } +void mem_cgroup_pgfault (struct mem_cgroup *mem,int val) +{ +this_cpu_add (mem->stat->events[MEM_CGROUP_EVENTS_PGFAULT ], val); +} + +void mem_cgroup_pgmajfault (struct mem_cgroup *mem,int val) +{ +this_cpu_add (mem->stat->events[MEM_CGROUP_EVENTS_PGMAJFAULT ], val); +} +static unsigned long mem_cgroup_read_events (struct mem_cgroup *mem,enum mem_cgroup_events_index idx) {@@ -813,6 +825,40 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *mem)return (mem == root_mem_cgroup); } +void mem_cgroup_pgfault_from_mm (struct mm_struct *mm)
mm/memcontrol.c static inline bool mem_cgroup_is_root(struct mem_cgroup *mem) · line 838
Quoted 10 lines
mm/memcontrol.c +10
-0+{ +struct mem_cgroup *mem; + +if (!mm) +return ; + +rcu_read_lock (); + mem =mem_cgroup_from_task (rcu_dereference (mm->owner)); +if (unlikely (!mem)) + goto out;
A lot of this can be reused, just a minor nitpick. May be you can combine this function and the one below
Quoted 90 lines
mm/memcontrol.c +31
-0+mem_cgroup_pgfault (mem,1 ); + +out: +rcu_read_unlock (); +} + +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ +struct mem_cgroup *mem; + +if (!mm) +return ; + +rcu_read_lock (); + mem =mem_cgroup_from_task (rcu_dereference (mm->owner)); +if (unlikely (!mem)) + goto out; +mem_cgroup_pgmajfault (mem,1 ); +out: +rcu_read_unlock (); +} +EXPORT_SYMBOL (mem_cgroup_pgmajfault_from_mm); +/* * Following LRU functions are allowed to be used without PCG_LOCK. * Operations are called by routine of global LRU independently from memcg. @@ -3772,6 +3818,8 @@ enum {MCS_PGPGIN ,MCS_PGPGOUT ,MCS_SWAP , +MCS_PGFAULT , +MCS_PGMAJFAULT ,MCS_INACTIVE_ANON ,MCS_ACTIVE_ANON , MCS_INACTIVE_FILE,@@ -3794,6 +3842,8 @@ struct { {"pgpgin", "total_pgpgin"}, {"pgpgout", "total_pgpgout"}, {"swap", "total_swap"}, + {"pgfault", "total_pgfault"}, + {"pgmajfault", "total_pgmajfault"}, {"inactive_anon", "total_inactive_anon"}, {"active_anon", "total_active_anon"}, {"inactive_file", "total_inactive_file"},@@ -3822,6 +3872,10 @@ mem_cgroup_get_local_stat(struct mem_cgroup *mem, struct mcs_total_stat *s) val =mem_cgroup_read_stat (mem,MEM_CGROUP_STAT_SWAPOUT ); s->stat[MCS_SWAP ] += val *PAGE_SIZE ; } + val =mem_cgroup_read_events (mem,MEM_CGROUP_EVENTS_PGFAULT ); + s->stat[MCS_PGFAULT ] += val; + val =mem_cgroup_read_events (mem,MEM_CGROUP_EVENTS_PGMAJFAULT ); + s->stat[MCS_PGMAJFAULT ] += val;/* per zone stat */ val =mem_cgroup_get_local_zonestat (mem,LRU_INACTIVE_ANON );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_pgmajfault_from_mm (mm); }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_pgfault_from_mm (mm);/* do counter updates before entering really critical section. */ check_sync_rss_stat (current);mm/shmem.c +1
-0@@ -1289,6 +1289,7 @@ repeat:/* here we actually do the io */ if (type && !(*type &VM_FAULT_MAJOR )) {__count_vm_event (PGMAJFAULT ); +mem_cgroup_pgmajfault_from_mm (current->mm); *type |=VM_FAULT_MAJOR ; }spin_unlock (&info->lock);Signature · 1 line
1.7.3.1
Signature · 9 lines
Three Cheers, Balbir -- 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 186 lines · Balbir Singh
Quoted 184 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"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.
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 1069962 pgmajfault 553 total_pgfault 1069966 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.67s 232.11s 14.68s 16892.130 267796.518$ ./ministat mmotm.txt mmotm_fault.txt x mmotm.txt (w/o patch) + mmotm_fault.txt (w/ patch) +-------------------------------------------------------------------------+ N Min Max Median Avg Stddev x 10 16682.962 17344.027 16913.524 16928.812 166.5362 + 10 16696.49 17480.09 16949.143 16951.448 223.56288 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| 22 +++++++++++++++mm/filemap.c| 1 +
mm/memcontrol.c | 54 ++++++++++++++++++++++++++++++++++++++mm/memory.c| 2 +
mm/shmem.c | 1 +7 files changed, 86 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_pgmajfault_from_mm(area->vm_mm); return VM_FAULT_MAJOR; }include/linux/memcontrol.h +22
-0@@ -147,6 +147,11 @@ 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_pgfault_from_mm (struct mm_struct *mm); +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm); + #ifdef CONFIG_TRANSPARENT_HUGEPAGE void mem_cgroup_split_huge_fixup(struct page *head, struct page *tail); #endif@@ -354,6 +359,23 @@ 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_pgfault_from_mm (struct mm_struct *mm) +{ +} + +static inline void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ +} #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_pgmajfault_from_mm(vma->vm_mm); ret = VM_FAULT_MAJOR;retry_find:
page =find_get_page(mapping, offset);mm/memcontrol.c +0
-0@@ -94,6 +94,8 @@ enum mem_cgroup_events_index {
MEM_CGROUP_EVENTS_PGPGIN, /* # of pages paged in */MEM_CGROUP_EVENTS_PGPGOUT, /* # of pages paged out */MEM_CGROUP_EVENTS_COUNT, /* # of pages paged in/out */
+MEM_CGROUP_EVENTS_PGFAULT, /* # of page-faults */
+MEM_CGROUP_EVENTS_PGMAJFAULT, /* # of major page-faults */MEM_CGROUP_EVENTS_NSTATS,
};
/*mm/memcontrol.c +10
-0@@ -585,6 +587,16 @@ static void mem_cgroup_swap_statistics(struct mem_cgroup *mem, this_cpu_add(mem->stat->count[MEM_CGROUP_STAT_SWAPOUT], val); } +void mem_cgroup_pgfault (struct mem_cgroup *mem,int val) +{ + this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_PGFAULT], val); +} + +void mem_cgroup_pgmajfault (struct mem_cgroup *mem,int val) +{ + this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_PGMAJFAULT], val); +} + static unsigned long mem_cgroup_read_events(struct mem_cgroup *mem, enum mem_cgroup_events_index idx) {@@ -813,6 +825,40 @@ static inline bool mem_cgroup_is_root(struct mem_cgroup *mem) return (mem == root_mem_cgroup); }
Quoted 14 lines
mm/memcontrol.c static inline bool mem_cgroup_is_root(struct mem_cgroup *mem) · line 838
Quoted 11 lines
mm/memcontrol.c +11
-0+void mem_cgroup_pgfault_from_mm (struct mm_struct *mm) +{ + struct mem_cgroup *mem; + + if (!mm) + return; + + rcu_read_lock(); + mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); + if (unlikely(!mem)) + goto out;A lot of this can be reused, just a minor nitpick. May be you can combine this function and the one below
This has been fixed in V3 :)
--Ying
Quoted 87 lines
Quoted 87 lines
mm/memcontrol.c +31
-0+ mem_cgroup_pgfault(mem, 1); + +out: + rcu_read_unlock(); +} + +void mem_cgroup_pgmajfault_from_mm (struct mm_struct *mm) +{ + struct mem_cgroup *mem; + + if (!mm) + return; + + rcu_read_lock(); + mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); + if (unlikely(!mem)) + goto out; + mem_cgroup_pgmajfault(mem, 1); +out: + rcu_read_unlock(); +} +EXPORT_SYMBOL (mem_cgroup_pgmajfault_from_mm); + /** Following LRU functions are allowed to be used without PCG_LOCK. * Operations are called by routine of global LRU independently from memcg. @@ -3772,6 +3818,8 @@ enum { MCS_PGPGIN, MCS_PGPGOUT, MCS_SWAP, + MCS_PGFAULT, + MCS_PGMAJFAULT, MCS_INACTIVE_ANON, MCS_ACTIVE_ANON, MCS_INACTIVE_FILE,@@ -3794,6 +3842,8 @@ struct { {"pgpgin", "total_pgpgin"}, {"pgpgout", "total_pgpgout"}, {"swap", "total_swap"}, + {"pgfault", "total_pgfault"}, + {"pgmajfault", "total_pgmajfault"}, {"inactive_anon", "total_inactive_anon"}, {"active_anon", "total_active_anon"}, {"inactive_file", "total_inactive_file"},@@ -3822,6 +3872,10 @@ mem_cgroup_get_local_stat(struct mem_cgroup *mem, struct mcs_total_stat *s) val = mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_SWAPOUT); s->stat[MCS_SWAP] += val * PAGE_SIZE; } + val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_PGFAULT); + s->stat[MCS_PGFAULT] += val; + val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_PGMAJFAULT); + s->stat[MCS_PGMAJFAULT] += val; /* per zone stat */ val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);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_pgmajfault_from_mm(mm); } 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_pgfault_from_mm(mm); /* do counter updates before entering really critical section. */ check_sync_rss_stat(current);mm/shmem.c +1
-0@@ -1289,6 +1289,7 @@ repeat: /* here we actually do the io */ if (type && !(*type & VM_FAULT_MAJOR)) { __count_vm_event(PGMAJFAULT); + mem_cgroup_pgmajfault_from_mm(current->mm); *type |= VM_FAULT_MAJOR; }
Quoted 9 lines
Quoted 4 lines
mm/shmem.c +0
-1spin_unlock(&info->lock); --1.7.3.1
--
Three Cheers,
Balbir
--
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>