linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ying Han <yinghan@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Michal Hocko <mhocko@suse.cz>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	Johannes Weiner <jweiner@redhat.com>,
	"minchan.kim@gmail.com" <minchan.kim@gmail.com>
Subject: Re: [PATCH 1/7] memcg: add high/low watermark to res_counter
Date: Tue, 10 May 2011 00:09:27 -0700	[thread overview]
Message-ID: <BANLkTi=n+R021tqEztKWJyE5q51kRa=epg@mail.gmail.com> (raw)
In-Reply-To: <20110510062731.GE16531@cmpxchg.org>

On Mon, May 9, 2011 at 11:27 PM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> On Mon, May 09, 2011 at 09:51:43PM -0700, Ying Han wrote:
>> On Mon, May 9, 2011 at 3:18 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
>> > On Mon, May 09, 2011 at 04:10:47PM +0900, KAMEZAWA Hiroyuki wrote:
>> >> On Sun, 8 May 2011 22:40:47 -0700
>> >> Ying Han <yinghan@google.com> wrote:
>> >> > Using the
>> >> > limit to calculate the wmarks is straight-forward since doing
>> >> > background reclaim reduces the latency spikes under direct reclaim.
>> >> > The direct reclaim is triggered while the usage is hitting the limit.
>> >> >
>> >> > This is different from the "soft_limit" which is based on the usage
>> >> > and we don't want to reinvent the soft_limit implementation.
>> >> >
>> >> Yes, this is a different feature.
>> >>
>> >>
>> >> The discussion here is how to make APIs for "shrink_to" and "shrink_over", ok ?
>> >>
>> >> I think there are 3 candidates.
>> >>
>> >>   1. using distance to limit.
>> >>      memory.shrink_to_distance
>> >>            - memory will be freed to 'limit - shrink_to_distance'.
>> >>      memory.shrink_over_distance
>> >>            - memory will be freed when usage > 'limit - shrink_over_distance'
>> >>
>> >>      Pros.
>> >>       - Both of shrink_over and shirnk_to can be determined by users.
>> >>       - Can keep stable distance to limit even when limit is changed.
>> >>      Cons.
>> >>       - complicated and seems not natural.
>> >>       - hierarchy support will be very difficult.
>> >>
>> >>   2. using bare value
>> >>      memory.shrink_to
>> >>            - memory will be freed to this 'shirnk_to'
>> >>      memory.shrink_from
>> >>            - memory will be freed when usage over this value.
>> >>      Pros.
>> >>       - Both of shrink_over and shrink)to can be determined by users.
>> >>       - easy to understand, straightforward.
>> >>       - hierarchy support will be easy.
>> >>      Cons.
>> >>       - The user may need to change this value when he changes the limit.
>> >>
>> >>
>> >>   3. using only 'shrink_to'
>> >>      memory.shrink_to
>> >>            - memory will be freed to this value when the usage goes over this vaue
>> >>              to some extent (determined by the system.)
>> >>
>> >>      Pros.
>> >>       - easy interface.
>> >>       - hierarchy support will be easy.
>> >>       - bad configuration check is very easy.
>> >>      Cons.
>> >>       - The user may beed to change this value when he changes the limit.
>> >>
>> >>
>> >> Then, I now vote for 3 because hierarchy support is easiest and enough handy for
>> >> real use.
>> >
>> > 3. looks best to me as well.
>> >
>> > What I am wondering, though: we already have a limit to push back
>> > memcgs when we need memory, the soft limit.  The 'need for memory' is
>> > currently defined as global memory pressure, which we know may be too
>> > late.  The problem is not having no limit, the problem is that we want
>> > to control the time of when this limit is enforced.  So instead of
>> > adding another limit, could we instead add a knob like
>> >
>> >        memory.force_async_soft_reclaim
>> >
>> > that asynchroneously pushes back to the soft limit instead of having
>> > another, separate limit to configure?
>> >
>> > Pros:
>> > - easy interface
>> > - limit already existing
>> > - hierarchy support already existing
>> > - bad configuration check already existing
>> > Cons:
>> > - ?
>>
>> Are we proposing to set the target of per-memcg background reclaim to
>> be the soft_limit?
>
> Yes, if memory.force_async_soft_reclaim is set.
>
>> If so, i would highly doubt for that. The
>> logic of background reclaim is to start reclaiming memory before
>> reaching the hard_limit, and stops whence
>> it makes enough progress. The motivation is to reduce the times for
>> memcg hitting direct reclaim and that is quite different from
>> the design of soft_limit. The soft_limit is designed to serve the
>> over-commit environment where memory can be shared across memcgs
>> until the global memory pressure. There is no correlation between that
>> to the watermark based background reclaim.
>
> Your whole argument for the knob so far has been that you want to use
> it to proactively reduce memory usage, and I argued that it has
> nothing to do with watermark reclaim.  This is exactly why I have been
> fighting making the watermark configurable and abuse it for that.



>
>> Making the soft_limit as target for background reclaim will make extra
>> memory pressure when not necessary. So I don't have issue to have
>> the tunable later and set the watermark equal to the soft_limit, but
>> using it as alternative to the watermarks is not straight-forward to
>> me at
>> this point.
>
> Please read my above proposal again, noone suggested to replace the
> watermark with the soft limit.
>
> 1. The watermark is always in place, computed by the kernel alone, and
> triggers background targetted reclaim when breached.

>
> 2. The soft limit is enforced as usual upon memory pressure.

