linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, memcg: add anon_hugepage stat
@ 2013-04-25 21:41 David Rientjes
  2013-04-25 21:55 ` Andrew Morton
  2013-04-26 11:17 ` Michal Hocko
  0 siblings, 2 replies; 9+ messages in thread
From: David Rientjes @ 2013-04-25 21:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johannes Weiner, Michal Hocko, KAMEZAWA Hiroyuki, linux-mm

This exports the amount of anonymous transparent hugepages for each memcg
via memory.stat in bytes.

This is helpful to determine the hugepage utilization for individual jobs
on the system in comparison to rss and opportunities where MADV_HUGEPAGE
may be helpful.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 include/linux/memcontrol.h |  3 ++-
 mm/huge_memory.c           |  2 ++
 mm/memcontrol.c            | 13 +++++++++----
 mm/rmap.c                  | 18 +++++++++++++++---
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -32,7 +32,8 @@ struct kmem_cache;
 
 /* Stats that can be updated by kernel. */
 enum mem_cgroup_page_stat_item {
-	MEMCG_NR_FILE_MAPPED, /* # of pages charged as file rss */
+	MEMCG_NR_FILE_MAPPED,	/* # of pages charged as file rss */
+	MEMCG_NR_ANON_HUGEPAGE,	/* # of anon transparent hugepages */
 };
 
 struct mem_cgroup_reclaim_cookie {
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1651,6 +1651,8 @@ static void __split_huge_page_refcount(struct page *page)
 	atomic_sub(tail_count, &page->_count);
 	BUG_ON(atomic_read(&page->_count) <= 0);
 
+	mem_cgroup_update_page_stat(page, MEMCG_NR_ANON_HUGEPAGE,
+				    -HPAGE_PMD_NR);
 	__mod_zone_page_state(zone, NR_ANON_TRANSPARENT_HUGEPAGES, -1);
 	__mod_zone_page_state(zone, NR_ANON_PAGES, HPAGE_PMD_NR);
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -91,10 +91,11 @@ enum mem_cgroup_stat_index {
 	/*
 	 * For MEM_CONTAINER_TYPE_ALL, usage = pagecache + rss.
 	 */
-	MEM_CGROUP_STAT_CACHE, 	   /* # of pages charged as cache */
-	MEM_CGROUP_STAT_RSS,	   /* # of pages charged as anon rss */
-	MEM_CGROUP_STAT_FILE_MAPPED,  /* # of pages charged as file rss */
-	MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */
+	MEM_CGROUP_STAT_CACHE,		/* # of pages charged as cache */
+	MEM_CGROUP_STAT_RSS,		/* # of pages charged as anon rss */
+	MEM_CGROUP_STAT_FILE_MAPPED,	/* # of pages charged as file rss */
+	MEM_CGROUP_STAT_SWAP,		/* # of pages, swapped out */
+	MEM_CGROUP_STAT_ANON_HUGEPAGE,	/* # of anon transparent hugepages */
 	MEM_CGROUP_STAT_NSTATS,
 };
 
@@ -103,6 +104,7 @@ static const char * const mem_cgroup_stat_names[] = {
 	"rss",
 	"mapped_file",
 	"swap",
+	"anon_hugepage",
 };
 
 enum mem_cgroup_events_index {
@@ -2217,6 +2219,9 @@ void mem_cgroup_update_page_stat(struct page *page,
 	case MEMCG_NR_FILE_MAPPED:
 		idx = MEM_CGROUP_STAT_FILE_MAPPED;
 		break;
+	case MEMCG_NR_ANON_HUGEPAGE:
+		idx = MEM_CGROUP_STAT_ANON_HUGEPAGE;
+		break;
 	default:
 		BUG();
 	}
diff --git a/mm/rmap.c b/mm/rmap.c
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1057,9 +1057,13 @@ void do_page_add_anon_rmap(struct page *page,
 	if (first) {
 		if (!PageTransHuge(page))
 			__inc_zone_page_state(page, NR_ANON_PAGES);
-		else
+		else {
+			mem_cgroup_update_page_stat(page,
+						    MEMCG_NR_ANON_HUGEPAGE,
+						    HPAGE_PMD_NR);
 			__inc_zone_page_state(page,
 					      NR_ANON_TRANSPARENT_HUGEPAGES);
+		}
 	}
 	if (unlikely(PageKsm(page)))
 		return;
@@ -1090,8 +1094,12 @@ void page_add_new_anon_rmap(struct page *page,
 	atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
 	if (!PageTransHuge(page))
 		__inc_zone_page_state(page, NR_ANON_PAGES);
-	else
+	else {
+		mem_cgroup_update_page_stat(page,
+					    MEMCG_NR_ANON_HUGEPAGE,
+					    HPAGE_PMD_NR);
 		__inc_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
+	}
 	__page_set_anon_rmap(page, vma, address, 1);
 	if (!mlocked_vma_newpage(vma, page))
 		lru_cache_add_lru(page, LRU_ACTIVE_ANON);
@@ -1152,9 +1160,13 @@ void page_remove_rmap(struct page *page)
 		mem_cgroup_uncharge_page(page);
 		if (!PageTransHuge(page))
 			__dec_zone_page_state(page, NR_ANON_PAGES);
-		else
+		else {
+			mem_cgroup_update_page_stat(page,
+						    MEMCG_NR_ANON_HUGEPAGE,
+						    -HPAGE_PMD_NR);
 			__dec_zone_page_state(page,
 					      NR_ANON_TRANSPARENT_HUGEPAGES);
+		}
 	} else {
 		__dec_zone_page_state(page, NR_FILE_MAPPED);
 		mem_cgroup_dec_page_stat(page, MEMCG_NR_FILE_MAPPED);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-04-25 21:41 [patch] mm, memcg: add anon_hugepage stat David Rientjes
@ 2013-04-25 21:55 ` Andrew Morton
  2013-04-25 23:07   ` David Rientjes
  2013-04-26 11:17 ` Michal Hocko
  1 sibling, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2013-04-25 21:55 UTC (permalink / raw)
  To: David Rientjes; +Cc: Johannes Weiner, Michal Hocko, KAMEZAWA Hiroyuki, linux-mm

On Thu, 25 Apr 2013 14:41:17 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:

> This exports the amount of anonymous transparent hugepages for each memcg
> via memory.stat in bytes.
> 
> This is helpful to determine the hugepage utilization for individual jobs
> on the system in comparison to rss and opportunities where MADV_HUGEPAGE
> may be helpful.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  include/linux/memcontrol.h |  3 ++-
>  mm/huge_memory.c           |  2 ++
>  mm/memcontrol.c            | 13 +++++++++----
>  mm/rmap.c                  | 18 +++++++++++++++---

And Documentation/cgroups/memory.txt, please.

> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
>
> ...
>
> +	MEM_CGROUP_STAT_FILE_MAPPED,	/* # of pages charged as file rss */
>
> ...
>
>  	"mapped_file",

That "FILE_MAPPED" is presented to the user as "mapped_file" makes me
want to chew my desk.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-04-25 21:55 ` Andrew Morton
@ 2013-04-25 23:07   ` David Rientjes
  0 siblings, 0 replies; 9+ messages in thread
From: David Rientjes @ 2013-04-25 23:07 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Johannes Weiner, Michal Hocko, KAMEZAWA Hiroyuki, linux-mm

On Thu, 25 Apr 2013, Andrew Morton wrote:

> > This exports the amount of anonymous transparent hugepages for each memcg
> > via memory.stat in bytes.
> > 
> > This is helpful to determine the hugepage utilization for individual jobs
> > on the system in comparison to rss and opportunities where MADV_HUGEPAGE
> > may be helpful.
> > 
> > Signed-off-by: David Rientjes <rientjes@google.com>
> > ---
> >  include/linux/memcontrol.h |  3 ++-
> >  mm/huge_memory.c           |  2 ++
> >  mm/memcontrol.c            | 13 +++++++++----
> >  mm/rmap.c                  | 18 +++++++++++++++---
> 
> And Documentation/cgroups/memory.txt, please.
> 

Sounds good, I'll send a v2 after the memcg maintainers have had a chance 
to give feedback.  Thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-04-25 21:41 [patch] mm, memcg: add anon_hugepage stat David Rientjes
  2013-04-25 21:55 ` Andrew Morton
@ 2013-04-26 11:17 ` Michal Hocko
  2013-04-28 21:40   ` David Rientjes
  1 sibling, 1 reply; 9+ messages in thread
From: Michal Hocko @ 2013-04-26 11:17 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Johannes Weiner, KAMEZAWA Hiroyuki, linux-mm

On Thu 25-04-13 14:41:17, David Rientjes wrote:
> This exports the amount of anonymous transparent hugepages for each memcg
> via memory.stat in bytes.
> 
> This is helpful to determine the hugepage utilization for individual jobs
> on the system in comparison to rss and opportunities where MADV_HUGEPAGE
> may be helpful.

Yes, useful and I had it on my todo list for quite some time. Never got
to it though. Thanks!

> Signed-off-by: David Rientjes <rientjes@google.com>

After documentation is update as poited out by Andrew.
Acked-by: Michal Hocko <mhocko@suse.cz>

One minor nit bellow:
> ---
>  include/linux/memcontrol.h |  3 ++-
>  mm/huge_memory.c           |  2 ++
>  mm/memcontrol.c            | 13 +++++++++----
>  mm/rmap.c                  | 18 +++++++++++++++---
>  4 files changed, 28 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -32,7 +32,8 @@ struct kmem_cache;
>  
>  /* Stats that can be updated by kernel. */
>  enum mem_cgroup_page_stat_item {
> -	MEMCG_NR_FILE_MAPPED, /* # of pages charged as file rss */
> +	MEMCG_NR_FILE_MAPPED,	/* # of pages charged as file rss */
> +	MEMCG_NR_ANON_HUGEPAGE,	/* # of anon transparent hugepages */

This is confusing because it would suggest that hpages is the unit but
you are accounting in regular pages as a unit.

>  };
>  
>  struct mem_cgroup_reclaim_cookie {
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1651,6 +1651,8 @@ static void __split_huge_page_refcount(struct page *page)
>  	atomic_sub(tail_count, &page->_count);
>  	BUG_ON(atomic_read(&page->_count) <= 0);
>  
> +	mem_cgroup_update_page_stat(page, MEMCG_NR_ANON_HUGEPAGE,
> +				    -HPAGE_PMD_NR);
				^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

>  	__mod_zone_page_state(zone, NR_ANON_TRANSPARENT_HUGEPAGES, -1);
>  	__mod_zone_page_state(zone, NR_ANON_PAGES, HPAGE_PMD_NR);
>  
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -91,10 +91,11 @@ enum mem_cgroup_stat_index {
>  	/*
>  	 * For MEM_CONTAINER_TYPE_ALL, usage = pagecache + rss.
>  	 */
> -	MEM_CGROUP_STAT_CACHE, 	   /* # of pages charged as cache */
> -	MEM_CGROUP_STAT_RSS,	   /* # of pages charged as anon rss */
> -	MEM_CGROUP_STAT_FILE_MAPPED,  /* # of pages charged as file rss */
> -	MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */
> +	MEM_CGROUP_STAT_CACHE,		/* # of pages charged as cache */
> +	MEM_CGROUP_STAT_RSS,		/* # of pages charged as anon rss */
> +	MEM_CGROUP_STAT_FILE_MAPPED,	/* # of pages charged as file rss */
> +	MEM_CGROUP_STAT_SWAP,		/* # of pages, swapped out */
> +	MEM_CGROUP_STAT_ANON_HUGEPAGE,	/* # of anon transparent hugepages */

Same here.

>  	MEM_CGROUP_STAT_NSTATS,
>  };
>  
[...]
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-04-26 11:17 ` Michal Hocko
@ 2013-04-28 21:40   ` David Rientjes
  2013-04-30  0:22     ` [patch] mm, memcg: add rss_huge stat to memory.stat David Rientjes
  2013-05-02 14:17     ` [patch] mm, memcg: add anon_hugepage stat Michal Hocko
  0 siblings, 2 replies; 9+ messages in thread
From: David Rientjes @ 2013-04-28 21:40 UTC (permalink / raw)
  To: Michal Hocko; +Cc: Andrew Morton, Johannes Weiner, KAMEZAWA Hiroyuki, linux-mm

On Fri, 26 Apr 2013, Michal Hocko wrote:

> Yes, useful and I had it on my todo list for quite some time. Never got
> to it though. Thanks!
> 

I think I'll add an anon_pages counter as well for non-thp for comparison, 
and probably do it in the same patch.

The problem is that we don't always have the memcg context for the page 
when calling page_add_anon_rmap() or page_remove_rmap().

 [ An example in this patch is in page_remove_rmap() where I was calling 
   mem_cgroup_update_page_stat() after mem_cgroup_uncharge_page(). ]

For example, in unuse_pte():

	if (page == swapcache)
		page_add_anon_rmap(page, vma, addr);
	else /* ksm created a completely new copy */
		page_add_new_anon_rmap(page, vma, addr);
	mem_cgroup_commit_charge_swapin(page, memcg);

There are a couple of options to fix this and I really don't have a strong 
preference for which one we go with:

 - pass struct mem_cgroup * to page_add_anon_rmap() and 
   page_remove_rmap(), such as "memcg" in the above example), or

 - separate out the anon page/hugepage ZVC accounting entirely from these 
   two functions and add a followup call to a new function dedicated for 
   this purpose once the memcg commit has been done.

I'm leaning toward doing the latter just because it's cleaner, but it 
means page_remove_rmap() picks up a return value (anon or not?) and 
page_add_anon_rmap() picks up a return value (_mapcount == 0?).

Comments?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch] mm, memcg: add rss_huge stat to memory.stat
  2013-04-28 21:40   ` David Rientjes
@ 2013-04-30  0:22     ` David Rientjes
  2013-04-30 17:36       ` Johannes Weiner
  2013-05-02 14:17     ` [patch] mm, memcg: add anon_hugepage stat Michal Hocko
  1 sibling, 1 reply; 9+ messages in thread
From: David Rientjes @ 2013-04-30  0:22 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Michal Hocko, Johannes Weiner, KAMEZAWA Hiroyuki, linux-kernel,
	linux-mm

This exports the amount of anonymous transparent hugepages for each memcg
via the new "rss_huge" stat in memory.stat.  The units are in bytes.

This is helpful to determine the hugepage utilization for individual jobs
on the system in comparison to rss and opportunities where MADV_HUGEPAGE
may be helpful.

The amount of anonymous transparent hugepages is also included in "rss"
for backwards compatibility.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 Documentation/cgroups/memory.txt |  4 +++-
 mm/memcontrol.c                  | 36 ++++++++++++++++++++++++++----------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -478,7 +478,9 @@ memory.stat file includes following statistics
 
 # per-memory cgroup local status
 cache		- # of bytes of page cache memory.
-rss		- # of bytes of anonymous and swap cache memory.
+rss		- # of bytes of anonymous and swap cache memory (includes
+		transparent hugepages).
+rss_huge	- # of bytes of anonymous transparent hugepages.
 mapped_file	- # of bytes of mapped file (includes tmpfs/shmem)
 pgpgin		- # of charging events to the memory cgroup. The charging
 		event happens each time a page is accounted as either mapped
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -91,16 +91,18 @@ enum mem_cgroup_stat_index {
 	/*
 	 * For MEM_CONTAINER_TYPE_ALL, usage = pagecache + rss.
 	 */
-	MEM_CGROUP_STAT_CACHE, 	   /* # of pages charged as cache */
-	MEM_CGROUP_STAT_RSS,	   /* # of pages charged as anon rss */
-	MEM_CGROUP_STAT_FILE_MAPPED,  /* # of pages charged as file rss */
-	MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */
+	MEM_CGROUP_STAT_CACHE,		/* # of pages charged as cache */
+	MEM_CGROUP_STAT_RSS,		/* # of pages charged as anon rss */
+	MEM_CGROUP_STAT_RSS_HUGE,	/* # of pages charged as anon huge */
+	MEM_CGROUP_STAT_FILE_MAPPED,	/* # of pages charged as file rss */
+	MEM_CGROUP_STAT_SWAP,		/* # of pages, swapped out */
 	MEM_CGROUP_STAT_NSTATS,
 };
 
 static const char * const mem_cgroup_stat_names[] = {
 	"cache",
 	"rss",
+	"rss_huge",
 	"mapped_file",
 	"swap",
 };
@@ -888,6 +890,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg,
 }
 
 static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
+					 struct page *page,
 					 bool anon, int nr_pages)
 {
 	preempt_disable();
@@ -903,6 +906,10 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg,
 		__this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_CACHE],
 				nr_pages);
 
