From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with ESMTP id 63B43900086 for ; Wed, 13 Apr 2011 14:47:04 -0400 (EDT) Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p3DIl04L032337 for ; Wed, 13 Apr 2011 11:47:00 -0700 Received: from qwb7 (qwb7.prod.google.com [10.241.193.71]) by hpaq6.eem.corp.google.com with ESMTP id p3DIi2U6012155 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 13 Apr 2011 11:46:59 -0700 Received: by qwb7 with SMTP id 7so592426qwb.12 for ; Wed, 13 Apr 2011 11:46:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110413173036.0756873d.kamezawa.hiroyu@jp.fujitsu.com> References: <1302678187-24154-1-git-send-email-yinghan@google.com> <1302678187-24154-4-git-send-email-yinghan@google.com> <20110413173036.0756873d.kamezawa.hiroyu@jp.fujitsu.com> Date: Wed, 13 Apr 2011 11:46:58 -0700 Message-ID: Subject: Re: [PATCH V3 3/7] New APIs to adjust per-memcg wmarks From: Ying Han Content-Type: multipart/alternative; boundary=000e0cd68ee0ce764104a0d13b96 Sender: owner-linux-mm@kvack.org List-ID: To: KAMEZAWA Hiroyuki Cc: Pavel Emelyanov , Balbir Singh , Daisuke Nishimura , Li Zefan , Mel Gorman , Christoph Lameter , Johannes Weiner , Rik van Riel , Hugh Dickins , KOSAKI Motohiro , Tejun Heo , Michal Hocko , Andrew Morton , Dave Hansen , linux-mm@kvack.org --000e0cd68ee0ce764104a0d13b96 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Apr 13, 2011 at 1:30 AM, KAMEZAWA Hiroyuki < kamezawa.hiroyu@jp.fujitsu.com> wrote: > On Wed, 13 Apr 2011 00:03:03 -0700 > Ying Han wrote: > > > Add wmark_ratio and reclaim_wmarks APIs per-memcg. The wmark_ratio > > adjusts the internal low/high wmark calculation and the reclaim_wmarks > > exports the current value of watermarks. By default, the wmark_ratio is > > set to 0 and the watermarks are equal to the hard_limit(limit_in_bytes). > > > > $ cat /dev/cgroup/A/memory.wmark_ratio > > 0 > > > > $ cat /dev/cgroup/A/memory.limit_in_bytes > > 524288000 > > > > $ echo 80 >/dev/cgroup/A/memory.wmark_ratio > > > > $ cat /dev/cgroup/A/memory.reclaim_wmarks > > low_wmark 393216000 > > high_wmark 419430400 > > > > I think havig _ratio_ will finally leads us to a tragedy as dirty_ratio, > a complicated interface. > > For memcg, I'd like to have only _bytes. > > And, as I wrote in previous mail, how about setting _distance_ ? > > memory.low_wmark_distance_in_bytes .... # hard_limit - low_wmark. > memory.high_wmark_distance_in_bytes ... # hard_limit - high_wmark. > > Anwyay, percent is too big unit. > Replied to your comment on "Add per memcg reclaim watermarks". I have no problem to make the wmark individual tunable. One thing to confirm before making the change is to have: memory.low_wmark_distance_in_bytes .... # min(hard_limit, soft_limit) - > low_wmark > memory.high_wmark_distance_in_bytes ... # min(hard_limit, soft_limit) - > high_wmark. > And also, some checks on soft_limit are needed. If "soft_limit" == 0, use hard_limit --Ying > Thanks, > -Kame > > > > changelog v3..v2: > > 1. replace the "min_free_kbytes" api with "wmark_ratio". This is part of > > feedbacks > > > > Signed-off-by: Ying Han > > --- > > mm/memcontrol.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 files changed, 49 insertions(+), 0 deletions(-) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index 664cdc5..36ae377 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -3983,6 +3983,31 @@ static int mem_cgroup_swappiness_write(struct > cgroup *cgrp, struct cftype *cft, > > return 0; > > } > > > > +static u64 mem_cgroup_wmark_ratio_read(struct cgroup *cgrp, struct > cftype *cft) > > +{ > > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); > > + > > + return get_wmark_ratio(memcg); > > +} > > + > > +static int mem_cgroup_wmark_ratio_write(struct cgroup *cgrp, struct > cftype *cfg, > > + u64 val) > > +{ > > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); > > + struct mem_cgroup *parent; > > + > > + if (cgrp->parent == NULL) > > + return -EINVAL; > > + > > + parent = mem_cgroup_from_cont(cgrp->parent); > > + > > + memcg->wmark_ratio = val; > > + > > + setup_per_memcg_wmarks(memcg); > > + return 0; > > + > > +} > > + > > static void __mem_cgroup_threshold(struct mem_cgroup *memcg, bool swap) > > { > > struct mem_cgroup_threshold_ary *t; > > @@ -4274,6 +4299,21 @@ static void mem_cgroup_oom_unregister_event(struct > cgroup *cgrp, > > mutex_unlock(&memcg_oom_mutex); > > } > > > > +static int mem_cgroup_wmark_read(struct cgroup *cgrp, > > + struct cftype *cft, struct cgroup_map_cb *cb) > > +{ > > + struct mem_cgroup *mem = mem_cgroup_from_cont(cgrp); > > + u64 low_wmark, high_wmark; > > + > > + low_wmark = res_counter_read_u64(&mem->res, RES_LOW_WMARK_LIMIT); > > + high_wmark = res_counter_read_u64(&mem->res, RES_HIGH_WMARK_LIMIT); > > + > > + cb->fill(cb, "low_wmark", low_wmark); > > + cb->fill(cb, "high_wmark", high_wmark); > > + > > + return 0; > > +} > > + > > static int mem_cgroup_oom_control_read(struct cgroup *cgrp, > > struct cftype *cft, struct cgroup_map_cb *cb) > > { > > @@ -4377,6 +4417,15 @@ static struct cftype mem_cgroup_files[] = { > > .unregister_event = mem_cgroup_oom_unregister_event, > > .private = MEMFILE_PRIVATE(_OOM_TYPE, OOM_CONTROL), > > }, > > + { > > + .name = "wmark_ratio", > > + .write_u64 = mem_cgroup_wmark_ratio_write, > > + .read_u64 = mem_cgroup_wmark_ratio_read, > > + }, > > + { > > + .name = "reclaim_wmarks", > > + .read_map = mem_cgroup_wmark_read, > > + }, > > }; > > > > #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP > > -- > > 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 > > > > --000e0cd68ee0ce764104a0d13b96 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Wed, Apr 13, 2011 at 1:30 AM, KAMEZAW= A Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
On Wed, 13 Apr 2011 00:03:03 -0700
Ying Han <yinghan@google.com&g= t; wrote:

> Add wmark_ratio and reclaim_wmarks APIs per-memcg. The wmark_ratio
> adjusts the internal low/high wmark calculation and the reclaim_wmarks=
> exports the current value of watermarks. By default, the wmark_ratio i= s
> set to 0 and the watermarks are equal to the hard_limit(limit_in_bytes= ).
>
> $ cat /dev/cgroup/A/memory.wmark_ratio
> 0
>
> $ cat /dev/cgroup/A/memory.limit_in_bytes
> 524288000
>
> $ echo 80 >/dev/cgroup/A/memory.wmark_ratio
>
> $ cat /dev/cgroup/A/memory.reclaim_wmarks
> low_wmark 393216000
> high_wmark 419430400
>

I think havig _ratio_ will finally leads us to a tragedy as dirty_rat= io,
a complicated interface.

For memcg, I'd like to have only _bytes.

And, as I wrote in previous mail, how about setting _distance_ ?

=A0 memory.low_wmark_distance_in_bytes .... # hard_limit - low_wmark.
=A0 memory.high_wmark_distance_in_bytes ... # hard_limit - high_wmark.

Anwyay, percent is too big unit.

Replie= d to your comment on "Add per memcg reclaim watermarks". I have n= o problem to make the
wmark individual tunable. One thing to conf= irm before making the change is to have:


me= mory.low_wmark_distance_in_bytes .... # min(hard_limit, soft_limit) - low_w= mark
me= mory.high_wmark_distance_in_bytes ... # min(hard_limit, soft_limit) - high_= wmark.

And also, some checks on soft_li= mit are needed. If "soft_limit" =3D=3D 0, use hard_limit

--Ying=A0
=A0
Thanks,
-Kame


