From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx175.postini.com [74.125.245.175]) by kanga.kvack.org (Postfix) with SMTP id 54F216B0068 for ; Sat, 16 Jun 2012 02:36:28 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id D60C73EE081 for ; Sat, 16 Jun 2012 15:36:26 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id C04DE45DEA6 for ; Sat, 16 Jun 2012 15:36:26 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id A00E445DE7E for ; Sat, 16 Jun 2012 15:36:26 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 942111DB803E for ; Sat, 16 Jun 2012 15:36:26 +0900 (JST) Received: from m1000.s.css.fujitsu.com (m1000.s.css.fujitsu.com [10.240.81.136]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 401A71DB803B for ; Sat, 16 Jun 2012 15:36:26 +0900 (JST) Message-ID: <4FDC28F0.8050805@jp.fujitsu.com> Date: Sat, 16 Jun 2012 15:34:24 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: [PATCH 2/2] memcg: add per cgroup dirty pages accounting References: <1339761611-29033-1-git-send-email-handai.szj@taobao.com> <1339761717-29070-1-git-send-email-handai.szj@taobao.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Greg Thelen Cc: Sha Zhengju , linux-mm@kvack.org, cgroups@vger.kernel.org, yinghan@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Sha Zhengju (2012/06/16 0:32), Greg Thelen wrote: > On Fri, Jun 15 2012, Sha Zhengju wrote: > >> This patch adds memcg routines to count dirty pages. I notice that >> the list has talked about per-cgroup dirty page limiting >> (http://lwn.net/Articles/455341/) before, but it did not get merged. > > Good timing, I was just about to make another effort to get some of > these patches upstream. Like you, I was going to start with some basic > counters. > > Your approach is similar to what I have in mind. While it is good to > use the existing PageDirty flag, rather than introducing a new > page_cgroup flag, there are locking complications (see below) to handle > races between moving pages between memcg and the pages being {un}marked > dirty. > >> I've no idea how is this going now, but maybe we can add per cgroup >> dirty pages accounting first. This allows the memory controller to >> maintain an accurate view of the amount of its memory that is dirty >> and can provide some infomation while group's direct reclaim is working. >> >> After commit 89c06bd5 (memcg: use new logic for page stat accounting), >> we do not need per page_cgroup flag anymore and can directly use >> struct page flag. >> >> >> Signed-off-by: Sha Zhengju >> --- >> include/linux/memcontrol.h | 1 + >> mm/filemap.c | 1 + >> mm/memcontrol.c | 32 +++++++++++++++++++++++++------- >> mm/page-writeback.c | 2 ++ >> mm/truncate.c | 1 + >> 5 files changed, 30 insertions(+), 7 deletions(-) >> >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index a337c2e..8154ade 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -39,6 +39,7 @@ enum mem_cgroup_stat_index { >> MEM_CGROUP_STAT_FILE_MAPPED, /* # of pages charged as file rss */ >> MEM_CGROUP_STAT_SWAPOUT, /* # of pages, swapped out */ >> MEM_CGROUP_STAT_DATA, /* end of data requires synchronization */ >> + MEM_CGROUP_STAT_FILE_DIRTY, /* # of dirty pages in page cache */ >> MEM_CGROUP_STAT_NSTATS, >> }; >> >> diff --git a/mm/filemap.c b/mm/filemap.c >> index 79c4b2b..5b5c121 100644 >> --- a/mm/filemap.c >> +++ b/mm/filemap.c >> @@ -141,6 +141,7 @@ void __delete_from_page_cache(struct page *page) >> * having removed the page entirely. >> */ >> if (PageDirty(page)&& mapping_cap_account_dirty(mapping)) { >> + mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_FILE_DIRTY); > > You need to use mem_cgroup_{begin,end}_update_page_stat around critical > sections that: > 1) check PageDirty > 2) update MEM_CGROUP_STAT_FILE_DIRTY counter > > This protects against the page from being moved between memcg while > accounting. Same comment applies to all of your new calls to > mem_cgroup_{dec,inc}_page_stat. For usage pattern, see > page_add_file_rmap. > If you feel some difficulty with mem_cgroup_{begin,end}_update_page_stat(), please let me know...I hope they should work enough.... Thanks, -Kame -- 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: email@kvack.org