All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mmotm] memcg: show swap usage in stat file
@ 2009-08-21  6:25 ` Daisuke Nishimura
  0 siblings, 0 replies; 8+ messages in thread
From: Daisuke Nishimura @ 2009-08-21  6:25 UTC (permalink / raw)
  To: LKML, linux-mm
  Cc: Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki, Daisuke Nishimura

We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
It would be useful for users to show swap usage in memory.stat file,
because they don't need calculate memsw.usage - res.usage to know swap usage.

Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
---
 mm/memcontrol.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8b06c05..ae80de0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2663,6 +2663,7 @@ enum {
 	MCS_MAPPED_FILE,
 	MCS_PGPGIN,
 	MCS_PGPGOUT,
+	MCS_SWAP,
 	MCS_INACTIVE_ANON,
 	MCS_ACTIVE_ANON,
 	MCS_INACTIVE_FILE,
@@ -2684,6 +2685,7 @@ struct {
 	{"mapped_file", "total_mapped_file"},
 	{"pgpgin", "total_pgpgin"},
 	{"pgpgout", "total_pgpgout"},
+	{"swap", "total_swap"},
 	{"inactive_anon", "total_inactive_anon"},
 	{"active_anon", "total_active_anon"},
 	{"inactive_file", "total_inactive_file"},
@@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
 	s->stat[MCS_PGPGIN] += val;
 	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
 	s->stat[MCS_PGPGOUT] += val;
+	if (do_swap_account) {
+		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
+		s->stat[MCS_SWAP] += val;
+	}
 
 	/* per zone stat */
 	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
@@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
 	memset(&mystat, 0, sizeof(mystat));
 	mem_cgroup_get_local_stat(mem_cont, &mystat);
 
-	for (i = 0; i < NR_MCS_STAT; i++)
+	for (i = 0; i < NR_MCS_STAT; i++) {
+		if (i == MCS_SWAP && !do_swap_account)
+			continue;
 		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
+	}
 
 	/* Hierarchical information */
 	{
@@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
 
 	memset(&mystat, 0, sizeof(mystat));
 	mem_cgroup_get_total_stat(mem_cont, &mystat);
-	for (i = 0; i < NR_MCS_STAT; i++)
+	for (i = 0; i < NR_MCS_STAT; i++) {
+		if (i == MCS_SWAP && !do_swap_account)
+			continue;
 		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
-
+	}
 
 #ifdef CONFIG_DEBUG_VM
 	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));

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

* [PATCH -mmotm] memcg: show swap usage in stat file
@ 2009-08-21  6:25 ` Daisuke Nishimura
  0 siblings, 0 replies; 8+ messages in thread
From: Daisuke Nishimura @ 2009-08-21  6:25 UTC (permalink / raw)
  To: LKML, linux-mm
  Cc: Andrew Morton, Balbir Singh, KAMEZAWA Hiroyuki, Daisuke Nishimura

