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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 B960FC433C1 for ; Sun, 21 Mar 2021 10:53:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 223CE614A5 for ; Sun, 21 Mar 2021 10:53:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 223CE614A5 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 45AB46B0070; Sun, 21 Mar 2021 06:53:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 431D06B0071; Sun, 21 Mar 2021 06:53:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E49E6B0072; Sun, 21 Mar 2021 06:53:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 142E76B0070 for ; Sun, 21 Mar 2021 06:53:51 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B7D4C8249980 for ; Sun, 21 Mar 2021 10:53:50 +0000 (UTC) X-FDA: 77943570978.36.7DB6E29 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id CBDA0407F8E8 for ; Sun, 21 Mar 2021 10:53:49 +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=IPWTpmNlwvQD2iMEaDZM4gbTBQw2JCKTcw+XHs6sAEA=; b=MycDLrIcd3ic8F/80A6VFdemDq mP6wMKgaJ+5fZ8A/5UZohpMbjrn0frButsf5ebBykDEX/RU1WPXs8HsON7xXx/0rh1H8iKU1zW2Bo gQnxM6q4iczEUtjYAhChY4xbcUghuUJ8SxLKS+Scas5RUAPIY1QVsjBRYZNB4Td9A/GdUbK+pGXzm ZxqPcKHFmjWFBOpIOxuPGE2Ge3lH75MgJq4zOA4kCUIW8QztYln6orsFPBg70IOQjgwHxMTUkpQvT sP5/cIEzN7DAaOGyHDRzy6+/swS96oUDvvYZzfmO85Y4+6qJHHEg0lpaPO9kP30HPHtXl8+ynO5/A 9oZufQ3g==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lNvhl-007173-MX; Sun, 21 Mar 2021 10:53:12 +0000 Date: Sun, 21 Mar 2021 10:53:09 +0000 From: Matthew Wilcox To: David Howells Cc: Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Linus Torvalds , Christoph Hellwig , Alexander Viro , linux-mm@kvack.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, Jeff Layton , David Wysochanski , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 02/28] mm: Add an unlock function for PG_private_2/PG_fscache Message-ID: <20210321105309.GG3420@casper.infradead.org> References: <161539526152.286939.8589700175877370401.stgit@warthog.procyon.org.uk> <161539528910.286939.1252328699383291173.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161539528910.286939.1252328699383291173.stgit@warthog.procyon.org.uk> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CBDA0407F8E8 X-Stat-Signature: x7p1r1m93sox6ebokxi1696sghuk3m65 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616324029-443843 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, Mar 10, 2021 at 04:54:49PM +0000, David Howells wrote: > Add a function, unlock_page_private_2(), to unlock PG_private_2 analogous > to that of PG_lock. Add a kerneldoc banner to that indicating the example > usage case. One of the things which confused me about this was ... where's the other side? Where's lock_page_private_2()? Then I found this: #ifdef CONFIG_AFS_FSCACHE if (PageFsCache(page) && wait_on_page_bit_killable(page, PG_fscache) < 0) return VM_FAULT_RETRY; #endif Please respect the comment! /* * This is exported only for wait_on_page_locked/wait_on_page_writeback, etc., * and should not be used directly. */ extern void wait_on_page_bit(struct page *page, int bit_nr); extern int wait_on_page_bit_killable(struct page *page, int bit_nr); I think we need the exported API to be wait_on_page_private_2(), and AFS needs to not tinker in the guts of filemap. Otherwise you miss out on bugfixes like c2407cf7d22d0c0d94cf20342b3b8f06f1d904e7 (see also https://lore.kernel.org/linux-fsdevel/20210320054104.1300774-4-willy@infradead.org/T/#u ). That also brings up that there is no set_page_private_2(). I think that's OK -- you only set PageFsCache() immediately after reading the page from the server. But I feel this "unlock_page_private_2" is actually "clear_page_private_2" -- ie it's equivalent to writeback, not to lock. > +++ b/mm/filemap.c > @@ -1432,6 +1432,26 @@ void unlock_page(struct page *page) > } > EXPORT_SYMBOL(unlock_page); > > +/** > + * unlock_page_private_2 - Unlock a page that's locked with PG_private_2 > + * @page: The page > + * > + * Unlocks a page that's locked with PG_private_2 and wakes up sleepers in > + * wait_on_page_private_2(). > + * > + * This is, for example, used when a netfs page is being written to a local > + * disk cache, thereby allowing writes to the cache for the same page to be > + * serialised. > + */ > +void unlock_page_private_2(struct page *page) > +{ > + page = compound_head(page); > + VM_BUG_ON_PAGE(!PagePrivate2(page), page); > + clear_bit_unlock(PG_private_2, &page->flags); > + wake_up_page_bit(page, PG_private_2); > +} > +EXPORT_SYMBOL(unlock_page_private_2); > + > /**