> changelog v3..v2:
> 1. replace the "min_free_kbytes" api with "wmark_ratio&= quot;. This is part of
> feedbacks
>
> Signed-off-by: Ying Han <ying= han@google.com>
> ---
> =A0mm/memcontrol.c | =A0 49 ++++++++++++++++++++++++++++++++++++++++++= +++++++
> =A01 files changed, 49 insertions(+), 0 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 664cdc5..36ae377 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -3983,6 +3983,31 @@ static int mem_cgroup_swappiness_write(struct c= group *cgrp, struct cftype *cft,
> =A0 =A0 =A0 return 0;
> =A0}
>
> +static u64 mem_cgroup_wmark_ratio_read(struct cgroup *cgrp, struct cf= type *cft)
> +{
> + =A0 =A0 struct mem_cgroup *memcg =3D mem_cgroup_from_cont(cgrp);
> +
> + =A0 =A0 return get_wmark_ratio(memcg);
> +}
> +
> +static int mem_cgroup_wmark_ratio_write(struct cgroup *cgrp, struct c= ftype *cfg,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0u= 64 val)
> +{
> + =A0 =A0 struct mem_cgroup *memcg =3D mem_cgroup_from_cont(cgrp);
> + =A0 =A0 struct mem_cgroup *parent;
> +
> + =A0 =A0 if (cgrp->parent =3D=3D NULL)
> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL;
> +
> + =A0 =A0 parent =3D mem_cgroup_from_cont(cgrp->parent);
> +
> + =A0 =A0 memcg->wmark_ratio =3D val;
> +
> + =A0 =A0 setup_per_memcg_wmarks(memcg);
> + =A0 =A0 return 0;
> +
> +}
> +
> =A0static void __mem_cgroup_threshold(struct mem_cgroup *memcg, bool s= wap)
> =A0{
> =A0 =A0 =A0 struct mem_cgroup_threshold_ary *t;
> @@ -4274,6 +4299,21 @@ static void mem_cgroup_oom_unregister_event(str= uct cgroup *cgrp,
> =A0 =A0 =A0 mutex_unlock(&memcg_oom_mutex);
> =A0}
>
> +static int mem_cgroup_wmark_read(struct cgroup *cgrp,
> + =A0 =A0 struct cftype *cft, =A0struct cgroup_map_cb *cb)
> +{
> + =A0 =A0 struct mem_cgroup *mem =3D mem_cgroup_from_cont(cgrp);
> + =A0 =A0 u64 low_wmark, high_wmark;
> +
> + =A0 =A0 low_wmark =3D res_counter_read_u64(&mem->res, RES_LOW= _WMARK_LIMIT);
> + =A0 =A0 high_wmark =3D res_counter_read_u64(&mem->res, RES_HI= GH_WMARK_LIMIT);
> +
> + =A0 =A0 cb->fill(cb, "low_wmark", low_wmark);
> + =A0 =A0 cb->fill(cb, "high_wmark", high_wmark);
> +
> + =A0 =A0 return 0;
> +}
> +
> =A0static int mem_cgroup_oom_control_read(struct cgroup *cgrp,
> =A0 =A0 =A0 struct cftype *cft, =A0struct cgroup_map_cb *cb)
> =A0{
> @@ -4377,6 +4417,15 @@ static struct cftype mem_cgroup_files[] =3D { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 .unregister_event =3D mem_cgroup_oom_unreg= ister_event,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 .private =3D MEMFILE_PRIVATE(_OOM_TYPE, OO= M_CONTROL),
> =A0 =A0 =A0 },
> + =A0 =A0 {
> + =A0 =A0 =A0 =A0 =A0 =A0 .name =3D "wmark_ratio",
> + =A0 =A0 =A0 =A0 =A0 =A0 .write_u64 =3D mem_cgroup_wmark_ratio_write,=
> + =A0 =A0 =A0 =A0 =A0 =A0 .read_u64 =3D mem_cgroup_wmark_ratio_read, > + =A0 =A0 },
> + =A0 =A0 {
> + =A0 =A0 =A0 =A0 =A0 =A0 .name =3D "reclaim_wmarks",
> + =A0 =A0 =A0 =A0 =A0 =A0 .read_map =3D mem_cgroup_wmark_read,
> + =A0 =A0 },
> =A0};
>
> =A0#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
> --
> 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>
>


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