From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail190.messagelabs.com (mail190.messagelabs.com [216.82.249.51]) by kanga.kvack.org (Postfix) with ESMTP id CCBCB900086 for ; Fri, 15 Apr 2011 00:36:35 -0400 (EDT) Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id p3F4aVkO018332 for ; Thu, 14 Apr 2011 21:36:31 -0700 Received: from qyk2 (qyk2.prod.google.com [10.241.83.130]) by wpaz24.hot.corp.google.com with ESMTP id p3F4aUkH019090 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 14 Apr 2011 21:36:30 -0700 Received: by qyk2 with SMTP id 2so1578176qyk.9 for ; Thu, 14 Apr 2011 21:36:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110415094007.9cfc4a7d.kamezawa.hiroyu@jp.fujitsu.com> References: <1302821669-29862-1-git-send-email-yinghan@google.com> <1302821669-29862-6-git-send-email-yinghan@google.com> <20110415094007.9cfc4a7d.kamezawa.hiroyu@jp.fujitsu.com> Date: Thu, 14 Apr 2011 21:36:28 -0700 Message-ID: Subject: Re: [PATCH V4 05/10] Implement the select_victim_node within memcg. From: Ying Han Content-Type: multipart/alternative; boundary=00248c6a84cadd63ea04a0ed9533 Sender: owner-linux-mm@kvack.org List-ID: To: KAMEZAWA Hiroyuki Cc: KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , Andrew Morton , Li Zefan , Mel Gorman , Christoph Lameter , Johannes Weiner , Rik van Riel , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai , linux-mm@kvack.org --00248c6a84cadd63ea04a0ed9533 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Apr 14, 2011 at 5:40 PM, KAMEZAWA Hiroyuki < kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Thu, 14 Apr 2011 15:54:24 -0700 > Ying Han wrote: > > > This add the mechanism for background reclaim which we remember the > > last scanned node and always starting from the next one each time. > > The simple round-robin fasion provide the fairness between nodes for > > each memcg. > > > > changelog v4..v3: > > 1. split off from the per-memcg background reclaim patch. > > > > Signed-off-by: Ying Han > > Yeah, looks nice. Thank you for splitting. > > > > --- > > include/linux/memcontrol.h | 3 +++ > > mm/memcontrol.c | 40 > ++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 43 insertions(+), 0 deletions(-) > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > index f7ffd1f..d4ff7f2 100644 > > --- a/include/linux/memcontrol.h > > +++ b/include/linux/memcontrol.h > > @@ -88,6 +88,9 @@ extern int mem_cgroup_init_kswapd(struct mem_cgroup > *mem, > > struct kswapd *kswapd_p); > > extern void mem_cgroup_clear_kswapd(struct mem_cgroup *mem); > > extern wait_queue_head_t *mem_cgroup_kswapd_wait(struct mem_cgroup > *mem); > > +extern int mem_cgroup_last_scanned_node(struct mem_cgroup *mem); > > +extern int mem_cgroup_select_victim_node(struct mem_cgroup *mem, > > + const nodemask_t *nodes); > > > > static inline > > int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup > *cgroup) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index c4e1904..e22351a 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -279,6 +279,11 @@ struct mem_cgroup { > > u64 high_wmark_distance; > > u64 low_wmark_distance; > > > > + /* While doing per cgroup background reclaim, we cache the > > + * last node we reclaimed from > > + */ > > + int last_scanned_node; > > + > > wait_queue_head_t *kswapd_wait; > > }; > > > > @@ -1536,6 +1541,32 @@ static int mem_cgroup_hierarchical_reclaim(struct > mem_cgroup *root_mem, > > } > > > > /* > > + * Visit the first node after the last_scanned_node of @mem and use that > to > > + * reclaim free pages from. > > + */ > > +int > > +mem_cgroup_select_victim_node(struct mem_cgroup *mem, const nodemask_t > *nodes) > > +{ > > + int next_nid; > > + int last_scanned; > > + > > + last_scanned = mem->last_scanned_node; > > + > > + /* Initial stage and start from node0 */ > > + if (last_scanned == -1) > > + next_nid = 0; > > + else > > + next_nid = next_node(last_scanned, *nodes); > > + > > IIUC, mem->last_scanned_node should be initialized to MAX_NUMNODES. > Then, we can remove above check. > make sense. will make the change on next post. --Ying > > Thanks, > -Kame > > > + if (next_nid == MAX_NUMNODES) > > + next_nid = first_node(*nodes); > > + > > + mem->last_scanned_node = next_nid; > > + > > + return next_nid; > > +} > > + > > +/* > > * Check OOM-Killer is already running under our hierarchy. > > * If someone is running, return false. > > */ > > @@ -4693,6 +4724,14 @@ wait_queue_head_t *mem_cgroup_kswapd_wait(struct > mem_cgroup *mem) > > return mem->kswapd_wait; > > } > > > > +int mem_cgroup_last_scanned_node(struct mem_cgroup *mem) > > +{ > > + if (!mem) > > + return -1; > > + > > + return mem->last_scanned_node; > > +} > > + > > static int mem_cgroup_soft_limit_tree_init(void) > > { > > struct mem_cgroup_tree_per_node *rtpn; > > @@ -4768,6 +4807,7 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct > cgroup *cont) > > res_counter_init(&mem->memsw, NULL); > > } > > mem->last_scanned_child = 0; > > + mem->last_scanned_node = -1; > > INIT_LIST_HEAD(&mem->oom_notify); > > > > if (parent) > > -- > > 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: email@kvack.org > > > > --00248c6a84cadd63ea04a0ed9533 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Thu, Apr 14, 2011 at 5:40 PM, KAMEZAW= A Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
On Thu, 14 Apr 2011 15:54:24 -0700
Ying Han <yinghan@google.com&g= t; wrote:

