Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6400232rwb; Mon, 14 Nov 2022 20:10:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Pi8KetmEBt/CIG3/MOIFT0/J404CjNQ/on3NA9F8ymPc3mXGWcc0zIIzCJwxrL80EfSia X-Received: by 2002:a17:906:3ecf:b0:7ac:db70:3ab5 with SMTP id d15-20020a1709063ecf00b007acdb703ab5mr12587432ejj.160.1668485400816; Mon, 14 Nov 2022 20:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668485400; cv=none; d=google.com; s=arc-20160816; b=xPgNcjcXBrlY7cyaHsB9Vu4QT+2EiMX+UUQBtUzZipvBCpEbFhfkWmHMPmeBoGbyoq fT4aWIR1fmnllmfhxys5pAK/uCz9bGeSpXuSw7yf/+6oI3LQPSOeaE4/MdNH48bahg5Y Do5MLn7QnkcpwPK2oQNjqA4qqiufERRPO0Bowi1yEOtoSdjOlRbQ+WkysN2cSLEx98tn GRGxpWuqfnCjHYYvJhLvxS5GX/OpZ4tObslLys6jA2Ipqzg5CWi0jhkqpRAd3nDt3lqM ufmCoBCd/Kpg/s8Yh0hHqwEvDNFw/nivA8/AearNo47Rqjvv+bYZV7AuEmbHjIvVjJ+I 5btQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=j/xUVrD8mPcSbyQHk615wZHvvK1z2hXuDfFCa4PiwtI=; b=Eas6hlm6fErAm6FirNo0fU3V3Eceej37LWmqverakP3m9sAZG01WLcTxE/wTm5QugO SeLv4y7wRzpX/x7D46A0PJdwB0J0YSfFRn1zWgYrF37+PSCJD/cqE2ukELtslm0+U4cX p/ILSxB84RAc7RHu3qCu1LT5vnR9ZWVY6Kjz/C7iv9Geo9VN52BDQQcjg+W+fx9+NhiA 5fyp56vVjOqU8/huLMkBWmlD+4DQ416uE/eAJF0gN11j/UWU60CpHhSpVFdA5hbHMQq1 HL+dzIYrthMqtqU1bbraHcTBxRINwSjAVw2axMfHO6pZbachrqOj7gMJZ0YlTWEB6cus X68g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cqcPHDV+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch9-20020a0564021bc900b00462750bbe08si9554090edb.522.2022.11.14.20.09.29; Mon, 14 Nov 2022 20:10:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cqcPHDV+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231497AbiKOEJZ (ORCPT + 99 others); Mon, 14 Nov 2022 23:09:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbiKOEJY (ORCPT ); Mon, 14 Nov 2022 23:09:24 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B5E31A82F; Mon, 14 Nov 2022 20:09:19 -0800 (PST) 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=j/xUVrD8mPcSbyQHk615wZHvvK1z2hXuDfFCa4PiwtI=; b=cqcPHDV+eY3ifO9g3vqqcV+Bnh zsVmJpaFiflf5AYEOG3Gk8yCOvxY2VdVW1IHUEvxNgWPziM1+s7iQWCyjRwtqWOztJWjco+wIE8+/ JAszRx1WSMGrgfhPxUKltG0mJzXigO2CzTqvQCN0Q3HVnio9l5kV7sxhHrOccZCnn8Cy7fh3vQHHk qM7aIAWE419vYSVxB5x5f2zCN2lWsovAQiBqh9msxwhjWhlT12x0nsBLDANysPmO7exwN52iTGj2e ijqiE0P7vjJQpO6DIyXSI0xgg+e0DxJ/Z5xGIsfiwcPbNKl3PxKsNMEMxE+mpSFr4xxXC7ElQ+PUq RJbOqsQw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ounFy-00G84y-Gg; Tue, 15 Nov 2022 04:09:06 +0000 Date: Tue, 15 Nov 2022 04:09:06 +0000 From: Matthew Wilcox To: David Howells Cc: dwysocha@redhat.com, Rohith Surabattula , Steve French , Shyam Prasad N , Dominique Martinet , Ilya Dryomov , linux-cachefs@redhat.com, linux-cifs@vger.kernel.org, linux-afs@lists.infradead.org, v9fs-developer@lists.sourceforge.net, ceph-devel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2] mm, netfs, fscache: Stop read optimisation when folio removed from pagecache Message-ID: References: <166844174069.1124521.10890506360974169994.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <166844174069.1124521.10890506360974169994.stgit@warthog.procyon.org.uk> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, Nov 14, 2022 at 04:02:20PM +0000, David Howells wrote: > +++ b/mm/filemap.c > @@ -3941,6 +3941,10 @@ bool filemap_release_folio(struct folio *folio, gfp_t gfp) > struct address_space * const mapping = folio->mapping; > > BUG_ON(!folio_test_locked(folio)); > + if ((!mapping || !mapping_release_always(mapping)) > + && !folio_test_private(folio) && > + !folio_test_private_2(folio)) > + return true; Why do you need to test 'mapping' here? Also this is the most inconsistent style ... if ((!mapping || !mapping_release_always(mapping)) && !folio_test_private(folio) && !folio_test_private_2(folio)) works fine, but if you insist on splitting over three lines, then: if ((!mapping || !mapping_release_always(mapping)) && !folio_test_private(folio) && !folio_test_private_2(folio)) > @@ -276,7 +275,7 @@ static long mapping_evict_folio(struct address_space *mapping, > if (folio_ref_count(folio) > > folio_nr_pages(folio) + folio_has_private(folio) + 1) I think this line is incorrect, right? You don't increment the folio refcount just because the folio has private2 set, do you? > return 0; > - if (folio_has_private(folio) && !filemap_release_folio(folio, 0)) > + if (!filemap_release_folio(folio, 0)) > return 0; > > return remove_mapping(mapping, folio); Can we get rid of folio_has_private() / page_has_private() now?