We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
It would be useful for users to show swap usage in memory.stat file,
because they don't need calculate memsw.usage - res.usage to know swap usage.

Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
---
 mm/memcontrol.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8b06c05..ae80de0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2663,6 +2663,7 @@ enum {
 	MCS_MAPPED_FILE,
 	MCS_PGPGIN,
 	MCS_PGPGOUT,
+	MCS_SWAP,
 	MCS_INACTIVE_ANON,
 	MCS_ACTIVE_ANON,
 	MCS_INACTIVE_FILE,
@@ -2684,6 +2685,7 @@ struct {
 	{"mapped_file", "total_mapped_file"},
 	{"pgpgin", "total_pgpgin"},
 	{"pgpgout", "total_pgpgout"},
+	{"swap", "total_swap"},
 	{"inactive_anon", "total_inactive_anon"},
 	{"active_anon", "total_active_anon"},
 	{"inactive_file", "total_inactive_file"},
@@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
 	s->stat[MCS_PGPGIN] += val;
 	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
 	s->stat[MCS_PGPGOUT] += val;
+	if (do_swap_account) {
+		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
+		s->stat[MCS_SWAP] += val;
+	}
 
 	/* per zone stat */
 	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
@@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
 	memset(&mystat, 0, sizeof(mystat));
 	mem_cgroup_get_local_stat(mem_cont, &mystat);
 
-	for (i = 0; i < NR_MCS_STAT; i++)
+	for (i = 0; i < NR_MCS_STAT; i++) {
+		if (i == MCS_SWAP && !do_swap_account)
+			continue;
 		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
+	}
 
 	/* Hierarchical information */
 	{
@@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
 
 	memset(&mystat, 0, sizeof(mystat));
 	mem_cgroup_get_total_stat(mem_cont, &mystat);
-	for (i = 0; i < NR_MCS_STAT; i++)
+	for (i = 0; i < NR_MCS_STAT; i++) {
+		if (i == MCS_SWAP && !do_swap_account)
+			continue;
 		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
-
+	}
 
 #ifdef CONFIG_DEBUG_VM
 	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));

--
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 related	[flat|nested] 8+ messages in thread

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
  2009-08-21  6:25 ` Daisuke Nishimura
@ 2009-08-21  7:05   ` KAMEZAWA Hiroyuki
  -1 siblings, 0 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-08-21  7:05 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: LKML, linux-mm, Andrew Morton, Balbir Singh

On Fri, 21 Aug 2009 15:25:49 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> It would be useful for users to show swap usage in memory.stat file,
> because they don't need calculate memsw.usage - res.usage to know swap usage.
> 
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>

Indeed.
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


Thanks,
-Kame


> ---
>  mm/memcontrol.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8b06c05..ae80de0 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2663,6 +2663,7 @@ enum {
>  	MCS_MAPPED_FILE,
>  	MCS_PGPGIN,
>  	MCS_PGPGOUT,
> +	MCS_SWAP,
>  	MCS_INACTIVE_ANON,
>  	MCS_ACTIVE_ANON,
>  	MCS_INACTIVE_FILE,
> @@ -2684,6 +2685,7 @@ struct {
>  	{"mapped_file", "total_mapped_file"},
>  	{"pgpgin", "total_pgpgin"},
>  	{"pgpgout", "total_pgpgout"},
> +	{"swap", "total_swap"},
>  	{"inactive_anon", "total_inactive_anon"},
>  	{"active_anon", "total_active_anon"},
>  	{"inactive_file", "total_inactive_file"},
> @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
>  	s->stat[MCS_PGPGIN] += val;
>  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
>  	s->stat[MCS_PGPGOUT] += val;
> +	if (do_swap_account) {
> +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> +		s->stat[MCS_SWAP] += val;
> +	}
>  
>  	/* per zone stat */
>  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_local_stat(mem_cont, &mystat);
>  
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> +	}
>  
>  	/* Hierarchical information */
>  	{
> @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> -
> +	}
>  
>  #ifdef CONFIG_DEBUG_VM
>  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));
> 


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

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
@ 2009-08-21  7:05   ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2009-08-21  7:05 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: LKML, linux-mm, Andrew Morton, Balbir Singh

On Fri, 21 Aug 2009 15:25:49 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> It would be useful for users to show swap usage in memory.stat file,
> because they don't need calculate memsw.usage - res.usage to know swap usage.
> 
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>

Indeed.
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


Thanks,
-Kame


> ---
>  mm/memcontrol.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8b06c05..ae80de0 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2663,6 +2663,7 @@ enum {
>  	MCS_MAPPED_FILE,
>  	MCS_PGPGIN,
>  	MCS_PGPGOUT,
> +	MCS_SWAP,
>  	MCS_INACTIVE_ANON,
>  	MCS_ACTIVE_ANON,
>  	MCS_INACTIVE_FILE,
> @@ -2684,6 +2685,7 @@ struct {
>  	{"mapped_file", "total_mapped_file"},
>  	{"pgpgin", "total_pgpgin"},
>  	{"pgpgout", "total_pgpgout"},
> +	{"swap", "total_swap"},
>  	{"inactive_anon", "total_inactive_anon"},
>  	{"active_anon", "total_active_anon"},
>  	{"inactive_file", "total_inactive_file"},
> @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
>  	s->stat[MCS_PGPGIN] += val;
>  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
>  	s->stat[MCS_PGPGOUT] += val;
> +	if (do_swap_account) {
> +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> +		s->stat[MCS_SWAP] += val;
> +	}
>  
>  	/* per zone stat */
>  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_local_stat(mem_cont, &mystat);
>  
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> +	}
>  
>  	/* Hierarchical information */
>  	{
> @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> -
> +	}
>  
>  #ifdef CONFIG_DEBUG_VM
>  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));
> 

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

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
  2009-08-21  6:25 ` Daisuke Nishimura
@ 2009-08-21  9:35   ` Balbir Singh
  -1 siblings, 0 replies; 8+ messages in thread
