Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755665AbaBROX1 (ORCPT ); Tue, 18 Feb 2014 09:23:27 -0500 Received: from mta-out.inet.fi ([195.156.147.13]:58924 "EHLO jenni2.inet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755084AbaBROXZ (ORCPT ); Tue, 18 Feb 2014 09:23:25 -0500 Date: Tue, 18 Feb 2014 16:23:05 +0200 From: "Kirill A. Shutemov" To: Rik van Riel Cc: Linus Torvalds , "Kirill A. Shutemov" , Andrew Morton , Mel Gorman , Andi Kleen , Matthew Wilcox , Dave Hansen , Alexander Viro , Dave Chinner , linux-mm , linux-fsdevel , Linux Kernel Mailing List Subject: Re: [RFC, PATCHv2 0/2] mm: map few pages around fault address if they are in page cache Message-ID: <20140218142305.GA5933@node.dhcp.inet.fi> References: <1392662333-25470-1-git-send-email-kirill.shutemov@linux.intel.com> <53035FE2.4080300@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53035FE2.4080300@redhat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2014 at 08:28:02AM -0500, Rik van Riel wrote: > On 02/17/2014 02:01 PM, Linus Torvalds wrote: > > > - increment the page _mapcount (iow, do "page_add_file_rmap()" > > early). This guarantees that any *subsequent* unmap activity on this > > page will walk the file mapping lists, and become serialized by the > > page table lock we hold. > > > > - mb_after_atomic_inc() (this is generally free) > > > > - test that the page is still unlocked and uptodate, and the page > > mapping still points to our page. > > > > - if that is true, we're all good, we can use the page, otherwise we > > decrement the mapcount (page_remove_rmap()) and skip the page. > > > > Hmm? Doing something like this means that we would never lock the > > pages we prefault, and you can go back to your gang lookup rather than > > that "one page at a time". And the race case is basically never going > > to trigger. > > > > Comments? > > What would the direct io code do when it runs into a page with > elevated mapcount, but for which a mapping cannot be found yet? > > Looking at the code, it looks like the above scheme could cause > some trouble with invalidate_inode_pages2_range(), which has > the following sequence: > > if (page_mapped(page)) { > ... unmap page > } > BUG_ON(page_mapped(page)); > > In other words, it looks like incrementing _mapcount first could > lead to an oops in the truncate and direct IO code. > > The page lock is used to prevent such races. > > *sigh* What if we will retry unmap once again, before triggering BUG(). The second unmap will be serialized by page table lock, right? -- Kirill A. Shutemov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/