linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 2/2] add stats to monitor soft_limit reclaim
  2011-03-28 23:51 [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd Ying Han
@ 2011-03-28 23:51 ` Ying Han
  2011-03-29  1:22   ` KAMEZAWA Hiroyuki
  2011-03-29  2:32   ` Daisuke Nishimura
  0 siblings, 2 replies; 13+ messages in thread
From: Ying Han @ 2011-03-28 23:51 UTC (permalink / raw)
  To: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel,
	Minchan Kim, Daisuke Nishimura, Andrew Morton
  Cc: linux-mm

The stat is added:

/dev/cgroup/*/memory.stat
soft_steal:        - # of pages reclaimed from soft_limit hierarchical reclaim
total_soft_steal:  - # sum of all children's "soft_steal"

Change log v2...v1
1. removed the counting on number of skips on shrink_zone. This is due to the
change on the previous patch.

Signed-off-by: Ying Han <yinghan@google.com>
---
 Documentation/cgroups/memory.txt |    2 ++
 include/linux/memcontrol.h       |    5 +++++
 mm/memcontrol.c                  |   14 ++++++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index b6ed61c..dcda6c5 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -385,6 +385,7 @@ 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
+soft_steal	- # of pages reclaimed from global hierarchical reclaim
 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 +407,7 @@ 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_soft_steal	- sum of all children's "soft_steal"
 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"
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 01281ac..151ab40 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -115,6 +115,7 @@ struct zone_reclaim_stat*
 mem_cgroup_get_reclaim_stat_from_page(struct page *page);
 extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
 					struct task_struct *p);
+void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val);
 
 #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
 extern int do_swap_account;
@@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
 {
 }
 
+static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg,
+					 int val)
+{
+}
 #endif /* CONFIG_CGROUP_MEM_CONT */
 
 #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 67fff28..5e4aa41 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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_SOFT_STEAL,	/* # of pages reclaimed from */
+					/* oft reclaim               */
 	MEM_CGROUP_EVENTS_NSTATS,
 };
 /*
@@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
 	preempt_enable();
 }
 
+void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val)
+{
+	this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val);
+}
+
 static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem,
 					enum lru_list idx)
 {
@@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 						&nr_scanned);
 		nr_reclaimed += reclaimed;
 		*total_scanned += nr_scanned;
+
+		mem_cgroup_soft_steal(mz->mem, reclaimed);
+
 		spin_lock(&mctz->lock);
 
 		/*
@@ -3783,6 +3793,7 @@ enum {
 	MCS_PGPGIN,
 	MCS_PGPGOUT,
 	MCS_SWAP,
+	MCS_SOFT_STEAL,
 	MCS_INACTIVE_ANON,
 	MCS_ACTIVE_ANON,
 	MCS_INACTIVE_FILE,
@@ -3805,6 +3816,7 @@ struct {
 	{"pgpgin", "total_pgpgin"},
 	{"pgpgout", "total_pgpgout"},
 	{"swap", "total_swap"},
+	{"soft_steal", "total_soft_steal"},
 	{"inactive_anon", "total_inactive_anon"},
 	{"active_anon", "total_active_anon"},
 	{"inactive_file", "total_inactive_file"},
@@ -3833,6 +3845,8 @@ 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_SOFT_STEAL);
+	s->stat[MCS_SOFT_STEAL] += val;
 
 	/* per zone stat */
 	val = mem_cgroup_get_local_zonestat(mem, LRU_INACTIVE_ANON);
-- 
1.7.3.1

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim
  2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han
@ 2011-03-29  1:22   ` KAMEZAWA Hiroyuki
  2011-03-29  4:38     ` Ying Han
  2011-03-29  2:32   ` Daisuke Nishimura
  1 sibling, 1 reply; 13+ messages in thread
From: KAMEZAWA Hiroyuki @ 2011-03-29  1:22 UTC (permalink / raw)
  To: Ying Han
  Cc: KOSAKI Motohiro, Mel Gorman, Rik van Riel, Minchan Kim,
	Daisuke Nishimura, Andrew Morton, linux-mm

On Mon, 28 Mar 2011 16:51:10 -0700
Ying Han <yinghan@google.com> wrote:

> The stat is added:
> 
> /dev/cgroup/*/memory.stat
> soft_steal:        - # of pages reclaimed from soft_limit hierarchical reclaim
> total_soft_steal:  - # sum of all children's "soft_steal"
> 
> Change log v2...v1
> 1. removed the counting on number of skips on shrink_zone. This is due to the
> change on the previous patch.
> 
> Signed-off-by: Ying Han <yinghan@google.com>

Hmm...


> ---
>  Documentation/cgroups/memory.txt |    2 ++
>  include/linux/memcontrol.h       |    5 +++++
>  mm/memcontrol.c                  |   14 ++++++++++++++
>  3 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
> index b6ed61c..dcda6c5 100644
> --- a/Documentation/cgroups/memory.txt
> +++ b/Documentation/cgroups/memory.txt
> @@ -385,6 +385,7 @@ 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
> +soft_steal	- # of pages reclaimed from global hierarchical reclaim
>  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 +407,7 @@ 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_soft_steal	- sum of all children's "soft_steal"
>  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"
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 01281ac..151ab40 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -115,6 +115,7 @@ struct zone_reclaim_stat*
>  mem_cgroup_get_reclaim_stat_from_page(struct page *page);
>  extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
>  					struct task_struct *p);
> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val);
>  
>  #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
>  extern int do_swap_account;
> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
>  {
>  }
>  
> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg,
> +					 int val)
> +{
> +}
>  #endif /* CONFIG_CGROUP_MEM_CONT */
>  
>  #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 67fff28..5e4aa41 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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_SOFT_STEAL,	/* # of pages reclaimed from */
> +					/* oft reclaim               */
>  	MEM_CGROUP_EVENTS_NSTATS,
>  };
>  /*
> @@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
>  	preempt_enable();
>  }
>  
> +void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val)
> +{
> +	this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val);
> +}
> +
>  static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem,
>  					enum lru_list idx)
>  {
> @@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
>  						&nr_scanned);
>  		nr_reclaimed += reclaimed;
>  		*total_scanned += nr_scanned;
> +
> +		mem_cgroup_soft_steal(mz->mem, reclaimed);
> +

Here, you add "the number of reclaimed pages from the all descendants under me".
Could you move this to mem_cgroup_hierarchical_reclaim() ? Then, you can report
the correct stats even with hierarchy enabled.

Even if the value is recorded into hierarchy, total_steal will show total.

BTW, soft_scan and soft_total_scan aren't necessary ?

Thanks,
-Kame

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim
  2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han
  2011-03-29  1:22   ` KAMEZAWA Hiroyuki
@ 2011-03-29  2:32   ` Daisuke Nishimura
  2011-03-29  4:55     ` Ying Han
  1 sibling, 1 reply; 13+ messages in thread
From: Daisuke Nishimura @ 2011-03-29  2:32 UTC (permalink / raw)
  To: Ying Han
  Cc: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel,
	Minchan Kim, Andrew Morton, linux-mm, Daisuke Nishimura

On Mon, 28 Mar 2011 16:51:10 -0700
Ying Han <yinghan@google.com> wrote:

> The stat is added:
> 
> /dev/cgroup/*/memory.stat
> soft_steal:        - # of pages reclaimed from soft_limit hierarchical reclaim
> total_soft_steal:  - # sum of all children's "soft_steal"
> 
> Change log v2...v1
> 1. removed the counting on number of skips on shrink_zone. This is due to the
> change on the previous patch.
> 
> Signed-off-by: Ying Han <yinghan@google.com>
> ---
>  Documentation/cgroups/memory.txt |    2 ++
>  include/linux/memcontrol.h       |    5 +++++
>  mm/memcontrol.c                  |   14 ++++++++++++++
>  3 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
> index b6ed61c..dcda6c5 100644
> --- a/Documentation/cgroups/memory.txt
> +++ b/Documentation/cgroups/memory.txt
> @@ -385,6 +385,7 @@ 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
> +soft_steal	- # of pages reclaimed from global hierarchical reclaim
>  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 +407,7 @@ 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_soft_steal	- sum of all children's "soft_steal"
>  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"
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 01281ac..151ab40 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -115,6 +115,7 @@ struct zone_reclaim_stat*
>  mem_cgroup_get_reclaim_stat_from_page(struct page *page);
>  extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
>  					struct task_struct *p);
> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val);
>  
>  #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
>  extern int do_swap_account;
> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
>  {
>  }
>  
> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg,
> +					 int val)
> +{
> +}
>  #endif /* CONFIG_CGROUP_MEM_CONT */
>  
Do you use this function outside of memcontrol.c in future, right ?
I'm asking just for clarification, and I'm sorry if I miss some past discussions.

