linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: [mmotm][PATCH 2/2] memcg: reduce calls for soft limit excess
Date: Wed, 2 Sep 2009 14:20:01 +0900	[thread overview]
Message-ID: <20090902142001.35cae908.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090902141639.565175d3.nishimura@mxp.nes.nec.co.jp>

On Wed, 2 Sep 2009 14:16:39 +0900
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> wrote:

> On Wed, 2 Sep 2009 09:35:51 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > In charge path, usage_in_excess is calculated repeatedly and
> > it takes res_counter's spin_lock every time.
> > 
> Hmm, mem_cgroup_update_tree() is called in both charge and uncharge path.
> So, this patch have effect on both path, doesn't it ?
> 
> > This patch removes unnecessary calls for res_count_soft_limit_excess.
> > 
> > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> > ---
> >  mm/memcontrol.c |   31 +++++++++++++++----------------
> >  1 file changed, 15 insertions(+), 16 deletions(-)
> > 
> > Index: mmotm-2.6.31-Aug27/mm/memcontrol.c
> > ===================================================================
> > --- mmotm-2.6.31-Aug27.orig/mm/memcontrol.c
> > +++ mmotm-2.6.31-Aug27/mm/memcontrol.c
> > @@ -313,7 +313,8 @@ soft_limit_tree_from_page(struct page *p
> >  static void
> >  __mem_cgroup_insert_exceeded(struct mem_cgroup *mem,
> >  				struct mem_cgroup_per_zone *mz,
> > -				struct mem_cgroup_tree_per_zone *mctz)
> > +				struct mem_cgroup_tree_per_zone *mctz,
> > +				unsigned long new_usage_in_excess)
> It might be a nitpick, shouldn't it be unsigned long long ?
> 
Ouch, yes. I'll post fixed one, today.
Thank you for pointing out.

-Kame

