mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: nishimura@mxp.nes.nec.co.jp,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
	"xemul@openvz.org" <xemul@openvz.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 4/4] memcg: optimze cpustat
Date: Mon, 29 Sep 2008 20:44:36 +0900	[thread overview]
Message-ID: <20080929204436.ee3fce0b.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20080929192430.e93d4f21.kamezawa.hiroyu@jp.fujitsu.com>

On Mon, 29 Sep 2008 19:24:30 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> Some obvious optimization to memcg.
> 
> I found mem_cgroup_charge_statistics() is a little big (in object) and
> does unnecessary address calclation.
> This patch is for optimization to reduce the size of this function.
> 
> And res_counter_charge() is 'likely' to success.
> 
> Changlog: v5->v6
>  - patch series was reordered and needs some adjustment. no changes in logic.
> Changelog v3->v4:
>  - merged with an other leaf patch.
> 
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
> 
> 
	Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>

I'll test with all the patches applied tonight.


Thanks,
Daisuke Nishimura.

>  mm/memcontrol.c |   18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> Index: mmotm-2.6.27-rc7+/mm/memcontrol.c
> ===================================================================
> --- mmotm-2.6.27-rc7+.orig/mm/memcontrol.c
> +++ mmotm-2.6.27-rc7+/mm/memcontrol.c
> @@ -66,11 +66,10 @@ struct mem_cgroup_stat {
>  /*
>   * For accounting under irq disable, no need for increment preempt count.
>   */
> -static void __mem_cgroup_stat_add_safe(struct mem_cgroup_stat *stat,
> +static inline void __mem_cgroup_stat_add_safe(struct mem_cgroup_stat_cpu *stat,
>  		enum mem_cgroup_stat_index idx, int val)
>  {
> -	int cpu = smp_processor_id();
> -	stat->cpustat[cpu].count[idx] += val;
> +	stat->count[idx] += val;
>  }
>  
>  static s64 mem_cgroup_read_stat(struct mem_cgroup_stat *stat,
> @@ -190,18 +189,21 @@ static void mem_cgroup_charge_statistics
>  {
>  	int val = (charge)? 1 : -1;
>  	struct mem_cgroup_stat *stat = &mem->stat;
> +	struct mem_cgroup_stat_cpu *cpustat;
>  
>  	VM_BUG_ON(!irqs_disabled());
> +
> +	cpustat = &stat->cpustat[smp_processor_id()];
>  	if (flags & PAGE_CGROUP_FLAG_CACHE)
> -		__mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_CACHE, val);
> +		__mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_CACHE, val);
>  	else
> -		__mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val);
> +		__mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_RSS, val);
>  
>  	if (charge)
> -		__mem_cgroup_stat_add_safe(stat,
> +		__mem_cgroup_stat_add_safe(cpustat,
>  				MEM_CGROUP_STAT_PGPGIN_COUNT, 1);
>  	else
> -		__mem_cgroup_stat_add_safe(stat,
> +		__mem_cgroup_stat_add_safe(cpustat,
>  				MEM_CGROUP_STAT_PGPGOUT_COUNT, 1);
>  }
>  
> @@ -558,7 +560,7 @@ static int mem_cgroup_charge_common(stru
>  		css_get(&memcg->css);
>  	}
>  
> -	while (res_counter_charge(&mem->res, PAGE_SIZE)) {
> +	while (unlikely(res_counter_charge(&mem->res, PAGE_SIZE))) {
>  		if (!(gfp_mask & __GFP_WAIT))
>  			goto out;
>  
> 

  reply	other threads:[~2008-09-29 11:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-29 10:19 [PATCH 0/4] memcg: ready-to-go series (was memcg update v6) KAMEZAWA Hiroyuki
2008-09-29 10:21 ` [PATCH 1/4] memcg: account swap cache under lock KAMEZAWA Hiroyuki
2008-09-29 11:33   ` Daisuke Nishimura
2008-09-30  8:05   ` Balbir Singh
2008-09-29 10:22 ` [PATCH 2/4] memcg: set page->mapping NULL before uncharge KAMEZAWA Hiroyuki
2008-09-29 11:39   ` Daisuke Nishimura
2008-10-01  3:50   ` Balbir Singh
2008-09-29 10:23 ` [PATCH 3/4] memcg: avoid account not-on-LRU pages KAMEZAWA Hiroyuki
2008-09-29 11:19   ` Daisuke Nishimura
2008-09-29 11:59   ` kamezawa.hiroyu
2008-09-30  1:17   ` [PATCH/stylefix " KAMEZAWA Hiroyuki
2008-10-01  3:49     ` Balbir Singh
2008-10-01  4:50       ` KAMEZAWA Hiroyuki
2008-09-30  8:14   ` [PATCH " Balbir Singh
2008-09-29 10:24 ` [PATCH 4/4] memcg: optimze cpustat KAMEZAWA Hiroyuki
2008-09-29 11:44   ` Daisuke Nishimura [this message]
2008-10-06 17:15 ` [PATCH 0/4] memcg: ready-to-go series (was memcg update v6) 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=20080929204436.ee3fce0b.nishimura@mxp.nes.nec.co.jp \
    --to=nishimura@mxp.nes.nec.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=xemul@openvz.org \
    /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

all inboxes | Powered by JetHome®