Thanks,
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim
  2011-03-29  1:22   ` KAMEZAWA Hiroyuki
@ 2011-03-29  4:38     ` Ying Han
  0 siblings, 0 replies; 13+ messages in thread
From: Ying Han @ 2011-03-29  4:38 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: KOSAKI Motohiro, Mel Gorman, Rik van Riel, Minchan Kim,
	Daisuke Nishimura, Andrew Morton, linux-mm

On Mon, Mar 28, 2011 at 6:22 PM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@jp.fujitsu.com> wrote:
> On Mon, 28 Mar 2011 16:51:10 -0700
> Ying Han <yinghan@google.com> wrote:
>
>> The stat is added:
>>
>> /dev/cgroup/*/memory.stat
>> soft_steal:        - # of pages reclaimed from soft_limit hierarchical reclaim
>> total_soft_steal:  - # sum of all children's "soft_steal"
>>
>> Change log v2...v1
>> 1. removed the counting on number of skips on shrink_zone. This is due to the
>> change on the previous patch.
>>
>> Signed-off-by: Ying Han <yinghan@google.com>
>
> Hmm...
>
>
>> ---
>>  Documentation/cgroups/memory.txt |    2 ++
>>  include/linux/memcontrol.h       |    5 +++++
>>  mm/memcontrol.c                  |   14 ++++++++++++++
>>  3 files changed, 21 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
>> index b6ed61c..dcda6c5 100644
>> --- a/Documentation/cgroups/memory.txt
>> +++ b/Documentation/cgroups/memory.txt
>> @@ -385,6 +385,7 @@ 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
>> +soft_steal   - # of pages reclaimed from global hierarchical reclaim
>>  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 +407,7 @@ 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_soft_steal     - sum of all children's "soft_steal"
>>  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"
>> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
>> index 01281ac..151ab40 100644
>> --- a/include/linux/memcontrol.h
>> +++ b/include/linux/memcontrol.h
>> @@ -115,6 +115,7 @@ struct zone_reclaim_stat*
>>  mem_cgroup_get_reclaim_stat_from_page(struct page *page);
>>  extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
>>                                       struct task_struct *p);
>> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val);
>>
>>  #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
>>  extern int do_swap_account;
>> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
>>  {
>>  }
>>
>> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg,
>> +                                      int val)
>> +{
>> +}
>>  #endif /* CONFIG_CGROUP_MEM_CONT */
>>
>>  #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 67fff28..5e4aa41 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -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_SOFT_STEAL,   /* # of pages reclaimed from */
>> +                                     /* oft reclaim               */
>>       MEM_CGROUP_EVENTS_NSTATS,
>>  };
>>  /*
>> @@ -624,6 +626,11 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
>>       preempt_enable();
>>  }
>>
>> +void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val)
>> +{
>> +     this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val);
>> +}
>> +
>>  static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem,
>>                                       enum lru_list idx)
>>  {
>> @@ -3326,6 +3333,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
>>                                               &nr_scanned);
>>               nr_reclaimed += reclaimed;
>>               *total_scanned += nr_scanned;
>> +
>> +             mem_cgroup_soft_steal(mz->mem, reclaimed);
>> +
>
> Here, you add "the number of reclaimed pages from the all descendants under me".
> Could you move this to mem_cgroup_hierarchical_reclaim() ? Then, you can report
> the correct stats even with hierarchy enabled.
>
> Even if the value is recorded into hierarchy, total_steal will show total.

good point. I will make that change.

>
> BTW, soft_scan and soft_total_scan aren't necessary ?

Hmm, i can look into that.

--Ying
>
> Thanks,
> -Kame
>
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] add stats to monitor soft_limit reclaim
  2011-03-29  2:32   ` Daisuke Nishimura
@ 2011-03-29  4:55     ` Ying Han
  0 siblings, 0 replies; 13+ messages in thread
From: Ying Han @ 2011-03-29  4:55 UTC (permalink / raw)
  To: Daisuke Nishimura
  Cc: KOSAKI Motohiro, KAMEZAWA Hiroyuki, Mel Gorman, Rik van Riel,
	Minchan Kim, Andrew Morton, linux-mm

On Mon, Mar 28, 2011 at 7:32 PM, Daisuke Nishimura
<nishimura@mxp.nes.nec.co.jp> wrote:
> On Mon, 28 Mar 2011 16:51:10 -0700
> Ying Han <yinghan@google.com> wrote:
>
>> The stat is added:
>>
>> /dev/cgroup/*/memory.stat
>> soft_steal:        - # of pages reclaimed from soft_limit hierarchical reclaim
>> total_soft_steal:  - # sum of all children's "soft_steal"
>>
>> Change log v2...v1
>> 1. removed the counting on number of skips on shrink_zone. This is due to the
>> change on the previous patch.
>>
>> Signed-off-by: Ying Han <yinghan@google.com>
>> ---
>>  Documentation/cgroups/memory.txt |    2 ++
>>  include/linux/memcontrol.h       |    5 +++++
>>  mm/memcontrol.c                  |   14 ++++++++++++++
>>  3 files changed, 21 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
>> index b6ed61c..dcda6c5 100644
>> --- a/Documentation/cgroups/memory.txt
>> +++ b/Documentation/cgroups/memory.txt
>> @@ -385,6 +385,7 @@ 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
>> +soft_steal   - # of pages reclaimed from global hierarchical reclaim
>>  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 +407,7 @@ 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_soft_steal     - sum of all children's "soft_steal"
>>  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"
>> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
>> index 01281ac..151ab40 100644
>> --- a/include/linux/memcontrol.h
>> +++ b/include/linux/memcontrol.h
>> @@ -115,6 +115,7 @@ struct zone_reclaim_stat*
>>  mem_cgroup_get_reclaim_stat_from_page(struct page *page);
>>  extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
>>                                       struct task_struct *p);
>> +void mem_cgroup_soft_steal(struct mem_cgroup *memcg, int val);
>>
>>  #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
>>  extern int do_swap_account;
>> @@ -356,6 +357,10 @@ static inline void mem_cgroup_split_huge_fixup(struct page *head,
>>  {
>>  }
>>
>> +static inline void mem_cgroup_soft_steal(struct mem_cgroup *memcg,
>> +                                      int val)
>> +{
>> +}
>>  #endif /* CONFIG_CGROUP_MEM_CONT */
>>
> Do you use this function outside of memcontrol.c in future, right ?
> I'm asking just for clarification, and I'm sorry if I miss some past discussions.

No, you didn't miss the discussion. That is a reasonable change. thanks

--Ying
>
> Thanks,
> 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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V2 0/2] memcg:add the soft_limit reclaim in global direct reclaim
@ 2011-05-02 16:50 Ying Han
  2011-05-02 16:50 ` [PATCH V2 1/2] Add " Ying Han
  2011-05-02 16:50 ` [PATCH V2 2/2] Add stats to monitor soft_limit reclaim Ying Han
  0 siblings, 2 replies; 13+ messages in thread
From: Ying Han @ 2011-05-02 16:50 UTC (permalink / raw)
  To: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Rik van Riel, Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai
  Cc: linux-mm

We recently added the change in global background reclaim which counts the
return value of soft_limit reclaim. Now this patch adds the similar logic
on global direct reclaim.

We should skip scanning global LRU on shrink_zone if soft_limit reclaim does
enough work. This is the first step where we start with counting the nr_scanned
and nr_reclaimed from soft_limit reclaim into global scan_control.

The patch is based on mmotm-2011-04-14-15-08 plus
0001-check-pageunevictable-in-lru_deactivate_fn.patch from Minchan.

Ying Han (2):
  Add the soft_limit reclaim in global direct reclaim.
  Add stats to monitor soft_limit reclaim

 Documentation/cgroups/memory.txt |   16 +++++++--
 mm/memcontrol.c                  |   68 ++++++++++++++++++++++++++++----------
 mm/vmscan.c                      |   16 ++++++++-
 3 files changed, 76 insertions(+), 24 deletions(-)

-- 
1.7.3.1

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V2 1/2] Add the soft_limit reclaim in global direct reclaim.
  2011-05-02 16:50 [PATCH V2 0/2] memcg:add the soft_limit reclaim in global direct reclaim Ying Han
@ 2011-05-02 16:50 ` Ying Han
  2011-05-02 16:52   ` Ying Han
  2011-05-03 13:25   ` Rik van Riel
  2011-05-02 16:50 ` [PATCH V2 2/2] Add stats to monitor soft_limit reclaim Ying Han
  1 sibling, 2 replies; 13+ messages in thread
From: Ying Han @ 2011-05-02 16:50 UTC (permalink / raw)
  To: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Rik van Riel, Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai
  Cc: linux-mm

We recently added the change in global background reclaim which
counts the return value of soft_limit reclaim. Now this patch adds
the similar logic on global direct reclaim.

We should skip scanning global LRU on shrink_zone if soft_limit reclaim
does enough work. This is the first step where we start with counting
the nr_scanned and nr_reclaimed from soft_limit reclaim into global
scan_control.

no change since v1.

Signed-off-by: Ying Han <yinghan@google.com>
---
 mm/vmscan.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index b3a569f..84003cc 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1959,11 +1959,14 @@ restart:
  * If a zone is deemed to be full of pinned pages then just give it a light
  * scan then give up on it.
  */
-static void shrink_zones(int priority, struct zonelist *zonelist,
+static unsigned long shrink_zones(int priority, struct zonelist *zonelist,
 					struct scan_control *sc)
 {
 	struct zoneref *z;
 	struct zone *zone;
+	unsigned long nr_soft_reclaimed;
+	unsigned long nr_soft_scanned;
+	unsigned long total_scanned = 0;
 
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 					gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -1980,8 +1983,17 @@ static void shrink_zones(int priority, struct zonelist *zonelist,
 				continue;	/* Let kswapd poll it */
 		}
 
+		nr_soft_scanned = 0;
+		nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone,
+							sc->order, sc->gfp_mask,
+							&nr_soft_scanned);
+		sc->nr_reclaimed += nr_soft_reclaimed;
+		total_scanned += nr_soft_scanned;
+
 		shrink_zone(priority, zone, sc);
 	}
+
+	return total_scanned;
 }
 
 static bool zone_reclaimable(struct zone *zone)
@@ -2045,7 +2057,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
 		sc->nr_scanned = 0;
 		if (!priority)
 			disable_swap_token();
-		shrink_zones(priority, zonelist, sc);
+		total_scanned += shrink_zones(priority, zonelist, sc);
 		/*
 		 * Don't shrink slabs when reclaiming memory from
 		 * over limit cgroups
-- 
1.7.3.1

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V2 2/2] Add stats to monitor soft_limit reclaim
  2011-05-02 16:50 [PATCH V2 0/2] memcg:add the soft_limit reclaim in global direct reclaim Ying Han
  2011-05-02 16:50 ` [PATCH V2 1/2] Add " Ying Han
@ 2011-05-02 16:50 ` Ying Han
  2011-05-02 16:52   ` Ying Han
  2011-05-03 13:54   ` Rik van Riel
  1 sibling, 2 replies; 13+ messages in thread
From: Ying Han @ 2011-05-02 16:50 UTC (permalink / raw)
  To: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Rik van Riel, Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai
  Cc: linux-mm

This patch extend the soft_limit reclaim stats to both global background
reclaim and global direct reclaim.

The following stats are renamed and added:

$cat /dev/cgroup/memory/A/memory.stat
soft_kswapd_steal 1053626
soft_kswapd_scan 1053693
soft_direct_steal 1481810
soft_direct_scan 1481996

changelog v2..v1:
1. rename the stats on soft_kswapd/direct_steal/scan.
2. fix the documentation to match the stat name.

Signed-off-by: Ying Han <yinghan@google.com>
---
 Documentation/cgroups/memory.txt |   16 +++++++--
 mm/memcontrol.c                  |   68 ++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 22 deletions(-)

diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index 0c40dab..575cf33 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -387,8 +387,14 @@ 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.
-soft_steal	- # of pages reclaimed from global hierarchical reclaim
-soft_scan	- # of pages scanned from global hierarchical reclaim
+soft_kswapd_steal- # of pages reclaimed in global hierarchical reclaim from
+		background reclaim
+soft_kswapd_scan - # of pages scanned in global hierarchical reclaim from
+		background reclaim
+soft_direct_steal- # of pages reclaimed in global hierarchical reclaim from
+		direct reclaim
+soft_direct_scan- # of pages scanned in global hierarchical reclaim from
+		direct reclaim
 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
@@ -412,8 +418,10 @@ 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_soft_steal	- sum of all children's "soft_steal"
-total_soft_scan		- sum of all children's "soft_scan"
+total_soft_kswapd_steal	- sum of all children's "soft_kswapd_steal"
+total_soft_kswapd_scan	- sum of all children's "soft_kswapd_scan"
+total_soft_direct_steal	- sum of all children's "soft_direct_steal"
+total_soft_direct_scan	- sum of all children's "soft_direct_scan"
 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"
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c2776f1..da1fb2b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -96,10 +96,14 @@ enum mem_cgroup_events_index {
 	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_SOFT_STEAL,	/* # of pages reclaimed from */
