linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][-mm] memcg: generic filestat update interface.
@ 2010-09-22  5:08 KAMEZAWA Hiroyuki
  2010-09-22  9:19 ` Balbir Singh
  2010-09-22 17:50 ` Greg Thelen
  0 siblings, 2 replies; 3+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-09-22  5:08 UTC (permalink / raw)
  To: linux-mm@kvack.org
  Cc: balbir@linux.vnet.ibm.com, nishimura@mxp.nes.nec.co.jp,
	Greg Thelen, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org


based on mmotm and other memory cgroup patches in -mm queue.
==
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

This patch extracts core logic of mem_cgroup_update_file_mapped() as
mem_cgroup_update_file_stat() and add a skin.

As a planned future update, memory cgroup has to count dirty pages to implement
dirty_ratio/limit. And more, the number of dirty pages is required to kick flusher
thread to start writeback. (Now, no kick.)

This patch is preparation for it and makes other statistics implementation
clearer. Just a clean up.

Note:
In previous patch series, I wrote a more complicated patch to make the
more generic and wanted to avoid using switch(). But now, we found page_mapped()
check is necessary for updage_file_mapepd().We can't avoid to add some conditions.
I hope this style is enough easy to read and to maintainance.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 mm/memcontrol.c |   25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

Index: mmotm-0915/mm/memcontrol.c
===================================================================
--- mmotm-0915.orig/mm/memcontrol.c
+++ mmotm-0915/mm/memcontrol.c
@@ -1575,7 +1575,8 @@ bool mem_cgroup_handle_oom(struct mem_cg
  * small, we check MEM_CGROUP_ON_MOVE percpu value and detect there are
  * possibility of race condition. If there is, we take a lock.
  */
-void mem_cgroup_update_file_mapped(struct page *page, int val)
+
+static void mem_cgroup_update_file_stat(struct page *page, int idx, int val)
 {
 	struct mem_cgroup *mem;
 	struct page_cgroup *pc = lookup_page_cgroup(page);
@@ -1597,13 +1598,18 @@ void mem_cgroup_update_file_mapped(struc
 		if (!mem || !PageCgroupUsed(pc))
 			goto out;
 	}
-	if (val > 0) {
-		this_cpu_inc(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
-		SetPageCgroupFileMapped(pc);
-	} else {
-		this_cpu_dec(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
-		if (!page_mapped(page)) /* for race between dec->inc counter */
+
+	this_cpu_add(mem->stat->count[idx], val);
+
+	switch (idx) {
+	case MEM_CGROUP_STAT_FILE_MAPPED:
+		if (val > 0)
+			SetPageCgroupFileMapped(pc);
+		else if (!page_mapped(page))
 			ClearPageCgroupFileMapped(pc);
+		break;
+	default:
+		BUG();
 	}
 
 out:
@@ -1613,6 +1619,11 @@ out:
 	return;
 }
 
+void mem_cgroup_update_file_mapped(struct page *page, int val)
+{
+	mem_cgroup_update_file_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, val);
+}
+
 /*
  * size of first charge trial. "32" comes from vmscan.c's magic value.
  * TODO: maybe necessary to use big numbers in big irons.

--
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] 3+ messages in thread

* Re: [PATCH][-mm] memcg: generic filestat update interface.
  2010-09-22  5:08 [PATCH][-mm] memcg: generic filestat update interface KAMEZAWA Hiroyuki
@ 2010-09-22  9:19 ` Balbir Singh
  2010-09-22 17:50 ` Greg Thelen
  1 sibling, 0 replies; 3+ messages in thread
From: Balbir Singh @ 2010-09-22  9:19 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: linux-mm@kvack.org, nishimura@mxp.nes.nec.co.jp, Greg Thelen,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org

* KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> [2010-09-22 14:08:17]:

> 
> based on mmotm and other memory cgroup patches in -mm queue.
> ==
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> This patch extracts core logic of mem_cgroup_update_file_mapped() as
> mem_cgroup_update_file_stat() and add a skin.
> 
> As a planned future update, memory cgroup has to count dirty pages to implement
> dirty_ratio/limit. And more, the number of dirty pages is required to kick flusher
> thread to start writeback. (Now, no kick.)
> 
> This patch is preparation for it and makes other statistics implementation
> clearer. Just a clean up.
> 
> Note:
> In previous patch series, I wrote a more complicated patch to make the
> more generic and wanted to avoid using switch(). But now, we found page_mapped()
> check is necessary for updage_file_mapepd().We can't avoid to add some conditions.
> I hope this style is enough easy to read and to maintainance.
> 
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
>  mm/memcontrol.c |   25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> Index: mmotm-0915/mm/memcontrol.c
> ===================================================================
> --- mmotm-0915.orig/mm/memcontrol.c
> +++ mmotm-0915/mm/memcontrol.c
> @@ -1575,7 +1575,8 @@ bool mem_cgroup_handle_oom(struct mem_cg
>   * small, we check MEM_CGROUP_ON_MOVE percpu value and detect there are
>   * possibility of race condition. If there is, we take a lock.
>   */
> -void mem_cgroup_update_file_mapped(struct page *page, int val)
> +
> +static void mem_cgroup_update_file_stat(struct page *page, int idx, int val)
>  {
>  	struct mem_cgroup *mem;
>  	struct page_cgroup *pc = lookup_page_cgroup(page);
> @@ -1597,13 +1598,18 @@ void mem_cgroup_update_file_mapped(struc
>  		if (!mem || !PageCgroupUsed(pc))
>  			goto out;
>  	}
> -	if (val > 0) {
> -		this_cpu_inc(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
> -		SetPageCgroupFileMapped(pc);
> -	} else {
> -		this_cpu_dec(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
> -		if (!page_mapped(page)) /* for race between dec->inc counter */
> +
> +	this_cpu_add(mem->stat->count[idx], val);
> +
> +	switch (idx) {
> +	case MEM_CGROUP_STAT_FILE_MAPPED:
> +		if (val > 0)
> +			SetPageCgroupFileMapped(pc);
> +		else if (!page_mapped(page))
>  			ClearPageCgroupFileMapped(pc);
> +		break;
> +	default:
> +		BUG();
>  	}
> 
>  out:
> @@ -1613,6 +1619,11 @@ out:
>  	return;
>  }
> 
> +void mem_cgroup_update_file_mapped(struct page *page, int val)
> +{
> +	mem_cgroup_update_file_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, val);
> +}
> +

Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
 

-- 
	Three Cheers,
	Balbir

--
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] 3+ messages in thread

* Re: [PATCH][-mm] memcg: generic filestat update interface.
  2010-09-22  5:08 [PATCH][-mm] memcg: generic filestat update interface KAMEZAWA Hiroyuki
  2010-09-22  9:19 ` Balbir Singh
@ 2010-09-22 17:50 ` Greg Thelen
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Thelen @ 2010-09-22 17:50 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: linux-mm@kvack.org, balbir@linux.vnet.ibm.com,
	nishimura@mxp.nes.nec.co.jp, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org

KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> writes:

> based on mmotm and other memory cgroup patches in -mm queue.
> ==
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> This patch extracts core logic of mem_cgroup_update_file_mapped() as
> mem_cgroup_update_file_stat() and add a skin.
>
> As a planned future update, memory cgroup has to count dirty pages to implement
> dirty_ratio/limit. And more, the number of dirty pages is required to kick flusher
> thread to start writeback. (Now, no kick.)
>
> This patch is preparation for it and makes other statistics implementation
> clearer. Just a clean up.
>
> Note:
> In previous patch series, I wrote a more complicated patch to make the
> more generic and wanted to avoid using switch(). But now, we found page_mapped()
> check is necessary for updage_file_mapepd().We can't avoid to add some conditions.
> I hope this style is enough easy to read and to maintainance.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
>  mm/memcontrol.c |   25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
>
> Index: mmotm-0915/mm/memcontrol.c
> ===================================================================
> --- mmotm-0915.orig/mm/memcontrol.c
> +++ mmotm-0915/mm/memcontrol.c
> @@ -1575,7 +1575,8 @@ bool mem_cgroup_handle_oom(struct mem_cg
>   * small, we check MEM_CGROUP_ON_MOVE percpu value and detect there are
>   * possibility of race condition. If there is, we take a lock.
>   */
> -void mem_cgroup_update_file_mapped(struct page *page, int val)
> +
> +static void mem_cgroup_update_file_stat(struct page *page, int idx, int val)
>  {
>  	struct mem_cgroup *mem;
>  	struct page_cgroup *pc = lookup_page_cgroup(page);
> @@ -1597,13 +1598,18 @@ void mem_cgroup_update_file_mapped(struc
>  		if (!mem || !PageCgroupUsed(pc))
>  			goto out;
>  	}
> -	if (val > 0) {
> -		this_cpu_inc(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
> -		SetPageCgroupFileMapped(pc);
> -	} else {
> -		this_cpu_dec(mem->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]);
> -		if (!page_mapped(page)) /* for race between dec->inc counter */
> +
> +	this_cpu_add(mem->stat->count[idx], val);
> +
> +	switch (idx) {
> +	case MEM_CGROUP_STAT_FILE_MAPPED:
> +		if (val > 0)
> +			SetPageCgroupFileMapped(pc);
> +		else if (!page_mapped(page))
>  			ClearPageCgroupFileMapped(pc);
> +		break;
> +	default:
> +		BUG();
>  	}
>  
>  out:
> @@ -1613,6 +1619,11 @@ out:
>  	return;
>  }
>  
> +void mem_cgroup_update_file_mapped(struct page *page, int val)
> +{
> +	mem_cgroup_update_file_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, val);
> +}
> +
>  /*
>   * size of first charge trial. "32" comes from vmscan.c's magic value.
>   * TODO: maybe necessary to use big numbers in big irons.

Reviewed-by: Greg Thelen <gthelen@google.com>

--
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] 3+ messages in thread

end of thread, other threads:[~2010-09-22 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-22  5:08 [PATCH][-mm] memcg: generic filestat update interface KAMEZAWA Hiroyuki
2010-09-22  9:19 ` Balbir Singh
2010-09-22 17:50 ` Greg Thelen

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