From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 29 Sep 2008 20:33:07 +0900 From: Daisuke Nishimura Subject: Re: [PATCH 1/4] memcg: account swap cache under lock Message-Id: <20080929203307.918e7990.nishimura@mxp.nes.nec.co.jp> In-Reply-To: <20080929192123.5ce60c24.kamezawa.hiroyu@jp.fujitsu.com> References: <20080929191927.caabec89.kamezawa.hiroyu@jp.fujitsu.com> <20080929192123.5ce60c24.kamezawa.hiroyu@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: KAMEZAWA Hiroyuki Cc: nishimura@mxp.nes.nec.co.jp, "linux-mm@kvack.org" , LKML , "balbir@linux.vnet.ibm.com" , "xemul@openvz.org" List-ID: On Mon, 29 Sep 2008 19:21:23 +0900, KAMEZAWA Hiroyuki wrote: > While page-cache's charge/uncharge is done under page_lock(), swap-cache > isn't. (anonymous page is charged when it's newly allocated.) > > This patch moves do_swap_page()'s charge() call under lock. > I don't see any bad problem *now* but this fix will be good for future > for avoiding unneccesary racy state. > > > Changelog: (v5) -> (v6) > - mark_page_accessed() is moved before lock_page(). > - fixed missing unlock_page() > (no changes in previous version) > > Signed-off-by: KAMEZAWA Hiroyuki > Looks good to me. Reviewed-by: Daisuke Nishimura > mm/memory.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > Index: mmotm-2.6.27-rc7+/mm/memory.c > =================================================================== > --- mmotm-2.6.27-rc7+.orig/mm/memory.c > +++ mmotm-2.6.27-rc7+/mm/memory.c > @@ -2326,16 +2326,17 @@ static int do_swap_page(struct mm_struct > count_vm_event(PGMAJFAULT); > } > > + mark_page_accessed(page); > + > + lock_page(page); > + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); > + > if (mem_cgroup_charge(page, mm, GFP_KERNEL)) { > - delayacct_clear_flag(DELAYACCT_PF_SWAPIN); > ret = VM_FAULT_OOM; > + unlock_page(page); > goto out; > } > > - mark_page_accessed(page); > - lock_page(page); > - delayacct_clear_flag(DELAYACCT_PF_SWAPIN); > - > /* > * Back out if somebody else already faulted in this pte. > */ > -- 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