Skip to contentSkip to conversation

Add the pagefault count into memcg stats

PATCH In review Ying Han 5 participants 9 messages Mar 29, 2011 – Apr 14, 2011

Subsystems (6)
lore
Share & tools
lore

Ying Han

author
#0 lore raw

PATCH v3 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.67s   233.41s    14.76s   16798.546 266356.260
+-------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  10     16682.962     17344.027     16913.524     16928.812      166.5362
+  10     16695.568     16923.896     16820.604     16824.652     84.816568

No difference proven at 95.0% confidence

Change v3..v2
1. removed the unnecessary function definition in memcontrol.h

---
 Documentation/cgroups/memory.txt |    4 +++
 fs/ncpfs/mmap.c                  |    2 +
 include/linux/memcontrol.h       |    6 +++++
 mm/filemap.c                     |    1 +
 mm/memcontrol.c                  |   47 ++++++++++++++++++++++++++++++++++++++
 mm/memory.c                      |    2 +
 mm/shmem.c                       |    2 +
 7 files changed, 64 insertions(+), 0 deletions(-)
Documentation/cgroups/memory.txt +4 -0
index b6ed61c..2db6103 100644
@@ -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
index a7c07b4..e5d71b2 100644
@@ -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 +6 -0
index 5a5ce70..8a48f5b 100644
@@ -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,7 @@ 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_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 +356,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
 {
 }
 
+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
index a6cfecf..e022229 100644
@@ -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
index 8617d39..28d19b6 100644
@@ -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
index ad8346b..fa0b2b8 100644
@@ -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>
#1 lore raw

Hi

sorry, I didn't see past discussion of this thread. then, I may be missing something.

Quoted 6 lines

Two new stats in per-memcg memory.stat which tracks the number of page faults and number of major page faults.

"pgfault"
"pgmajfault"

Quoted 8 lines

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.

Currently, memory cgroup don't restrict number of page fault. And we already have this feature by CONFIG_CGROUP_PERF if my understanding is correct. Why don't you use perf cgroup?

In the other words, after your patch, we have four pagefault counter. Do we really need *four*? Can't we consolidate them?

1. tsk->maj_flt
2. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ)
3. count_vm_event(PGMAJFAULT);
4. mem_cgroup_count_vm_event(PGMAJFAULT);

--
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>

author
#2 lore raw
Quoted 24 lines · KOSAKI Motohiro

Hi

sorry, I didn't see past discussion of this thread. then, I may be missing something.

Quoted 6 lines

Two new stats in per-memcg memory.stat which tracks the number of page faults and number of major page faults.

"pgfault"
"pgmajfault"

Quoted 8 lines

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.

Currently, memory cgroup don't restrict number of page fault. And we already have this feature by CONFIG_CGROUP_PERF if my understanding is correct. Why don't you use perf cgroup?

Quoted 7 lines

In the other words, after your patch, we have four pagefault counter. Do we really need *four*? Can't we consolidate them?

1. tsk->maj_flt
2. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ)
3. count_vm_event(PGMAJFAULT);
4. mem_cgroup_count_vm_event(PGMAJFAULT);

The first three are per-process and per-system level counters. What I did in this patch is to add per-memcg counters for pgfault and pgmajfault. This purpose is not to do any limiting but monitoring. I am not sure about the CONFIG_CGROUP_PERF, does it require CONFIG_PERF_EVENTS?

Thanks

--Ying

Quoted 6 lines

--
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>

#3 lore raw
Quoted 12 lines
Quoted 11 lines

Currently, memory cgroup don't restrict number of page fault. And we already have this feature by CONFIG_CGROUP_PERF if my understanding is correct. Why don't you use perf cgroup?

In the other words, after your patch, we have four pagefault counter. Do we really need *four*? Can't we consolidate them?

1. tsk->maj_flt
2. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ)
3. count_vm_event(PGMAJFAULT);
4. mem_cgroup_count_vm_event(PGMAJFAULT);

Quoted 5 lines

The first three are per-process and per-system level counters. What I did in this patch is to add per-memcg counters for pgfault and pgmajfault. This purpose is not to do any limiting but monitoring. I am not sure about the CONFIG_CGROUP_PERF, does it require CONFIG_PERF_EVENTS?

Yes, per-process counter can be enhanced per-cgroup counter naturally and easily. I guess it's a background idea of that.

--
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>

maintainer
#4 lore raw
In reply to Ying Han
Quoted 14 lines · On Tue, 29 Mar 2011 10:32:33 -0700 Ying Han <[email protected]> wrote:
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 static inline void mem_cgroup_split_huge_fixup(struct page *head, · line 362

Quoted 7 lines
include/linux/memcontrol.h +4 -0
@@ -354,6 +356,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
 {
 }
 
+static inline
+void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx)
+{
+}

This doesn't compile for me - parameter idx has an incomplete type.

I've seen this before and I suspect that some (later) versions of gcc are happy with it, but older gcc's are not. It's a recurring problem with enums - forard-declaring them doesn't work.

What I did was to move all the vm_event_item definition into a standalone header file and then applied the appropriate fixups. This was done as a preparatory patch, preceding yours.