From: Balbir Singh @ 2009-08-21  9:35 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki

* nishimura@mxp.nes.nec.co.jp <nishimura@mxp.nes.nec.co.jp> [2009-08-21 15:25:49]:

> We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> It would be useful for users to show swap usage in memory.stat file,
> because they don't need calculate memsw.usage - res.usage to know swap usage.
> 
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> ---
>  mm/memcontrol.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8b06c05..ae80de0 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2663,6 +2663,7 @@ enum {
>  	MCS_MAPPED_FILE,
>  	MCS_PGPGIN,
>  	MCS_PGPGOUT,
> +	MCS_SWAP,
>  	MCS_INACTIVE_ANON,
>  	MCS_ACTIVE_ANON,
>  	MCS_INACTIVE_FILE,
> @@ -2684,6 +2685,7 @@ struct {
>  	{"mapped_file", "total_mapped_file"},
>  	{"pgpgin", "total_pgpgin"},
>  	{"pgpgout", "total_pgpgout"},
> +	{"swap", "total_swap"},
>  	{"inactive_anon", "total_inactive_anon"},
>  	{"active_anon", "total_active_anon"},
>  	{"inactive_file", "total_inactive_file"},
> @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
>  	s->stat[MCS_PGPGIN] += val;
>  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
>  	s->stat[MCS_PGPGOUT] += val;
> +	if (do_swap_account) {
> +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> +		s->stat[MCS_SWAP] += val;
> +	}
> 
>  	/* per zone stat */
>  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_local_stat(mem_cont, &mystat);
> 
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;

May be worth encapsulating in a function like memcg_show_swapout

>  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> +	}
> 
>  	/* Hierarchical information */
>  	{
> @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> 
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> -
> +	}
> 
>  #ifdef CONFIG_DEBUG_VM
>  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));

Overall, looks good


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

-- 
	Balbir

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

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
@ 2009-08-21  9:35   ` Balbir Singh
  0 siblings, 0 replies; 8+ messages in thread
From: Balbir Singh @ 2009-08-21  9:35 UTC (permalink / raw)
  To: Daisuke Nishimura; +Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki

* nishimura@mxp.nes.nec.co.jp <nishimura@mxp.nes.nec.co.jp> [2009-08-21 15:25:49]:

> We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> It would be useful for users to show swap usage in memory.stat file,
> because they don't need calculate memsw.usage - res.usage to know swap usage.
> 
> Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> ---
>  mm/memcontrol.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8b06c05..ae80de0 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2663,6 +2663,7 @@ enum {
>  	MCS_MAPPED_FILE,
>  	MCS_PGPGIN,
>  	MCS_PGPGOUT,
> +	MCS_SWAP,
>  	MCS_INACTIVE_ANON,
>  	MCS_ACTIVE_ANON,
>  	MCS_INACTIVE_FILE,
> @@ -2684,6 +2685,7 @@ struct {
>  	{"mapped_file", "total_mapped_file"},
>  	{"pgpgin", "total_pgpgin"},
>  	{"pgpgout", "total_pgpgout"},
> +	{"swap", "total_swap"},
>  	{"inactive_anon", "total_inactive_anon"},
>  	{"active_anon", "total_active_anon"},
>  	{"inactive_file", "total_inactive_file"},
> @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
>  	s->stat[MCS_PGPGIN] += val;
>  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
>  	s->stat[MCS_PGPGOUT] += val;
> +	if (do_swap_account) {
> +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> +		s->stat[MCS_SWAP] += val;
> +	}
> 
>  	/* per zone stat */
>  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_local_stat(mem_cont, &mystat);
> 
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;

May be worth encapsulating in a function like memcg_show_swapout

>  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> +	}
> 
>  	/* Hierarchical information */
>  	{
> @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> 
>  	memset(&mystat, 0, sizeof(mystat));
>  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> -	for (i = 0; i < NR_MCS_STAT; i++)
> +	for (i = 0; i < NR_MCS_STAT; i++) {
> +		if (i == MCS_SWAP && !do_swap_account)
> +			continue;
>  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> -
> +	}
> 
>  #ifdef CONFIG_DEBUG_VM
>  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));

Overall, looks good


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

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

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
  2009-08-21  9:35   ` Balbir Singh
