From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [BUGFIX][PATCH v2] add mem_cgroup_replace_page_cache. Date: Fri, 9 Dec 2011 12:37:01 -0800 Message-ID: <20111209123701.7e43dadf.akpm@linux-foundation.org> References: <20111206123923.1432ab52.kamezawa.hiroyu@jp.fujitsu.com> <20111207111455.GA18249@tiehlicka.suse.cz> <20111208161829.b6101de6.kamezawa.hiroyu@jp.fujitsu.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20111208161829.b6101de6.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: KAMEZAWA Hiroyuki Cc: Michal Hocko , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Miklos Szeredi , "linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org" , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org" , Hugh Dickins On Thu, 8 Dec 2011 16:18:29 +0900 KAMEZAWA Hiroyuki wrote: > commit ef6a3c6311 adds a function replace_page_cache_page(). This > function replaces a page in radix-tree with a new page. > At doing this, memory cgroup need to fix up the accounting information. > memcg need to check PCG_USED bit etc. > > In some(many?) case, 'newpage' is on LRU before calling replace_page_cache(). > So, memcg's LRU accounting information should be fixed, too. > > This patch adds mem_cgroup_replace_page_cache() and removing old hooks. > In that function, old pages will be unaccounted without touching res_counter > and new page will be accounted to the memcg (of old page). At overwriting > pc->mem_cgroup of newpage, take zone->lru_lock and avoid race with > LRU handling. > > Background: > replace_page_cache_page() is called by FUSE code in its splice() handling. > Here, 'newpage' is replacing oldpage but this newpage is not a newly allocated > page and may be on LRU. LRU mis-accounting will be critical for memory cgroup > because rmdir() checks the whole LRU is empty and there is no account leak. > If a page is on the other LRU than it should be, rmdir() will fail. > > Changelog: v1 -> v2 > - fixed mem_cgroup_disabled() check missing. > - added comments. > > Acked-by: Johannes Weiner > Signed-off-by: KAMEZAWA Hiroyuki > --- > include/linux/memcontrol.h | 6 ++++++ > mm/filemap.c | 18 ++---------------- > mm/memcontrol.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 52 insertions(+), 16 deletions(-) It's a relatively intrusive patch and I'm a bit concerned about feeding it into 3.2. How serious is the bug, and which kernel version(s) do you think we should fix it in? -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html