-					/* soft reclaim               */
-	MEM_CGROUP_EVENTS_SOFT_SCAN,	/* # of pages scanned from */
-					/* soft reclaim               */
+	MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL, /* # of pages reclaimed from */
+					/* soft reclaim in background reclaim */
+	MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN, /* # of pages scanned from */
+					/* soft reclaim in background reclaim */
+	MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL, /* # of pages reclaimed from */
+					/* soft reclaim in direct reclaim */
+	MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN, /* # of pages scanned from */
+					/* soft reclaim in direct reclaim */
 	MEM_CGROUP_EVENTS_NSTATS,
 };
 /*
@@ -640,14 +644,30 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
 	preempt_enable();
 }
 
-static void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val)
+static void mem_cgroup_soft_steal(struct mem_cgroup *mem, bool is_kswapd,
+				  int val)
 {
-	this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val);
+	if (is_kswapd)
+		this_cpu_add(
+			mem->stat->events[MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL],
+									val);
+	else
+		this_cpu_add(
+			mem->stat->events[MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL],
+									val);
 }
 
-static void mem_cgroup_soft_scan(struct mem_cgroup *mem, int val)
+static void mem_cgroup_soft_scan(struct mem_cgroup *mem, bool is_kswapd,
+				 int val)
 {
-	this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_SCAN], val);
+	if (is_kswapd)
+		this_cpu_add(
+			mem->stat->events[MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN],
+									val);
+	else
+		this_cpu_add(
+			mem->stat->events[MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN],
+									val);
 }
 
 static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem,
@@ -1495,6 +1515,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
 	bool noswap = reclaim_options & MEM_CGROUP_RECLAIM_NOSWAP;
 	bool shrink = reclaim_options & MEM_CGROUP_RECLAIM_SHRINK;
 	bool check_soft = reclaim_options & MEM_CGROUP_RECLAIM_SOFT;
+	bool is_kswapd = false;
 	unsigned long excess;
 	unsigned long nr_scanned;
 
@@ -1504,6 +1525,9 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
 	if (root_mem->memsw_is_minimum)
 		noswap = true;
 
+	if (current_is_kswapd())
+		is_kswapd = true;
+
 	while (1) {
 		victim = mem_cgroup_select_victim(root_mem);
 		if (victim == root_mem) {
@@ -1544,8 +1568,8 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
 				noswap, get_swappiness(victim), zone,
 				&nr_scanned);
 			*total_scanned += nr_scanned;
-			mem_cgroup_soft_steal(victim, ret);
-			mem_cgroup_soft_scan(victim, nr_scanned);
+			mem_cgroup_soft_steal(victim, is_kswapd, ret);
+			mem_cgroup_soft_scan(victim, is_kswapd, nr_scanned);
 		} else
 			ret = try_to_free_mem_cgroup_pages(victim, gfp_mask,
 						noswap, get_swappiness(victim));
@@ -3840,8 +3864,10 @@ enum {
 	MCS_SWAP,
 	MCS_PGFAULT,
 	MCS_PGMAJFAULT,
-	MCS_SOFT_STEAL,
-	MCS_SOFT_SCAN,
+	MCS_SOFT_KSWAPD_STEAL,
+	MCS_SOFT_KSWAPD_SCAN,
+	MCS_SOFT_DIRECT_STEAL,
+	MCS_SOFT_DIRECT_SCAN,
 	MCS_INACTIVE_ANON,
 	MCS_ACTIVE_ANON,
 	MCS_INACTIVE_FILE,
@@ -3866,8 +3892,10 @@ struct {
 	{"swap", "total_swap"},
 	{"pgfault", "total_pgfault"},
 	{"pgmajfault", "total_pgmajfault"},
-	{"soft_steal", "total_soft_steal"},
-	{"soft_scan", "total_soft_scan"},
+	{"soft_kswapd_steal", "total_soft_kswapd_steal"},
+	{"soft_kswapd_scan", "total_soft_kswapd_scan"},
+	{"soft_direct_steal", "total_soft_direct_steal"},
+	{"soft_direct_scan", "total_soft_direct_scan"},
 	{"inactive_anon", "total_inactive_anon"},
 	{"active_anon", "total_active_anon"},
 	{"inactive_file", "total_inactive_file"},
@@ -3896,10 +3924,14 @@ 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_SOFT_STEAL);
-	s->stat[MCS_SOFT_STEAL] += val;
-	val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_SCAN);
-	s->stat[MCS_SOFT_SCAN] += val;
+	val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL);
+	s->stat[MCS_SOFT_KSWAPD_STEAL] += val;
+	val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN);
+	s->stat[MCS_SOFT_KSWAPD_SCAN] += val;
+	val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL);
+	s->stat[MCS_SOFT_DIRECT_STEAL] += val;
+	val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN);
+	s->stat[MCS_SOFT_DIRECT_SCAN] += val;
 	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);
-- 
1.7.3.1

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 1/2] Add the soft_limit reclaim in global direct reclaim.
  2011-05-02 16:50 ` [PATCH V2 1/2] Add " Ying Han
@ 2011-05-02 16:52   ` Ying Han
  2011-05-03 13:25   ` Rik van Riel
  1 sibling, 0 replies; 13+ messages in thread
From: Ying Han @ 2011-05-02 16:52 UTC (permalink / raw)
  To: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Rik van Riel, Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai
  Cc: linux-mm, Hiroyuki Kamezawa

On Mon, May 2, 2011 at 9:50 AM, Ying Han <yinghan@google.com> wrote:
> We recently added the change in global background reclaim which
> counts the return value of soft_limit reclaim. Now this patch adds
> the similar logic on global direct reclaim.
>
> We should skip scanning global LRU on shrink_zone if soft_limit reclaim
> does enough work. This is the first step where we start with counting
> the nr_scanned and nr_reclaimed from soft_limit reclaim into global
> scan_control.
>
> no change since v1.
>
> Signed-off-by: Ying Han <yinghan@google.com>
> ---
>  mm/vmscan.c |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index b3a569f..84003cc 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1959,11 +1959,14 @@ restart:
>  * If a zone is deemed to be full of pinned pages then just give it a light
>  * scan then give up on it.
>  */
> -static void shrink_zones(int priority, struct zonelist *zonelist,
> +static unsigned long shrink_zones(int priority, struct zonelist *zonelist,
>                                        struct scan_control *sc)
>  {
>        struct zoneref *z;
>        struct zone *zone;
> +       unsigned long nr_soft_reclaimed;
> +       unsigned long nr_soft_scanned;
> +       unsigned long total_scanned = 0;
>
>        for_each_zone_zonelist_nodemask(zone, z, zonelist,
>                                        gfp_zone(sc->gfp_mask), sc->nodemask) {
> @@ -1980,8 +1983,17 @@ static void shrink_zones(int priority, struct zonelist *zonelist,
>                                continue;       /* Let kswapd poll it */
>                }
>
> +               nr_soft_scanned = 0;
> +               nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone,
> +                                                       sc->order, sc->gfp_mask,
> +                                                       &nr_soft_scanned);
> +               sc->nr_reclaimed += nr_soft_reclaimed;
> +               total_scanned += nr_soft_scanned;
> +
>                shrink_zone(priority, zone, sc);
>        }
> +
> +       return total_scanned;
>  }
>
>  static bool zone_reclaimable(struct zone *zone)
> @@ -2045,7 +2057,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
>                sc->nr_scanned = 0;
>                if (!priority)
>                        disable_swap_token();
> -               shrink_zones(priority, zonelist, sc);
> +               total_scanned += shrink_zones(priority, zonelist, sc);
>                /*
>                 * Don't shrink slabs when reclaiming memory from
>                 * over limit cgroups
> --
> 1.7.3.1
>
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] Add stats to monitor soft_limit reclaim
  2011-05-02 16:50 ` [PATCH V2 2/2] Add stats to monitor soft_limit reclaim Ying Han
@ 2011-05-02 16:52   ` Ying Han
  2011-05-03 13:54   ` Rik van Riel
  1 sibling, 0 replies; 13+ messages in thread
From: Ying Han @ 2011-05-02 16:52 UTC (permalink / raw)
  To: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Rik van Riel, Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai
  Cc: linux-mm, Hiroyuki Kamezawa

On Mon, May 2, 2011 at 9:50 AM, Ying Han <yinghan@google.com> wrote:
> This patch extend the soft_limit reclaim stats to both global background
> reclaim and global direct reclaim.
>
> The following stats are renamed and added:
>
> $cat /dev/cgroup/memory/A/memory.stat
> soft_kswapd_steal 1053626
> soft_kswapd_scan 1053693
> soft_direct_steal 1481810
> soft_direct_scan 1481996
>
> changelog v2..v1:
> 1. rename the stats on soft_kswapd/direct_steal/scan.
> 2. fix the documentation to match the stat name.
>
> Signed-off-by: Ying Han <yinghan@google.com>
> ---
>  Documentation/cgroups/memory.txt |   16 +++++++--
>  mm/memcontrol.c                  |   68 ++++++++++++++++++++++++++++----------
>  2 files changed, 62 insertions(+), 22 deletions(-)
>
> diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
> index 0c40dab..575cf33 100644
> --- a/Documentation/cgroups/memory.txt
> +++ b/Documentation/cgroups/memory.txt
> @@ -387,8 +387,14 @@ 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.
> -soft_steal     - # of pages reclaimed from global hierarchical reclaim
> -soft_scan      - # of pages scanned from global hierarchical reclaim
> +soft_kswapd_steal- # of pages reclaimed in global hierarchical reclaim from
> +               background reclaim
> +soft_kswapd_scan - # of pages scanned in global hierarchical reclaim from
> +               background reclaim
> +soft_direct_steal- # of pages reclaimed in global hierarchical reclaim from
> +               direct reclaim
> +soft_direct_scan- # of pages scanned in global hierarchical reclaim from
> +               direct reclaim
>  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
> @@ -412,8 +418,10 @@ 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_soft_steal       - sum of all children's "soft_steal"
> -total_soft_scan                - sum of all children's "soft_scan"
> +total_soft_kswapd_steal        - sum of all children's "soft_kswapd_steal"
> +total_soft_kswapd_scan - sum of all children's "soft_kswapd_scan"
> +total_soft_direct_steal        - sum of all children's "soft_direct_steal"
> +total_soft_direct_scan - sum of all children's "soft_direct_scan"
>  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"
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c2776f1..da1fb2b 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -96,10 +96,14 @@ enum mem_cgroup_events_index {
>        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_SOFT_STEAL,   /* # of pages reclaimed from */
> -                                       /* soft reclaim               */
> -       MEM_CGROUP_EVENTS_SOFT_SCAN,    /* # of pages scanned from */
> -                                       /* soft reclaim               */
> +       MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL, /* # of pages reclaimed from */
> +                                       /* soft reclaim in background reclaim */
> +       MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN, /* # of pages scanned from */
> +                                       /* soft reclaim in background reclaim */
> +       MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL, /* # of pages reclaimed from */
> +                                       /* soft reclaim in direct reclaim */
> +       MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN, /* # of pages scanned from */
> +                                       /* soft reclaim in direct reclaim */
>        MEM_CGROUP_EVENTS_NSTATS,
>  };
>  /*
> @@ -640,14 +644,30 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem,
>        preempt_enable();
>  }
>
> -static void mem_cgroup_soft_steal(struct mem_cgroup *mem, int val)
> +static void mem_cgroup_soft_steal(struct mem_cgroup *mem, bool is_kswapd,
> +                                 int val)
>  {
> -       this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_STEAL], val);
> +       if (is_kswapd)
> +               this_cpu_add(
> +                       mem->stat->events[MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL],
> +                                                                       val);
> +       else
> +               this_cpu_add(
> +                       mem->stat->events[MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL],
> +                                                                       val);
>  }
>
> -static void mem_cgroup_soft_scan(struct mem_cgroup *mem, int val)
> +static void mem_cgroup_soft_scan(struct mem_cgroup *mem, bool is_kswapd,
> +                                int val)
>  {
> -       this_cpu_add(mem->stat->events[MEM_CGROUP_EVENTS_SOFT_SCAN], val);
> +       if (is_kswapd)
> +               this_cpu_add(
> +                       mem->stat->events[MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN],
> +                                                                       val);
> +       else
> +               this_cpu_add(
> +                       mem->stat->events[MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN],
> +                                                                       val);
>  }
>
>  static unsigned long mem_cgroup_get_local_zonestat(struct mem_cgroup *mem,
> @@ -1495,6 +1515,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
>        bool noswap = reclaim_options & MEM_CGROUP_RECLAIM_NOSWAP;
>        bool shrink = reclaim_options & MEM_CGROUP_RECLAIM_SHRINK;
>        bool check_soft = reclaim_options & MEM_CGROUP_RECLAIM_SOFT;
> +       bool is_kswapd = false;
>        unsigned long excess;
>        unsigned long nr_scanned;
>
> @@ -1504,6 +1525,9 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
>        if (root_mem->memsw_is_minimum)
>                noswap = true;
>
> +       if (current_is_kswapd())
> +               is_kswapd = true;
> +
>        while (1) {
>                victim = mem_cgroup_select_victim(root_mem);
>                if (victim == root_mem) {
> @@ -1544,8 +1568,8 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
>                                noswap, get_swappiness(victim), zone,
>                                &nr_scanned);
>                        *total_scanned += nr_scanned;
> -                       mem_cgroup_soft_steal(victim, ret);
> -                       mem_cgroup_soft_scan(victim, nr_scanned);
> +                       mem_cgroup_soft_steal(victim, is_kswapd, ret);
> +                       mem_cgroup_soft_scan(victim, is_kswapd, nr_scanned);
>                } else
>                        ret = try_to_free_mem_cgroup_pages(victim, gfp_mask,
>                                                noswap, get_swappiness(victim));
> @@ -3840,8 +3864,10 @@ enum {
>        MCS_SWAP,
>        MCS_PGFAULT,
>        MCS_PGMAJFAULT,
> -       MCS_SOFT_STEAL,
> -       MCS_SOFT_SCAN,
> +       MCS_SOFT_KSWAPD_STEAL,
> +       MCS_SOFT_KSWAPD_SCAN,
> +       MCS_SOFT_DIRECT_STEAL,
> +       MCS_SOFT_DIRECT_SCAN,
>        MCS_INACTIVE_ANON,
>        MCS_ACTIVE_ANON,
>        MCS_INACTIVE_FILE,
> @@ -3866,8 +3892,10 @@ struct {
>        {"swap", "total_swap"},
>        {"pgfault", "total_pgfault"},
>        {"pgmajfault", "total_pgmajfault"},
> -       {"soft_steal", "total_soft_steal"},
> -       {"soft_scan", "total_soft_scan"},
> +       {"soft_kswapd_steal", "total_soft_kswapd_steal"},
> +       {"soft_kswapd_scan", "total_soft_kswapd_scan"},
> +       {"soft_direct_steal", "total_soft_direct_steal"},
> +       {"soft_direct_scan", "total_soft_direct_scan"},
>        {"inactive_anon", "total_inactive_anon"},
>        {"active_anon", "total_active_anon"},
>        {"inactive_file", "total_inactive_file"},
> @@ -3896,10 +3924,14 @@ 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_SOFT_STEAL);
> -       s->stat[MCS_SOFT_STEAL] += val;
> -       val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_SCAN);
> -       s->stat[MCS_SOFT_SCAN] += val;
> +       val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_KSWAPD_STEAL);
> +       s->stat[MCS_SOFT_KSWAPD_STEAL] += val;
> +       val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_KSWAPD_SCAN);
> +       s->stat[MCS_SOFT_KSWAPD_SCAN] += val;
> +       val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_DIRECT_STEAL);
> +       s->stat[MCS_SOFT_DIRECT_STEAL] += val;
> +       val = mem_cgroup_read_events(mem, MEM_CGROUP_EVENTS_SOFT_DIRECT_SCAN);
> +       s->stat[MCS_SOFT_DIRECT_SCAN] += val;
>        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);
> --
> 1.7.3.1
>
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 1/2] Add the soft_limit reclaim in global direct reclaim.
  2011-05-02 16:50 ` [PATCH V2 1/2] Add " Ying Han
  2011-05-02 16:52   ` Ying Han
@ 2011-05-03 13:25   ` Rik van Riel
  1 sibling, 0 replies; 13+ messages in thread
From: Rik van Riel @ 2011-05-03 13:25 UTC (permalink / raw)
  To: Ying Han
  Cc: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai, linux-mm

On 05/02/2011 12:50 PM, Ying Han wrote:
> We recently added the change in global background reclaim which
> counts the return value of soft_limit reclaim. Now this patch adds
> the similar logic on global direct reclaim.
>
> We should skip scanning global LRU on shrink_zone if soft_limit reclaim
> does enough work. This is the first step where we start with counting
> the nr_scanned and nr_reclaimed from soft_limit reclaim into global
> scan_control.

Would be nice to see that at some point, but simply counting
the amount reclaimed from the over softlimit groups is a good
start.

> no change since v1.
>
> Signed-off-by: Ying Han<yinghan@google.com>

Acked-by: Rik van Riel<riel@redhat.com>

-- 
All rights reversed

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] Add stats to monitor soft_limit reclaim
  2011-05-02 16:50 ` [PATCH V2 2/2] Add stats to monitor soft_limit reclaim Ying Han
  2011-05-02 16:52   ` Ying Han
@ 2011-05-03 13:54   ` Rik van Riel
  2011-05-03 16:59     ` Ying Han
  1 sibling, 1 reply; 13+ messages in thread
From: Rik van Riel @ 2011-05-03 13:54 UTC (permalink / raw)
  To: Ying Han
  Cc: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai, linux-mm

On 05/02/2011 12:50 PM, Ying Han wrote:
> This patch extend the soft_limit reclaim stats to both global background
> reclaim and global direct reclaim.
>
> The following stats are renamed and added:
>
> $cat /dev/cgroup/memory/A/memory.stat
> soft_kswapd_steal 1053626
> soft_kswapd_scan 1053693
> soft_direct_steal 1481810
> soft_direct_scan 1481996
>
> changelog v2..v1:
> 1. rename the stats on soft_kswapd/direct_steal/scan.
> 2. fix the documentation to match the stat name.

> Signed-off-by: Ying Han<yinghan@google.com>

Acked-by: Rik van Riel<riel@redhat.com>

I expect people to continue arguing over the names a little
longer, but feel free to keep my Acked-by: across the various
name changes :)

-- 
All rights reversed

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V2 2/2] Add stats to monitor soft_limit reclaim
  2011-05-03 13:54   ` Rik van Riel
@ 2011-05-03 16:59     ` Ying Han
  0 siblings, 0 replies; 13+ messages in thread
From: Ying Han @ 2011-05-03 16:59 UTC (permalink / raw)
  To: Rik van Riel
  Cc: KOSAKI Motohiro, Minchan Kim, Daisuke Nishimura, Balbir Singh,
	Tejun Heo, Pavel Emelyanov, KAMEZAWA Hiroyuki, Andrew Morton,
	Li Zefan, Mel Gorman, Christoph Lameter, Johannes Weiner,
	Hugh Dickins, Michal Hocko, Dave Hansen, Zhu Yanhai, linux-mm

On Tue, May 3, 2011 at 6:54 AM, Rik van Riel <riel@redhat.com> wrote:
> On 05/02/2011 12:50 PM, Ying Han wrote:
>>
>> This patch extend the soft_limit reclaim stats to both global background
>> reclaim and global direct reclaim.
>>
>> The following stats are renamed and added:
>>
>> $cat /dev/cgroup/memory/A/memory.stat
>> soft_kswapd_steal 1053626
>> soft_kswapd_scan 1053693
>> soft_direct_steal 1481810
>> soft_direct_scan 1481996
>>
>> changelog v2..v1:
>> 1. rename the stats on soft_kswapd/direct_steal/scan.
>> 2. fix the documentation to match the stat name.
>
>> Signed-off-by: Ying Han<yinghan@google.com>
>
> Acked-by: Rik van Riel<riel@redhat.com>
>
> I expect people to continue arguing over the names a little
> longer, but feel free to keep my Acked-by: across the various
> name changes :)

Hi Rik:

Thank you for reviewing and acking. Regarding the name, i think we are
reaching some stage. And my
current naming is following that as well. :)

--Ying
>
> --
> All rights reversed
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2011-05-03 16:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 16:50 [PATCH V2 0/2] memcg:add the soft_limit reclaim in global direct reclaim Ying Han
2011-05-02 16:50 ` [PATCH V2 1/2] Add " Ying Han
2011-05-02 16:52   ` Ying Han
2011-05-03 13:25   ` Rik van Riel
2011-05-02 16:50 ` [PATCH V2 2/2] Add stats to monitor soft_limit reclaim Ying Han
2011-05-02 16:52   ` Ying Han
2011-05-03 13:54   ` Rik van Riel
2011-05-03 16:59     ` Ying Han
  -- strict thread matches above, loose matches on Subject: below --
2011-03-28 23:51 [PATCH V2 0/2] Reduce reclaim from per-zone LRU in global kswapd Ying Han
2011-03-28 23:51 ` [PATCH V2 2/2] add stats to monitor soft_limit reclaim Ying Han
2011-03-29  1:22   ` KAMEZAWA Hiroyuki
2011-03-29  4:38     ` Ying Han
2011-03-29  2:32   ` Daisuke Nishimura
2011-03-29  4:55     ` Ying Han

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