From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id D99FB900086 for ; Mon, 18 Apr 2011 13:31:55 -0400 (EDT) Received: from hpaq13.eem.corp.google.com (hpaq13.eem.corp.google.com [172.25.149.13]) by smtp-out.google.com with ESMTP id p3IHVqv7007550 for ; Mon, 18 Apr 2011 10:31:53 -0700 Received: from qwa26 (qwa26.prod.google.com [10.241.193.26]) by hpaq13.eem.corp.google.com with ESMTP id p3IHVmX6027873 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 18 Apr 2011 10:31:51 -0700 Received: by qwa26 with SMTP id 26so3869558qwa.14 for ; Mon, 18 Apr 2011 10:31:48 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1302909815-4362-1-git-send-email-yinghan@google.com> <1302909815-4362-8-git-send-email-yinghan@google.com> Date: Mon, 18 Apr 2011 10:31:47 -0700 Message-ID: Subject: Re: [PATCH V5 07/10] Add per-memcg zone "unreclaimable" From: Ying Han Content-Type: multipart/alternative; boundary=000e0cdfd08224bb4a04a134c41f Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim Cc: KOSAKI Motohiro , 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 , linux-mm@kvack.org --000e0cdfd08224bb4a04a134c41f Content-Type: text/plain; charset=ISO-8859-1 On Sun, Apr 17, 2011 at 9:27 PM, Minchan Kim wrote: > On Sat, Apr 16, 2011 at 8:23 AM, Ying Han wrote: > > After reclaiming each node per memcg, it checks mem_cgroup_watermark_ok() > > and breaks the priority loop if it returns true. The per-memcg zone will > > be marked as "unreclaimable" if the scanning rate is much greater than > the > > reclaiming rate on the per-memcg LRU. The bit is cleared when there is a > > page charged to the memcg being freed. Kswapd breaks the priority loop if > > all the zones are marked as "unreclaimable". > > > > changelog v5..v4: > > 1. reduce the frequency of updating mz->unreclaimable bit by using the > existing > > memcg batch in task struct. > > 2. add new function mem_cgroup_mz_clear_unreclaimable() for recoganizing > zone. > > > > changelog v4..v3: > > 1. split off from the per-memcg background reclaim patch in V3. > > > > Signed-off-by: Ying Han > > --- > > include/linux/memcontrol.h | 40 ++++++++++++++ > > include/linux/sched.h | 1 + > > include/linux/swap.h | 2 + > > mm/memcontrol.c | 130 > +++++++++++++++++++++++++++++++++++++++++++- > > mm/vmscan.c | 19 +++++++ > > 5 files changed, 191 insertions(+), 1 deletions(-) > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > index d4ff7f2..b18435d 100644 > > --- a/include/linux/memcontrol.h > > +++ b/include/linux/memcontrol.h > > @@ -155,6 +155,14 @@ static inline void mem_cgroup_dec_page_stat(struct > page *page, > > unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int > order, > > gfp_t gfp_mask); > > u64 mem_cgroup_get_limit(struct mem_cgroup *mem); > > +bool mem_cgroup_zone_reclaimable(struct mem_cgroup *mem, int nid, int > zid); > > +bool mem_cgroup_mz_unreclaimable(struct mem_cgroup *mem, struct zone > *zone); > > +void mem_cgroup_mz_set_unreclaimable(struct mem_cgroup *mem, struct zone > *zone); > > +void mem_cgroup_clear_unreclaimable(struct mem_cgroup *mem, struct page > *page); > > +void mem_cgroup_mz_clear_unreclaimable(struct mem_cgroup *mem, > > + struct zone *zone); > > +void mem_cgroup_mz_pages_scanned(struct mem_cgroup *mem, struct zone* > zone, > > + unsigned long nr_scanned); > > > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > void mem_cgroup_split_huge_fixup(struct page *head, struct page *tail); > > @@ -345,6 +353,38 @@ static inline void mem_cgroup_dec_page_stat(struct > page *page, > > { > > } > > > > +static inline bool mem_cgroup_zone_reclaimable(struct mem_cgroup *mem, > int nid, > > + int zid) > > +{ > > + return false; > > +} > > + > > +static inline bool mem_cgroup_mz_unreclaimable(struct mem_cgroup *mem, > > + struct zone *zone) > > +{ > > + return false; > > +} > > + > > +static inline void mem_cgroup_mz_set_unreclaimable(struct mem_cgroup > *mem, > > + struct zone > *zone) > > +{ > > +} > > + > > +static inline void mem_cgroup_clear_unreclaimable(struct mem_cgroup > *mem, > > + struct page > *page) > > +{ > > +} > > + > > +static inline void mem_cgroup_mz_clear_unreclaimable(struct mem_cgroup > *mem, > > + struct zone > *zone); > > +{ > > +} > > +static inline void mem_cgroup_mz_pages_scanned(struct mem_cgroup *mem, > > + struct zone *zone, > > + unsigned long nr_scanned) > > +{ > > +} > > + > > static inline > > unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int > order, > > gfp_t gfp_mask) > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index 98fc7ed..3370c5a 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -1526,6 +1526,7 @@ struct task_struct { > > struct mem_cgroup *memcg; /* target memcg of uncharge */ > > unsigned long nr_pages; /* uncharged usage */ > > unsigned long memsw_nr_pages; /* uncharged mem+swap usage > */ > > + struct zone *zone; /* a zone page is last uncharged */ > > } memcg_batch; > > #endif > > }; > > diff --git a/include/linux/swap.h b/include/linux/swap.h > > index 17e0511..319b800 100644 > > --- a/include/linux/swap.h > > +++ b/include/linux/swap.h > > @@ -160,6 +160,8 @@ enum { > > SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ > > }; > > > > +#define ZONE_RECLAIMABLE_RATE 6 > > + > > You can use ZONE_RECLAIMABLE_RATE in zone_reclaimable, too. > If you want to separate rate of memcg and global, please clear macro > name like ZONE_MEMCG_RECLAIMABLE_RATE. > For now I will leave them as the same value. Will make the change in the next post. Thanks --Ying > > -- > Kind regards, > Minchan Kim > --000e0cdfd08224bb4a04a134c41f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Sun, Apr 17, 2011 at 9:27 PM, Minchan= Kim <minchan= .kim@gmail.com> wrote:
On Sat, Apr 16, 2011 at 8:23 AM, Ying Han= <yinghan@google.com> wrote= :
> After reclaiming each node per memcg, it checks mem_cgroup_watermark_o= k()
> and breaks the priority loop if it returns true. The per-memcg zone wi= ll
> be marked as "unreclaimable" if the scanning rate is much gr= eater than the
> reclaiming rate on the per-memcg LRU. The bit is cleared when there is= a
> page charged to the memcg being freed. Kswapd breaks the priority loop= if
> all the zones are marked as "unreclaimable".
>
> changelog v5..v4:
> 1. reduce the frequency of updating mz->unreclaimable bit by using = the existing
> memcg batch in task struct.
> 2. add new function mem_cgroup_mz_clear_unreclaimable() for recoganizi= ng zone.
>
> changelog v4..v3:
> 1. split off from the per-memcg background reclaim patch in V3.
>
> Signed-off-by: Ying Han <ying= han@google.com>
> ---
> =A0include/linux/memcontrol.h | =A0 40 ++++++++++++++
> =A0include/linux/sched.h =A0 =A0 =A0| =A0 =A01 +
> =A0include/linux/swap.h =A0 =A0 =A0 | =A0 =A02 +
> =A0mm/memcontrol.c =A0 =A0 =A0 =A0 =A0 =A0| =A0130 +++++++++++++++++++= ++++++++++++++++++++++++-
> =A0mm/vmscan.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 19 +++++++
> =A05 files changed, 191 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index d4ff7f2..b18435d 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -155,6 +155,14 @@ static inline void mem_cgroup_dec_page_stat(struc= t page *page,
> =A0unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int = order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0gfp_t gfp_mask);
> =A0u64 mem_cgroup_get_limit(struct mem_cgroup *mem);
> +bool mem_cgroup_zone_reclaimable(struct mem_cgroup *mem, int nid, int= zid);
> +bool mem_cgroup_mz_unreclaimable(struct mem_cgroup *mem, struct zone = *zone);
> +void mem_cgroup_mz_set_unreclaimable(struct mem_cgroup *mem, struct z= one *zone);
> +void mem_cgroup_clear_unreclaimable(struct mem_cgroup *mem, struct pa= ge *page);
> +void mem_cgroup_mz_clear_unreclaimable(struct mem_cgroup *mem,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 struct zone *zone);
> +void mem_cgroup_mz_pages_scanned(struct mem_cgroup *mem, struct zone*= zone,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 unsigned long nr_scanned);
>
> =A0#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> =A0void mem_cgroup_split_huge_fixup(struct page *head, struct page *ta= il);
> @@ -345,6 +353,38 @@ static inline void mem_cgroup_dec_page_stat(struc= t page *page,
> =A0{
> =A0}
>
> +static inline bool mem_cgroup_zone_reclaimable(struct mem_cgroup *mem= , int nid,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int zid)
> +{
> + =A0 =A0 =A0 return false;
> +}
> +
> +static inline bool mem_cgroup_mz_unreclaimable(struct mem_cgroup *mem= ,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 struct zone *zone)
> +{
> + =A0 =A0 =A0 return false;
> +}
> +
> +static inline void mem_cgroup_mz_set_unreclaimable(struct mem_cgroup = *mem,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct zone *zone)
> +{
> +}
> +
> +static inline void mem_cgroup_clear_unreclaimable(struct mem_cgroup *= mem,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct page *page)
> +{
> +}
> +
> +static inline void mem_cgroup_mz_clear_unreclaimable(struct mem_cgrou= p *mem,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct zone *zone);
> +{
> +}
> +static inline void mem_cgroup_mz_pages_scanned(struct mem_cgroup *mem= ,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 struct zone *zone,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 unsigned long nr_scanned)
> +{
> +}
> +
> =A0static inline
> =A0unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int = order,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0gfp_t gfp_mask)
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 98fc7ed..3370c5a 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1526,6 +1526,7 @@ struct task_struct {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct mem_cgroup *memcg; /* target mem= cg of uncharge */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long nr_pages; /* uncharged us= age */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long memsw_nr_pages; /* unchar= ged mem+swap usage */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct zone *zone; /* a zone page is las= t uncharged */
> =A0 =A0 =A0 =A0} memcg_batch;
> =A0#endif
> =A0};
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 17e0511..319b800 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -160,6 +160,8 @@ enum {
> =A0 =A0 =A0 =A0SWP_SCANNING =A0 =A0=3D (1 << 8), =A0 =A0 /* refc= ount in scan_swap_map */
> =A0};
>
> +#define ZONE_RECLAIMABLE_RATE 6
> +

You can use ZONE_RECLAIMABLE_RATE in zone_reclaimable, too.
If you want to separate rate of memcg and global, please clear macro
name like ZONE_MEMCG_RECLAIMABLE_RATE.

= For now I will leave them as the same value. Will make the change in the ne= xt post.

Thanks

--Ying=A0=

--
Kind regards,
Minchan Kim

--000e0cdfd08224bb4a04a134c41f-- -- 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