From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2234EC433E7 for ; Wed, 14 Oct 2020 18:15:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 241032222C for ; Wed, 14 Oct 2020 18:15:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZqWQT4WO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 241032222C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 402336B005C; Wed, 14 Oct 2020 14:15:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D9A66B0062; Wed, 14 Oct 2020 14:15:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C99C6B006E; Wed, 14 Oct 2020 14:15:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id 001986B005C for ; Wed, 14 Oct 2020 14:15:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 96F2E181AEF00 for ; Wed, 14 Oct 2020 18:15:13 +0000 (UTC) X-FDA: 77371332906.16.glove34_3f020d02720d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 7AA35100C7213 for ; Wed, 14 Oct 2020 18:15:13 +0000 (UTC) X-HE-Tag: glove34_3f020d02720d X-Filterd-Recvd-Size: 3413 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 14 Oct 2020 18:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sQvG5B57qQ8pitJx5xAsS25qRLEbRjXr/NwuIkkRph8=; b=ZqWQT4WOvQ0G8vZGdAd085nXrs 793fmY3O7zgdfZle1c1NyuwoZu7RGnqlY4Z/8dpeMAOxPz9IhxWF9EzqaaRVjxs6N/VI5J831DfQY uTVWrGcNvvLfLbZfAosgrTXIZRbAS9NqXDF1Co6YnJV11pIWnA0bnezhDdnV5urq79X+nKOQj1Zxq vwVBT7xHTDA6HyJXLKP2k5iWbZ9XRxzDWRcS15m/RKYKQveTHUBqMnOc3m1CdgV2jkyM73yqSvRtM lK5ryRd8zQwYy+HY9tf1otRyew4C0b0CHgFCI/0vJq99zn6UriMxo55sAyMnAZeS6c80ZbXmm3Wxa ty+Vc4PA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSlIr-0007sy-UD; Wed, 14 Oct 2020 18:15:09 +0000 Date: Wed, 14 Oct 2020 19:15:09 +0100 From: Matthew Wilcox To: Linus Torvalds Cc: "Kirill A. Shutemov" , Hugh Dickins , Linux-MM , Andrew Morton , linux-fsdevel , Amir Goldstein Subject: Re: [PATCH 0/4] Some more lock_page work.. Message-ID: <20201014181509.GU20115@casper.infradead.org> References: <20201014130555.kdbxyavqoyfnpos3@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Oct 14, 2020 at 09:53:35AM -0700, Linus Torvalds wrote: > In particular, what I _think_ we could do is: > > - lock the page tables > > - check that the page isn't locked > > - increment the page mapcount (atomic and ordered) > > - check that the page still isn't locked > > - insert pte > > without taking the page lock. And the reason that's safe is that *if* [...] > And they aren't necessarily a _lot_ more involved. In fact, I think we > may already hold the page table lock due to doing that > "pte_alloc_one_map()" thing over all of filemap_map_pages(). So I > think the only _real_ problem is that I think we increment the > page_mapcount() too late in alloc_set_pte(). I'm not entirely sure why we require the page lock to be held in page_add_file_rmap(): } else { if (PageTransCompound(page) && page_mapping(page)) { VM_WARN_ON_ONCE(!PageLocked(page)); SetPageDoubleMap(compound_head(page)); if (PageMlocked(page)) clear_page_mlock(compound_head(page)); } We have a reference to the page, so compound_head() isn't going to change. SetPageDoubleMap() is atomic. PageMlocked() is atomic. clear_page_mlock() does TestClearPageMlocked() as its first thing, so that's atomic too. What am I missing? (Kirill added it, so I assume he remembers ;-)