> This add the mechanism for background reclaim which we remember the > last scanned node and always starting from the next one each time.
> The simple round-robin fasion provide the fairness between nodes for > each memcg.
>
> changelog v4..v3:
> 1. split off from the per-memcg background reclaim patch.
>
> Signed-off-by: Ying Han <ying= han@google.com>

Yeah, looks nice. Thank you for splitting.


> ---
> =A0include/linux/memcontrol.h | =A0 =A03 +++
> =A0mm/memcontrol.c =A0 =A0 =A0 =A0 =A0 =A0| =A0 40 +++++++++++++++++++= +++++++++++++++++++++
> =A02 files changed, 43 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index f7ffd1f..d4ff7f2 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -88,6 +88,9 @@ extern int mem_cgroup_init_kswapd(struct mem_cgroup = *mem,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct= kswapd *kswapd_p);
> =A0extern void mem_cgroup_clear_kswapd(struct mem_cgroup *mem);
> =A0extern wait_queue_head_t *mem_cgroup_kswapd_wait(struct mem_cgroup = *mem);
> +extern int mem_cgroup_last_scanned_node(struct mem_cgroup *mem);
> +extern int mem_cgroup_select_victim_node(struct mem_cgroup *mem,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 const nodemask_t *nodes);
>
> =A0static inline
> =A0int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cg= roup *cgroup)
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c4e1904..e22351a 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -279,6 +279,11 @@ struct mem_cgroup {
> =A0 =A0 =A0 u64 high_wmark_distance;
> =A0 =A0 =A0 u64 low_wmark_distance;
>
> + =A0 =A0 /* While doing per cgroup background reclaim, we cache the > + =A0 =A0 =A0* last node we reclaimed from
> + =A0 =A0 =A0*/
> + =A0 =A0 int last_scanned_node;
> +
> =A0 =A0 =A0 wait_queue_head_t *kswapd_wait;
> =A0};
>
> @@ -1536,6 +1541,32 @@ static int mem_cgroup_hierarchical_reclaim(stru= ct mem_cgroup *root_mem,
> =A0}
>
> =A0/*
> + * Visit the first node after the last_scanned_node of @mem and use t= hat to
> + * reclaim free pages from.
> + */
> +int
> +mem_cgroup_select_victim_node(struct mem_cgroup *mem, const nodemask_= t *nodes)
> +{
> + =A0 =A0 int next_nid;
> + =A0 =A0 int last_scanned;
> +
> + =A0 =A0 last_scanned =3D mem->last_scanned_node;
> +
> + =A0 =A0 /* Initial stage and start from node0 */
> + =A0 =A0 if (last_scanned =3D=3D -1)
> + =A0 =A0 =A0 =A0 =A0 =A0 next_nid =3D 0;
> + =A0 =A0 else
> + =A0 =A0 =A0 =A0 =A0 =A0 next_nid =3D next_node(last_scanned, *nodes)= ;
> +

IIUC, mem->last_scanned_node should be initialized to MAX_NU= MNODES.
Then, we can remove above check.

make s= ense. will make the change on next post.

--Ying

Thanks,
-Kame

> + =A0 =A0 if (next_nid =3D=3D MAX_NUMNODES)
> + =A0 =A0 =A0 =A0 =A0 =A0 next_nid =3D first_node(*nodes);
> +
> + =A0 =A0 mem->last_scanned_node =3D next_nid;
> +
> + =A0 =A0 return next_nid;
> +}
> +
> +/*
> =A0 * Check OOM-Killer is already running under our hierarchy.
> =A0 * If someone is running, return false.
> =A0 */
> @@ -4693,6 +4724,14 @@ wait_queue_head_t *mem_cgroup_kswapd_wait(struc= t mem_cgroup *mem)
> =A0 =A0 =A0 return mem->kswapd_wait;
> =A0}
>
> +int mem_cgroup_last_scanned_node(struct mem_cgroup *mem)
> +{
> + =A0 =A0 if (!mem)
> + =A0 =A0 =A0 =A0 =A0 =A0 return -1;
> +
> + =A0 =A0 return mem->last_scanned_node;
> +}
> +
> =A0static int mem_cgroup_soft_limit_tree_init(void)
> =A0{
> =A0 =A0 =A0 struct mem_cgroup_tree_per_node *rtpn;
> @@ -4768,6 +4807,7 @@ mem_cgroup_create(struct cgroup_subsys *ss, stru= ct cgroup *cont)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 res_counter_init(&mem->memsw, NULL)= ;
> =A0 =A0 =A0 }
> =A0 =A0 =A0 mem->last_scanned_child =3D 0;
> + =A0 =A0 mem->last_scanned_node =3D -1;
> =A0 =A0 =A0 INIT_LIST_HEAD(&mem->oom_notify);
>
> =A0 =A0 =A0 if (parent)
> --
> 1.7.3.1
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in<= br> > the body to majordomo@kvack.org= . =A0For 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=3Dmailto:"dont@kvack.org"> emai= l@kvack.org </a>
>


--00248c6a84cadd63ea04a0ed9533-- -- 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: email@kvack.org