All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: cgroups@vger.kernel.org, Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.cz>,
	Balbir Singh <bsingharora@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	John Stultz <john.stultz@linaro.org>,
	linaro-kernel@lists.linaro.org, patches@linaro.org
Subject: Re: [PATCH RFC] memcg: MEMCG_NR_FILE_MAPPED should update _STAT_CACHE as well
Date: Mon, 23 Apr 2012 02:33:11 -0700	[thread overview]
Message-ID: <20120423093311.GA17412@lizard> (raw)
In-Reply-To: <4F951440.7040704@jp.fujitsu.com>

On Mon, Apr 23, 2012 at 05:35:12PM +0900, KAMEZAWA Hiroyuki wrote:
[...]
> > For example, looking into this code flow:
> > 
> > -> page_add_file_rmap() (mm/rmap.c)
> >  -> mem_cgroup_inc_page_stat(page, MEMCG_NR_FILE_MAPPED) (include/linux/memcontrol.h)
> >   -> void mem_cgroup_update_page_stat(page, MEMCG_NR_FILE_MAPPED, 1) (mm/memcontrol.c)
> > 
> > And then:
> > 
> > void mem_cgroup_update_page_stat(struct page *page,
> >                                  enum mem_cgroup_page_stat_item idx, int val)
> > {
> >         ...
> >         switch (idx) {
> >         case MEMCG_NR_FILE_MAPPED:
> >                 idx = MEM_CGROUP_STAT_FILE_MAPPED;
> >                 break;
> >         default:
> >                 BUG();
> >         }
> > 
> >         this_cpu_add(memcg->stat->count[idx], val);
> >         ...
> > }
> > 
> > So, clearly, this function only bothers updating _FILE_MAPPED only,
> > leaving _CACHE alone.
[...]
> 
> NACK.
> CACHE is updated at charge()/uncharge()...inserting/removing page cache to radix-tree.

Interesting; true, we have charge/uncharge in __do_fault()/do_wp_page
and friends. So, we seem to update FILE_MAPPED in the rmap via
cgroup_dec/inc_page_stat, and CACHE is updated via charge/uncharge. Hm.

The code in memory.c is full of if/else ifs, and I wonder if there's 
some discrepancy in there, but briefly looking it looks fine. The
code looks correct indeed, but I'm getting the wrong stats. :-/

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

WARNING: multiple messages have this Message-ID (diff)
From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: cgroups@vger.kernel.org, Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@suse.cz>,
	Balbir Singh <bsingharora@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
	John Stultz <john.stultz@linaro.org>,
	linaro-kernel@lists.linaro.org, patches@linaro.org
Subject: Re: [PATCH RFC] memcg: MEMCG_NR_FILE_MAPPED should update _STAT_CACHE as well
Date: Mon, 23 Apr 2012 02:33:11 -0700	[thread overview]
Message-ID: <20120423093311.GA17412@lizard> (raw)
In-Reply-To: <4F951440.7040704@jp.fujitsu.com>

On Mon, Apr 23, 2012 at 05:35:12PM +0900, KAMEZAWA Hiroyuki wrote:
[...]
> > For example, looking into this code flow:
> > 
> > -> page_add_file_rmap() (mm/rmap.c)
> >  -> mem_cgroup_inc_page_stat(page, MEMCG_NR_FILE_MAPPED) (include/linux/memcontrol.h)
> >   -> void mem_cgroup_update_page_stat(page, MEMCG_NR_FILE_MAPPED, 1) (mm/memcontrol.c)
> > 
> > And then:
> > 
> > void mem_cgroup_update_page_stat(struct page *page,
> >                                  enum mem_cgroup_page_stat_item idx, int val)
> > {
> >         ...
> >         switch (idx) {
> >         case MEMCG_NR_FILE_MAPPED:
> >                 idx = MEM_CGROUP_STAT_FILE_MAPPED;
> >                 break;
> >         default:
> >                 BUG();
> >         }
> > 
> >         this_cpu_add(memcg->stat->count[idx], val);
> >         ...
> > }
> > 
> > So, clearly, this function only bothers updating _FILE_MAPPED only,
> > leaving _CACHE alone.
[...]
> 
> NACK.
> CACHE is updated at charge()/uncharge()...inserting/removing page cache to radix-tree.

Interesting; true, we have charge/uncharge in __do_fault()/do_wp_page
and friends. So, we seem to update FILE_MAPPED in the rmap via
cgroup_dec/inc_page_stat, and CACHE is updated via charge/uncharge. Hm.

The code in memory.c is full of if/else ifs, and I wonder if there's 
some discrepancy in there, but briefly looking it looks fine. The
code looks correct indeed, but I'm getting the wrong stats. :-/

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

  reply	other threads:[~2012-04-23  9:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02 16:27 [RFC] memcg usage_in_bytes does not account file mapped and slab memory Anton Vorontsov
2012-03-02 16:27 ` Anton Vorontsov
2012-03-02 16:27 ` Anton Vorontsov
2012-03-05  0:19 ` KAMEZAWA Hiroyuki
2012-03-05  0:19   ` KAMEZAWA Hiroyuki
     [not found]   ` <20120305091934.588c160b.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2012-04-23  8:28     ` [PATCH RFC] memcg: MEMCG_NR_FILE_MAPPED should update _STAT_CACHE as well Anton Vorontsov
2012-04-23  8:28       ` Anton Vorontsov
2012-04-23  8:28       ` Anton Vorontsov
2012-04-23  8:35       ` KAMEZAWA Hiroyuki
2012-04-23  8:35         ` KAMEZAWA Hiroyuki
2012-04-23  9:33         ` Anton Vorontsov [this message]
2012-04-23  9:33           ` Anton Vorontsov

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=20120423093311.GA17412@lizard \
    --to=anton.vorontsov@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=bsingharora@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=john.stultz@linaro.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=patches@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.