> Otherwise, it looks good to me.
> 
> 	Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> 
> Thanks,
> Daisuke Nishimura.
> 
> >  {
> >  	struct rb_node **p = &mctz->rb_root.rb_node;
> >  	struct rb_node *parent = NULL;
> > @@ -322,7 +323,9 @@ __mem_cgroup_insert_exceeded(struct mem_
> >  	if (mz->on_tree)
> >  		return;
> >  
> > -	mz->usage_in_excess = res_counter_soft_limit_excess(&mem->res);
> > +	mz->usage_in_excess = new_usage_in_excess;
> > +	if (!mz->usage_in_excess)
> > +		return;
> >  	while (*p) {
> >  		parent = *p;
> >  		mz_node = rb_entry(parent, struct mem_cgroup_per_zone,
> > @@ -382,7 +385,7 @@ static bool mem_cgroup_soft_limit_check(
> >  
> >  static void mem_cgroup_update_tree(struct mem_cgroup *mem, struct page *page)
> >  {
> > -	unsigned long long new_usage_in_excess;
> > +	unsigned long long excess;
> >  	struct mem_cgroup_per_zone *mz;
> >  	struct mem_cgroup_tree_per_zone *mctz;
> >  	int nid = page_to_nid(page);
> > @@ -395,25 +398,21 @@ static void mem_cgroup_update_tree(struc
> >  	 */
> >  	for (; mem; mem = parent_mem_cgroup(mem)) {
> >  		mz = mem_cgroup_zoneinfo(mem, nid, zid);
> > -		new_usage_in_excess =
> > -			res_counter_soft_limit_excess(&mem->res);
> > +		excess = res_counter_soft_limit_excess(&mem->res);
> >  		/*
> >  		 * We have to update the tree if mz is on RB-tree or
> >  		 * mem is over its softlimit.
> >  		 */
> > -		if (new_usage_in_excess || mz->on_tree) {
> > +		if (excess || mz->on_tree) {
> >  			spin_lock(&mctz->lock);
> >  			/* if on-tree, remove it */
> >  			if (mz->on_tree)
> >  				__mem_cgroup_remove_exceeded(mem, mz, mctz);
> >  			/*
> > -			 * if over soft limit, insert again. mz->usage_in_excess
> > -			 * will be updated properly.
> > +			 * Insert again. mz->usage_in_excess will be updated.
> > +			 * If excess is 0, no tree ops.
> >  			 */
> > -			if (new_usage_in_excess)
> > -				__mem_cgroup_insert_exceeded(mem, mz, mctz);
> > -			else
> > -				mz->usage_in_excess = 0;
> > +			__mem_cgroup_insert_exceeded(mem, mz, mctz, excess);
> >  			spin_unlock(&mctz->lock);
> >  		}
> >  	}
> > @@ -2216,6 +2215,7 @@ unsigned long mem_cgroup_soft_limit_recl
> >  	unsigned long reclaimed;
> >  	int loop = 0;
> >  	struct mem_cgroup_tree_per_zone *mctz;
> > +	unsigned long long excess;
> >  
> >  	if (order > 0)
> >  		return 0;
> > @@ -2260,9 +2260,8 @@ unsigned long mem_cgroup_soft_limit_recl
> >  				__mem_cgroup_largest_soft_limit_node(mctz);
> >  			} while (next_mz == mz);
> >  		}
> > -		mz->usage_in_excess =
> > -			res_counter_soft_limit_excess(&mz->mem->res);
> >  		__mem_cgroup_remove_exceeded(mz->mem, mz, mctz);
> > +		excess = res_counter_soft_limit_excess(&mz->mem->res);
> >  		/*
> >  		 * One school of thought says that we should not add
> >  		 * back the node to the tree if reclaim returns 0.
> > @@ -2271,8 +2270,8 @@ unsigned long mem_cgroup_soft_limit_recl
> >  		 * memory to reclaim from. Consider this as a longer
> >  		 * term TODO.
> >  		 */
> > -		if (mz->usage_in_excess)
> > -			__mem_cgroup_insert_exceeded(mz->mem, mz, mctz);
> > +		/* If excess == 0, no tree ops */
> > +		__mem_cgroup_insert_exceeded(mz->mem, mz, mctz, excess);
> >  		spin_unlock(&mctz->lock);
> >  		css_put(&mz->mem->css);
> >  		loop++;
> > 
> 

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-09-02  5:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02  0:34 [mmotm][PATCH 1/2] memcg: softlimit clean up KAMEZAWA Hiroyuki
2009-09-02  0:35 ` [mmotm][PATCH 2/2] memcg: reduce calls for soft limit excess KAMEZAWA Hiroyuki
2009-09-02  5:16   ` Daisuke Nishimura
2009-09-02  5:20     ` KAMEZAWA Hiroyuki [this message]
2009-09-02  5:56   ` [mmotm][PATCH 2/2 v2] " KAMEZAWA Hiroyuki
2009-09-02 20:15     ` Balbir Singh
2009-09-03  0:34       ` KAMEZAWA Hiroyuki
2009-09-02  3:56 ` [mmotm][PATCH 1/2] memcg: softlimit clean up Daisuke Nishimura
2009-09-02  4:41 ` [mmotm][PATCH] coalescing uncharge KAMEZAWA Hiroyuki
2009-09-02  6:15   ` KAMEZAWA Hiroyuki
2009-09-02  9:29   ` [mmotm][experimental][PATCH] coalescing charge KAMEZAWA Hiroyuki
2009-09-02 19:58     ` Balbir Singh
2009-09-03  0:24       ` KAMEZAWA Hiroyuki
2009-09-03  5:17     ` Daisuke Nishimura
2009-09-04  4:18       ` KAMEZAWA Hiroyuki
2009-09-04  5:11         ` Daisuke Nishimura
2009-09-04  5:21           ` KAMEZAWA Hiroyuki
2009-09-04  5:26             ` KAMEZAWA Hiroyuki
2009-09-04  6:40               ` Daisuke Nishimura
2009-09-04  6:50                 ` KAMEZAWA Hiroyuki
2009-09-04  7:37                 ` [mmotm][BUGFIX][PATCH] memcg: fix softlimit css refcnt handling KAMEZAWA Hiroyuki
2009-09-04  7:45                   ` KAMEZAWA Hiroyuki
2009-09-04 10:07                   ` Daisuke Nishimura
2009-09-06 23:04                     ` [mmotm][BUGFIX][PATCH] memcg: fix softlimit css refcnt handling(yet another one) Daisuke Nishimura
2009-09-07  0:49                       ` KAMEZAWA Hiroyuki
2009-09-07  4:51                         ` Balbir Singh
2009-09-04  5:47           ` [mmotm][experimental][PATCH] coalescing charge KAMEZAWA Hiroyuki

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=20090902142001.35cae908.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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