>
> 3. In addition, the soft limit is enforced by background reclaim if
> memory.force_async_soft_reclaim is set.
>
> Thus, you can use 3. if you foresee memory pressure and want to
> proactively push back a memcg to the soft limit.

Ok, thanks a lot for the clarification. I was confused at the
beginning of using the force_async_soft_reclaim as the alternatives to
background reclaim watermarks. So, the proposal looks good to me and
the computed watermarks based on the hard_limit by default
should work most of the time w/o the configurable tunable.

--Ying

>

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

  reply	other threads:[~2011-05-10  7:09 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-25  9:25 [PATCH 0/7] memcg background reclaim , yet another one KAMEZAWA Hiroyuki
2011-04-25  9:28 ` [PATCH 1/7] memcg: add high/low watermark to res_counter KAMEZAWA Hiroyuki
2011-04-26 17:54   ` Ying Han
2011-04-29 13:33   ` Michal Hocko
2011-05-01  6:06     ` KOSAKI Motohiro
2011-05-03  6:49       ` Michal Hocko
2011-05-03  7:45         ` KOSAKI Motohiro
2011-05-03  8:25           ` Michal Hocko
2011-05-03 17:01             ` Ying Han
2011-05-04  8:58               ` Michal Hocko
2011-05-04 17:16                 ` Ying Han
2011-05-05  6:59                   ` Michal Hocko
2011-05-06  5:28                     ` KAMEZAWA Hiroyuki
2011-05-06 14:22                       ` Johannes Weiner
2011-05-09  0:21                         ` KAMEZAWA Hiroyuki
2011-05-09  5:47                           ` Ying Han
2011-05-09  9:58                           ` Johannes Weiner
2011-05-09  9:59                             ` KAMEZAWA Hiroyuki
2011-05-10  4:43                             ` Ying Han
2011-05-09  5:40                       ` Ying Han
2011-05-09  7:10                         ` KAMEZAWA Hiroyuki
2011-05-09 10:18                           ` Johannes Weiner
2011-05-09 12:49                             ` Michal Hocko
2011-05-09 23:49                               ` KAMEZAWA Hiroyuki
2011-05-10  4:39                                 ` Ying Han
2011-05-10  4:51                             ` Ying Han
2011-05-10  6:27                               ` Johannes Weiner
2011-05-10  7:09                                 ` Ying Han [this message]
2011-05-04  3:55             ` KOSAKI Motohiro
2011-05-04  8:55               ` Michal Hocko
2011-05-09  3:24                 ` KOSAKI Motohiro
2011-05-02  9:07   ` Balbir Singh
2011-05-06  5:30     ` KAMEZAWA Hiroyuki
2011-04-25  9:29 ` [PATCH 2/7] memcg high watermark interface KAMEZAWA Hiroyuki
2011-04-25 22:36   ` Ying Han
2011-04-25  9:31 ` [PATCH 3/7] memcg: select victim node in round robin KAMEZAWA Hiroyuki
2011-04-25  9:34 ` [PATCH 4/7] memcg fix scan ratio with small memcg KAMEZAWA Hiroyuki
2011-04-25 17:35   ` Ying Han
2011-04-26  1:43     ` KAMEZAWA Hiroyuki
2011-04-25  9:36 ` [PATCH 5/7] memcg bgreclaim core KAMEZAWA Hiroyuki
2011-04-26  4:59   ` Ying Han
2011-04-26  5:08     ` KAMEZAWA Hiroyuki
2011-04-26 23:15       ` Ying Han
2011-04-27  0:10         ` KAMEZAWA Hiroyuki
2011-04-27  1:01           ` KAMEZAWA Hiroyuki
2011-04-26 18:37   ` Ying Han
2011-04-25  9:40 ` [PATCH 6/7] memcg add zone_all_unreclaimable KAMEZAWA Hiroyuki
2011-04-25  9:42 ` [PATCH 7/7] memcg watermark reclaim workqueue KAMEZAWA Hiroyuki
2011-04-26 23:19   ` Ying Han
2011-04-27  0:31     ` KAMEZAWA Hiroyuki
2011-04-27  3:40       ` Ying Han
2011-04-25  9:43 ` [PATCH 8/7] memcg : reclaim statistics KAMEZAWA Hiroyuki
2011-04-26  5:35   ` Ying Han
2011-04-25  9:49 ` [PATCH 0/7] memcg background reclaim , yet another one KAMEZAWA Hiroyuki
2011-04-25 10:14 ` KAMEZAWA Hiroyuki
2011-04-25 22:21   ` Ying Han
2011-04-26  1:38     ` KAMEZAWA Hiroyuki
2011-04-26  7:19       ` Ying Han
2011-04-26  7:43         ` KAMEZAWA Hiroyuki
2011-04-26  8:43           ` Ying Han
2011-04-26  8:47             ` KAMEZAWA Hiroyuki
2011-04-26 23:08               ` Ying Han
2011-04-27  0:34                 ` KAMEZAWA Hiroyuki
2011-04-27  1:19                   ` Ying Han
2011-04-28  3:55               ` Ying Han
2011-04-28  4:05                 ` KAMEZAWA Hiroyuki
2011-05-02  7:02     ` Balbir Singh
2011-05-02  6:09 ` Balbir Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=n+R021tqEztKWJyE5q51kRa=epg@mail.gmail.com' \
    --to=yinghan@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=hannes@cmpxchg.org \
    --cc=jweiner@redhat.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=minchan.kim@gmail.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox