From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail191.messagelabs.com (mail191.messagelabs.com [216.82.242.19]) by kanga.kvack.org (Postfix) with ESMTP id 500546B003D for ; Tue, 17 Mar 2009 13:06:26 -0400 (EDT) Date: Tue, 17 Mar 2009 10:01:06 -0700 (PDT) From: Linus Torvalds Subject: Re: [aarcange@redhat.com: [PATCH] fork vs gup(-fast) fix] In-Reply-To: Message-ID: References: <1237007189.25062.91.camel@pasglop> <200903141620.45052.nickpiggin@yahoo.com.au> <20090316223612.4B2A.A69D9226@jp.fujitsu.com> <20090317121900.GD20555@random.random> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org To: Andrea Arcangeli Cc: KOSAKI Motohiro , Nick Piggin , Benjamin Herrenschmidt , Ingo Molnar , Nick Piggin , Hugh Dickins , KAMEZAWA Hiroyuki , linux-mm@kvack.org List-ID: On Tue, 17 Mar 2009, Linus Torvalds wrote: > > So yes - I had expected our VM to be sane, and have a writable private > page _stay_ writable (in the absense of fork() it should never turn into a > COW page), but the swapout+swapin code can result in a rw page that turns > read-only in order to catch a swap cache invalidation. > > Good catch. Let me think about it. Btw, I think this is actually a pre-existing bug regardless of my patch. That same swapout+swapin problem seems to lose the dirty bit on a O_DIRECT write - exactly for the same reason. When swapin turns the page into a read-only page in order to keep the physical page in the swap cache, the write to the physical page (that was gotten by get_user_pages() earlier) will bypass all that. So the get_user_pages() users will then write to the page, but the next time we swap things out, if nobody _else_ wrote to it, that write will be lost because we'll just drop the page (it was in the swap cache!) even though it had changed data on it. My patch changed the schenario a bit (split page rather than dropped page), but the fundamental cause seems to be the same - the swap cache code very much depends on writes to the _virtual_ address. Or am I missing something? Linus -- 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