From: Andrew Morton <[email protected]>

enums are problematic because they cannot be forward-declared:

akpm2:/home/akpm> cat t.c

enum foo;

static inline void bar(enum foo f)
{
}
akpm2:/home/akpm> gcc -c t.c
t.c:4: error: parameter 1 ('f') has incomplete type

So move the enum's definition into a standalone header file which can be used wherever its definition is needed.

Cc Ying Han <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Daisuke Nishimura <[email protected]>
Cc Balbir Singh <[email protected]>

---

 include/linux/vm_event_item.h |   64 ++++++++++++++++++++++++++++++++
 include/linux/vmstat.h        |   62 -------------------------------
 2 files changed, 65 insertions(+), 61 deletions(-)
include/linux/vmstat.h renamed from include/linux/vmstat.h~mm-move-enum-vm_event_item-into-a-standalone-header-file +1 -61
diff -puN include/linux/vmstat.h~mm-move-enum-vm_event_item-into-a-standalone-header-file include/linux/vmstat.h
@@ -5,69 +5,9 @@
 #include <linux/percpu.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
+#include <linux/vm_event_item.h>
 #include <asm/atomic.h>
 
-#ifdef CONFIG_ZONE_DMA
-#define DMA_ZONE(xx) xx##_DMA,
-#else
-#define DMA_ZONE(xx)
-#endif
-
-#ifdef CONFIG_ZONE_DMA32
-#define DMA32_ZONE(xx) xx##_DMA32,
-#else
-#define DMA32_ZONE(xx)
-#endif
-
-#ifdef CONFIG_HIGHMEM
-#define HIGHMEM_ZONE(xx) , xx##_HIGH
-#else
-#define HIGHMEM_ZONE(xx)
-#endif
-
-
-#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
-
-enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
-		FOR_ALL_ZONES(PGALLOC),
-		PGFREE, PGACTIVATE, PGDEACTIVATE,
-		PGFAULT, PGMAJFAULT,
-		FOR_ALL_ZONES(PGREFILL),
-		FOR_ALL_ZONES(PGSTEAL),
-		FOR_ALL_ZONES(PGSCAN_KSWAPD),
-		FOR_ALL_ZONES(PGSCAN_DIRECT),
-#ifdef CONFIG_NUMA
-		PGSCAN_ZONE_RECLAIM_FAILED,
-#endif
-		PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
-		KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY,
-		KSWAPD_SKIP_CONGESTION_WAIT,
-		PAGEOUTRUN, ALLOCSTALL, PGROTATED,
-#ifdef CONFIG_COMPACTION
-		COMPACTBLOCKS, COMPACTPAGES, COMPACTPAGEFAILED,
-		COMPACTSTALL, COMPACTFAIL, COMPACTSUCCESS,
-#endif
-#ifdef CONFIG_HUGETLB_PAGE
-		HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
-#endif
-		UNEVICTABLE_PGCULLED,	/* culled to noreclaim list */
-		UNEVICTABLE_PGSCANNED,	/* scanned for reclaimability */
-		UNEVICTABLE_PGRESCUED,	/* rescued from noreclaim list */
-		UNEVICTABLE_PGMLOCKED,
-		UNEVICTABLE_PGMUNLOCKED,
-		UNEVICTABLE_PGCLEARED,	/* on COW, page truncate */
-		UNEVICTABLE_PGSTRANDED,	/* unable to isolate on unlock */
-		UNEVICTABLE_MLOCKFREED,
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
-		THP_FAULT_ALLOC,
-		THP_FAULT_FALLBACK,
-		THP_COLLAPSE_ALLOC,
-		THP_COLLAPSE_ALLOC_FAILED,
-		THP_SPLIT,
-#endif
-		NR_VM_EVENT_ITEMS
-};
-
 extern int sysctl_stat_interval;
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
include/linux/vm_event_item.h new file +64 -0

64 lines not on this page · raw message

_

--
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>

#5 lore raw
In reply to Ying Han
Quoted 46 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 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   233.41s    14.76s   16798.546 266356.260
+-------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  10     16682.962     17344.027     16913.524     16928.812      166.5362
+  10     16695.568     16923.896     16820.604     16824.652     84.816568
Quoted 7 lines

No difference proven at 95.0% confidence

Change v3..v2
1. removed the unnecessary function definition in memcontrol.h

I'm wondering if we can just modify count_vm_event() directly for CONFIG_CGROUP_MEM_RES_CTLR so that we automatically track all vmstat items (those in enum vm_event_item) for each memcg. We could add an array of NR_VM_EVENT_ITEMS into each struct mem_cgroup to be incremented on count_vm_event() for current's memcg.

If that's done, we wouldn't have to add additional calls for every vmstat item we want to duplicate from the global counters.

--
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>

#6 lore raw
Quoted 56 lines · On Wed, 13 Apr 2011 13:12:33 -0700 (PDT) David Rientjes <[email protected]>…
Quoted 46 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 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   233.41s    14.76s   16798.546 266356.260
+-------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x  10     16682.962     17344.027     16913.524     16928.812      166.5362
+  10     16695.568     16923.896     16820.604     16824.652     84.816568
Quoted 7 lines