@ 2009-08-21 10:39     ` Daisuke Nishimura
  -1 siblings, 0 replies; 8+ messages in thread
From: Daisuke Nishimura @ 2009-08-21 10:39 UTC (permalink / raw)
  To: balbir
  Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki, d-nishimura,
	Daisuke Nishimura

On Fri, 21 Aug 2009 15:05:48 +0530
Balbir Singh <balbir@linux.vnet.ibm.com> wrote:

> * nishimura@mxp.nes.nec.co.jp <nishimura@mxp.nes.nec.co.jp> [2009-08-21 15:25:49]:
> 
> > We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> > It would be useful for users to show swap usage in memory.stat file,
> > because they don't need calculate memsw.usage - res.usage to know swap usage.
> > 
> > Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> > ---
> >  mm/memcontrol.c |   17 ++++++++++++++---
> >  1 files changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 8b06c05..ae80de0 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -2663,6 +2663,7 @@ enum {
> >  	MCS_MAPPED_FILE,
> >  	MCS_PGPGIN,
> >  	MCS_PGPGOUT,
> > +	MCS_SWAP,
> >  	MCS_INACTIVE_ANON,
> >  	MCS_ACTIVE_ANON,
> >  	MCS_INACTIVE_FILE,
> > @@ -2684,6 +2685,7 @@ struct {
> >  	{"mapped_file", "total_mapped_file"},
> >  	{"pgpgin", "total_pgpgin"},
> >  	{"pgpgout", "total_pgpgout"},
> > +	{"swap", "total_swap"},
> >  	{"inactive_anon", "total_inactive_anon"},
> >  	{"active_anon", "total_active_anon"},
> >  	{"inactive_file", "total_inactive_file"},
> > @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
> >  	s->stat[MCS_PGPGIN] += val;
> >  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
> >  	s->stat[MCS_PGPGOUT] += val;
> > +	if (do_swap_account) {
> > +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> > +		s->stat[MCS_SWAP] += val;
> > +	}
> > 
> >  	/* per zone stat */
> >  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> > @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> >  	memset(&mystat, 0, sizeof(mystat));
> >  	mem_cgroup_get_local_stat(mem_cont, &mystat);
> > 
> > -	for (i = 0; i < NR_MCS_STAT; i++)
> > +	for (i = 0; i < NR_MCS_STAT; i++) {
> > +		if (i == MCS_SWAP && !do_swap_account)
> > +			continue;
> 
> May be worth encapsulating in a function like memcg_show_swapout
> 
I tried it first, but I think it would be overkill a bit
and writing in open-coded would be more simple and making it
clear what we are doing.
So, I went this direction.

> >  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> > +	}
> > 
> >  	/* Hierarchical information */
> >  	{
> > @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> > 
> >  	memset(&mystat, 0, sizeof(mystat));
> >  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> > -	for (i = 0; i < NR_MCS_STAT; i++)
> > +	for (i = 0; i < NR_MCS_STAT; i++) {
> > +		if (i == MCS_SWAP && !do_swap_account)
> > +			continue;
> >  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> > -
> > +	}
> > 
> >  #ifdef CONFIG_DEBUG_VM
> >  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));
> 
> Overall, looks good
> 
> 
> Reviewed-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>  
Thank you.


Daisuke Nishimura.

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

* Re: [PATCH -mmotm] memcg: show swap usage in stat file
@ 2009-08-21 10:39     ` Daisuke Nishimura
  0 siblings, 0 replies; 8+ messages in thread