+	if (PageTransHuge(page))
+		__this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_RSS_HUGE],
+				nr_pages);
+
 	/* pagein of a big page is an event. So, ignore page size */
 	if (nr_pages > 0)
 		__this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PGPGIN]);
@@ -2813,7 +2820,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
 	else
 		anon = false;
 
-	mem_cgroup_charge_statistics(memcg, anon, nr_pages);
+	mem_cgroup_charge_statistics(memcg, page, anon, nr_pages);
 	unlock_page_cgroup(pc);
 
 	/*
@@ -3603,16 +3610,21 @@ void mem_cgroup_split_huge_fixup(struct page *head)
 {
 	struct page_cgroup *head_pc = lookup_page_cgroup(head);
 	struct page_cgroup *pc;
+	struct mem_cgroup *memcg;
 	int i;
 
 	if (mem_cgroup_disabled())
 		return;
+
+	memcg = head_pc->mem_cgroup;
 	for (i = 1; i < HPAGE_PMD_NR; i++) {
 		pc = head_pc + i;
-		pc->mem_cgroup = head_pc->mem_cgroup;
+		pc->mem_cgroup = memcg;
 		smp_wmb();/* see __commit_charge() */
 		pc->flags = head_pc->flags & ~PCGF_NOCOPY_AT_SPLIT;
 	}
+	__this_cpu_sub(memcg->stat->count[MEM_CGROUP_STAT_RSS_HUGE],
+		       HPAGE_PMD_NR);
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
@@ -3668,11 +3680,11 @@ static int mem_cgroup_move_account(struct page *page,
 		__this_cpu_inc(to->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
 		preempt_enable();
 	}
-	mem_cgroup_charge_statistics(from, anon, -nr_pages);
+	mem_cgroup_charge_statistics(from, page, anon, -nr_pages);
 
 	/* caller should have done css_get */
 	pc->mem_cgroup = to;
-	mem_cgroup_charge_statistics(to, anon, nr_pages);
+	mem_cgroup_charge_statistics(to, page, anon, nr_pages);
 	move_unlock_mem_cgroup(from, &flags);
 	ret = 0;
 unlock:
@@ -4047,7 +4059,7 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype,
 		break;
 	}
 
-	mem_cgroup_charge_statistics(memcg, anon, -nr_pages);
+	mem_cgroup_charge_statistics(memcg, page, anon, -nr_pages);
 
 	ClearPageCgroupUsed(pc);
 	/*
@@ -4397,7 +4409,7 @@ void mem_cgroup_replace_page_cache(struct page *oldpage,
 	lock_page_cgroup(pc);
 	if (PageCgroupUsed(pc)) {
 		memcg = pc->mem_cgroup;
-		mem_cgroup_charge_statistics(memcg, false, -1);
+		mem_cgroup_charge_statistics(memcg, oldpage, false, -1);
 		ClearPageCgroupUsed(pc);
 	}
 	unlock_page_cgroup(pc);
@@ -4925,6 +4937,10 @@ static inline u64 mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
 			return res_counter_read_u64(&memcg->memsw, RES_USAGE);
 	}
 
+	/*
+	 * Transparent hugepages are still accounted for in MEM_CGROUP_STAT_RSS
+	 * as well as in MEM_CGROUP_STAT_RSS_HUGE.
+	 */
 	val = mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_CACHE);
 	val += mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_RSS);
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add rss_huge stat to memory.stat
  2013-04-30  0:22     ` [patch] mm, memcg: add rss_huge stat to memory.stat David Rientjes
@ 2013-04-30 17:36       ` Johannes Weiner
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Weiner @ 2013-04-30 17:36 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Michal Hocko, KAMEZAWA Hiroyuki, linux-kernel,
	linux-mm

On Mon, Apr 29, 2013 at 05:22:52PM -0700, David Rientjes wrote:
> This exports the amount of anonymous transparent hugepages for each memcg
> via the new "rss_huge" stat in memory.stat.  The units are in bytes.
> 
> This is helpful to determine the hugepage utilization for individual jobs
> on the system in comparison to rss and opportunities where MADV_HUGEPAGE
> may be helpful.
> 
> The amount of anonymous transparent hugepages is also included in "rss"
> for backwards compatibility.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-04-28 21:40   ` David Rientjes
  2013-04-30  0:22     ` [patch] mm, memcg: add rss_huge stat to memory.stat David Rientjes
@ 2013-05-02 14:17     ` Michal Hocko
  2013-05-02 16:01       ` David Rientjes
  1 sibling, 1 reply; 9+ messages in thread
From: Michal Hocko @ 2013-05-02 14:17 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Johannes Weiner, KAMEZAWA Hiroyuki, linux-mm

On Sun 28-04-13 14:40:37, David Rientjes wrote:
> On Fri, 26 Apr 2013, Michal Hocko wrote:
> 
> > Yes, useful and I had it on my todo list for quite some time. Never got
> > to it though. Thanks!
> > 
> 
> I think I'll add an anon_pages counter as well for non-thp for comparison, 