No difference proven at 95.0% confidence

Change v3..v2
1. removed the unnecessary function definition in memcontrol.h

Quoted 9 lines

I'm wondering if we can just modify count_vm_event() directly for CONFIG_CGROUP_MEM_RES_CTLR so that we automatically track all vmstat items (those in enum vm_event_item) for each memcg. We could add an array of NR_VM_EVENT_ITEMS into each struct mem_cgroup to be incremented on count_vm_event() for current's memcg.

If that's done, we wouldn't have to add additional calls for every vmstat item we want to duplicate from the global counters.

Maybe we do that finally.

For now, IIUC, over 50% of VM_EVENTS are needless for memcg (ex. per zone stats) and this array consumes large size of percpu area. I think we need to select events carefully even if we do that. And current memcg's percpu stat is mixture of vm_events and vm_stat. We may need to sort out them and re-design it. My concern is that I'm not sure we have enough percpu area for vmstat+vmevents for 1000+ memcg, and it's allowed even if we can do.

But yes, it seems worth to consider.

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>

#7 lore raw
Quoted 10 lines · KAMEZAWA Hiroyuki
Quoted 9 lines

I'm wondering if we can just modify count_vm_event() directly for CONFIG_CGROUP_MEM_RES_CTLR so that we automatically track all vmstat items (those in enum vm_event_item) for each memcg. We could add an array of NR_VM_EVENT_ITEMS into each struct mem_cgroup to be incremented on count_vm_event() for current's memcg.

If that's done, we wouldn't have to add additional calls for every vmstat item we want to duplicate from the global counters.

Quoted 9 lines

Maybe we do that finally.

For now, IIUC, over 50% of VM_EVENTS are needless for memcg (ex. per zone stats) and this array consumes large size of percpu area. I think we need to select events carefully even if we do that. And current memcg's percpu stat is mixture of vm_events and vm_stat. We may need to sort out them and re-design it. My concern is that I'm not sure we have enough percpu area for vmstat+vmevents for 1000+ memcg, and it's allowed even if we can do.

What I proposed above was adding an array directly into struct mem_cgroup so that we don't collect the stats percpu, they are incremented directly in the mem_cgroup. Perhaps if we separated enum vm_event_item out into two separate arrays (those useful only globally and those useful for both global and memcg), then this would be simple.

Something like

	enum vm_event_item {
		PGPGIN,
		PGPGOUT,
		PSWPIN,
		PSWPOUT,
		...
		NR_VM_EVENT_ITEMS,
	};

	enum vm_global_event_item {
		KSWAPD_STEAL = NR_VM_EVENT_ITEMS,
		KSWAPD_INODESTEAL,
		...
	};

and then in count_vm_event(), check

	if (item < NR_VM_EVENT_ITEMS) {
		memcg_add_vm_event(mem, item, count);
	}

I don't think we need to be concerned about reordering the global /proc/vmstat to fit this purpose.

--
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>

#8 lore raw
Quoted 45 lines · On Wed, 13 Apr 2011 17:47:01 -0700 (PDT) David Rientjes <[email protected]>…
Quoted 10 lines · KAMEZAWA Hiroyuki
Quoted 9 lines

I'm wondering if we can just modify count_vm_event() directly for CONFIG_CGROUP_MEM_RES_CTLR so that we automatically track all vmstat items (those in enum vm_event_item) for each memcg. We could add an array of NR_VM_EVENT_ITEMS into each struct mem_cgroup to be incremented on count_vm_event() for current's memcg.

If that's done, we wouldn't have to add additional calls for every vmstat item we want to duplicate from the global counters.

Quoted 9 lines

Maybe we do that finally.

For now, IIUC, over 50% of VM_EVENTS are needless for memcg (ex. per zone stats) and this array consumes large size of percpu area. I think we need to select events carefully even if we do that. And current memcg's percpu stat is mixture of vm_events and vm_stat. We may need to sort out them and re-design it. My concern is that I'm not sure we have enough percpu area for vmstat+vmevents for 1000+ memcg, and it's allowed even if we can do.

What I proposed above was adding an array directly into struct mem_cgroup so that we don't collect the stats percpu, they are incremented directly in the mem_cgroup. Perhaps if we separated enum vm_event_item out into two separate arrays (those useful only globally and those useful for both global and memcg), then this would be simple.

Something like

	enum vm_event_item {
		PGPGIN,
		PGPGOUT,
		PSWPIN,
		PSWPOUT,
		...
		NR_VM_EVENT_ITEMS,
	};

	enum vm_global_event_item {
		KSWAPD_STEAL = NR_VM_EVENT_ITEMS,
		KSWAPD_INODESTEAL,
		...
	};
Quoted 9 lines

and then in count_vm_event(), check

	if (item < NR_VM_EVENT_ITEMS) {
		memcg_add_vm_event(mem, item, count);
	}

I don't think we need to be concerned about reordering the global /proc/vmstat to fit this purpose.

Hmm, ok. will try that.

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>