From: Daisuke Nishimura @ 2009-08-21 10:39 UTC (permalink / raw)
  To: balbir
  Cc: LKML, linux-mm, Andrew Morton, KAMEZAWA Hiroyuki, d-nishimura,
	Daisuke Nishimura

On Fri, 21 Aug 2009 15:05:48 +0530
Balbir Singh <balbir@linux.vnet.ibm.com> wrote:

> * nishimura@mxp.nes.nec.co.jp <nishimura@mxp.nes.nec.co.jp> [2009-08-21 15:25:49]:
> 
> > We now count MEM_CGROUP_STAT_SWAPOUT, so we can show swap usage.
> > It would be useful for users to show swap usage in memory.stat file,
> > because they don't need calculate memsw.usage - res.usage to know swap usage.
> > 
> > Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> > ---
> >  mm/memcontrol.c |   17 ++++++++++++++---
> >  1 files changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 8b06c05..ae80de0 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -2663,6 +2663,7 @@ enum {
> >  	MCS_MAPPED_FILE,
> >  	MCS_PGPGIN,
> >  	MCS_PGPGOUT,
> > +	MCS_SWAP,
> >  	MCS_INACTIVE_ANON,
> >  	MCS_ACTIVE_ANON,
> >  	MCS_INACTIVE_FILE,
> > @@ -2684,6 +2685,7 @@ struct {
> >  	{"mapped_file", "total_mapped_file"},
> >  	{"pgpgin", "total_pgpgin"},
> >  	{"pgpgout", "total_pgpgout"},
> > +	{"swap", "total_swap"},
> >  	{"inactive_anon", "total_inactive_anon"},
> >  	{"active_anon", "total_active_anon"},
> >  	{"inactive_file", "total_inactive_file"},
> > @@ -2708,6 +2710,10 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
> >  	s->stat[MCS_PGPGIN] += val;
> >  	val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
> >  	s->stat[MCS_PGPGOUT] += val;
> > +	if (do_swap_account) {
> > +		val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_SWAPOUT);
> > +		s->stat[MCS_SWAP] += val;
> > +	}
> > 
> >  	/* per zone stat */
> >  	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
> > @@ -2739,8 +2745,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> >  	memset(&mystat, 0, sizeof(mystat));
> >  	mem_cgroup_get_local_stat(mem_cont, &mystat);
> > 
> > -	for (i = 0; i < NR_MCS_STAT; i++)
> > +	for (i = 0; i < NR_MCS_STAT; i++) {
> > +		if (i == MCS_SWAP && !do_swap_account)
> > +			continue;
> 
> May be worth encapsulating in a function like memcg_show_swapout
> 
I tried it first, but I think it would be overkill a bit
and writing in open-coded would be more simple and making it
clear what we are doing.
So, I went this direction.

> >  		cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
> > +	}
> > 
> >  	/* Hierarchical information */
> >  	{
> > @@ -2753,9 +2762,11 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
> > 
> >  	memset(&mystat, 0, sizeof(mystat));
> >  	mem_cgroup_get_total_stat(mem_cont, &mystat);
> > -	for (i = 0; i < NR_MCS_STAT; i++)
> > +	for (i = 0; i < NR_MCS_STAT; i++) {
> > +		if (i == MCS_SWAP && !do_swap_account)
> > +			continue;
> >  		cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
> > -
> > +	}
> > 
> >  #ifdef CONFIG_DEBUG_VM
> >  	cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));
> 
> Overall, looks good
> 
> 
> Reviewed-by: Balbir Singh <balbir@linux.vnet.ibm.com>
>  
Thank you.


Daisuke Nishimura.

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

end of thread, other threads:[~2009-08-21 15:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-21  6:25 [PATCH -mmotm] memcg: show swap usage in stat file Daisuke Nishimura
2009-08-21  6:25 ` Daisuke Nishimura
2009-08-21  7:05 ` KAMEZAWA Hiroyuki
2009-08-21  7:05   ` KAMEZAWA Hiroyuki
2009-08-21  9:35 ` Balbir Singh
2009-08-21  9:35   ` Balbir Singh
2009-08-21 10:39   ` Daisuke Nishimura
2009-08-21 10:39     ` Daisuke Nishimura

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.