From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422709AbXCGKPZ (ORCPT ); Wed, 7 Mar 2007 05:15:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1422707AbXCGKPZ (ORCPT ); Wed, 7 Mar 2007 05:15:25 -0500 Received: from smtp.osdl.org ([65.172.181.24]:59932 "EHLO smtp.osdl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422709AbXCGKPX (ORCPT ); Wed, 7 Mar 2007 05:15:23 -0500 Date: Wed, 7 Mar 2007 02:15:18 -0800 From: Andrew Morton To: Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nick Piggin , Linus Torvalds Subject: Re: [patch 1/8] fix race in clear_page_dirty_for_io() Message-Id: <20070307021518.3b1ff4a2.akpm@linux-foundation.org> In-Reply-To: <20070307082337.101759335@szeredi.hu> References: <20070307080949.290171170@szeredi.hu> <20070307082337.101759335@szeredi.hu> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.17; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org (cc's reinstated) On Wed, 07 Mar 2007 09:09:50 +0100 Miklos Szeredi wrote: > There's a race in clear_page_dirty_for_io() that allows a page to have > cleared PG_dirty, while being mapped read-write into the page table(s). I assume you refer to this: * FIXME! We still have a race here: if somebody * adds the page back to the page tables in * between the "page_mkclean()" and the "TestClearPageDirty()", * we might have it mapped without the dirty bit set. */ if (page_mkclean(page)) set_page_dirty(page); if (TestClearPageDirty(page)) { dec_zone_page_state(page, NR_FILE_DIRTY); return 1; } I guess the comment actually refers to a writefault after the set_page_dirty() and before the TestClearPageDirty(). The fault handler will run set_page_dirty() and will return to userspace to rerun the write. The page then gets set pte-dirty but this thread of control will now make the page !PageDirty() and will write it out. With Nick's proposed lock-the-page-in-pagefaults patches, we have lock_page() synchronisation between pagefaults and clear_page_dirty_for_io() which I think will fix this. From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 7 Mar 2007 02:15:18 -0800 From: Andrew Morton Subject: Re: [patch 1/8] fix race in clear_page_dirty_for_io() Message-Id: <20070307021518.3b1ff4a2.akpm@linux-foundation.org> In-Reply-To: <20070307082337.101759335@szeredi.hu> References: <20070307080949.290171170@szeredi.hu> <20070307082337.101759335@szeredi.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nick Piggin , Linus Torvalds List-ID: (cc's reinstated) On Wed, 07 Mar 2007 09:09:50 +0100 Miklos Szeredi wrote: > There's a race in clear_page_dirty_for_io() that allows a page to have > cleared PG_dirty, while being mapped read-write into the page table(s). I assume you refer to this: * FIXME! We still have a race here: if somebody * adds the page back to the page tables in * between the "page_mkclean()" and the "TestClearPageDirty()", * we might have it mapped without the dirty bit set. */ if (page_mkclean(page)) set_page_dirty(page); if (TestClearPageDirty(page)) { dec_zone_page_state(page, NR_FILE_DIRTY); return 1; } I guess the comment actually refers to a writefault after the set_page_dirty() and before the TestClearPageDirty(). The fault handler will run set_page_dirty() and will return to userspace to rerun the write. The page then gets set pte-dirty but this thread of control will now make the page !PageDirty() and will write it out. With Nick's proposed lock-the-page-in-pagefaults patches, we have lock_page() synchronisation between pagefaults and clear_page_dirty_for_io() which I think will fix this. -- 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