I am not sure I understand. I assume you want to export the anon counter
as well, right? Wouldn't that be too confusing? Yes, rss is a terrible
name and mixing it with swapcache is arguably a good idea but are there
any cases where you want anon - swapcache?

> and probably do it in the same patch.
> 
> The problem is that we don't always have the memcg context for the page 
> when calling page_add_anon_rmap() or page_remove_rmap().
> 
>  [ An example in this patch is in page_remove_rmap() where I was calling 
>    mem_cgroup_update_page_stat() after mem_cgroup_uncharge_page(). ]
> 
> For example, in unuse_pte():
> 
> 	if (page == swapcache)
> 		page_add_anon_rmap(page, vma, addr);
> 	else /* ksm created a completely new copy */
> 		page_add_new_anon_rmap(page, vma, addr);
> 	mem_cgroup_commit_charge_swapin(page, memcg);
> 
> There are a couple of options to fix this and I really don't have a strong 
> preference for which one we go with:
> 
>  - pass struct mem_cgroup * to page_add_anon_rmap() and 
>    page_remove_rmap(), such as "memcg" in the above example), or
> 
>  - separate out the anon page/hugepage ZVC accounting entirely from these 
>    two functions and add a followup call to a new function dedicated for 
>    this purpose once the memcg commit has been done.
> 
> I'm leaning toward doing the latter just because it's cleaner, but it 
> means page_remove_rmap() picks up a return value (anon or not?) and 
> page_add_anon_rmap() picks up a return value (_mapcount == 0?).
> 
> Comments?

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] mm, memcg: add anon_hugepage stat
  2013-05-02 14:17     ` [patch] mm, memcg: add anon_hugepage stat Michal Hocko
@ 2013-05-02 16:01       ` David Rientjes
  0 siblings, 0 replies; 9+ messages in thread
From: David Rientjes @ 2013-05-02 16:01 UTC (permalink / raw)
  To: Michal Hocko; +Cc: Andrew Morton, Johannes Weiner, KAMEZAWA Hiroyuki, linux-mm

On Thu, 2 May 2013, Michal Hocko wrote:

> I am not sure I understand. I assume you want to export the anon counter
> as well, right? Wouldn't that be too confusing? Yes, rss is a terrible
> name and mixing it with swapcache is arguably a good idea but are there
> any cases where you want anon - swapcache?
> 

This concept was obsoleted by 
mm-memcg-add-rss_huge-stat-to-memorystat.patch.  Thanks for the ack!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-02 16:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25 21:41 [patch] mm, memcg: add anon_hugepage stat David Rientjes
2013-04-25 21:55 ` Andrew Morton
2013-04-25 23:07   ` David Rientjes
2013-04-26 11:17 ` Michal Hocko
2013-04-28 21:40   ` David Rientjes
2013-04-30  0:22     ` [patch] mm, memcg: add rss_huge stat to memory.stat David Rientjes
2013-04-30 17:36       ` Johannes Weiner
2013-05-02 14:17     ` [patch] mm, memcg: add anon_hugepage stat Michal Hocko
2013-05-02 16:01       ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).