Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp102021pxh; Thu, 7 Apr 2022 15:19:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEsNXJkODQtAt6+lObucsme5azSXVzUr7n6iLm5QRYU1SEZT42L2tErPVT5Mh5x4O7EiQq X-Received: by 2002:a81:a142:0:b0:2eb:9481:ecc with SMTP id y63-20020a81a142000000b002eb94810eccmr12976011ywg.264.1649369993996; Thu, 07 Apr 2022 15:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649369993; cv=none; d=google.com; s=arc-20160816; b=M1ie6UDpyDhPOYlzkGHWuGuao1JK2PwipNNHtXb7Khds/L9TaE6ET0/Cad5L5VZxpr UZZnYgbZWM/iGFqyIcTGR7O6oyxa4kOFwoV1APVpOiOqMDyS00c38fnXAiJ5dfh0F7Qv fzKW1lyKioL0VsnBjn3sPnrIT92zN3MpK6lKWGIMzrQphSLVjO1G9VIzKOb8pxlsGM7T Ta1qWNwf2mgLhuxg7GltNc2mu4ZncXcPN6CzltVR6Bbs2FMpqgwa6Nwf0EXnVprjS52A RKdSvIK+ftYm7/GWaiJYVddvfQdNvVHY7lFkodVsx0nXZfhKfB1C6OHliA5yb9MkD1Q+ RXyw== 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=AP3ckG/WzqkXC8+7CiECPH3yRSiA3cIEW4UGrQf10jo=; b=KuVVN4gqAG6UgOrUaXWn+nE1knDpTaV/cHOoyGq+48NL3iS2KXuur95SQWyWGr46Jw 6x9/xPz3jv8mFmL/BprdmX9rTT33MsITxQoklPjstULKi0oQnCuL9xwwskOjC7Ti9i1J Mn/updnicbEfQqbnFKT5qXed/pIe+N7tI7FI/TNCM4c9iaqqb9Rv6uRQLlR6iugH34bj EAkPkiY2mpTLdFiiWvTiSSVWuhQPSGNKgX8cCL2uAsKc/wdC6+5FQw2omcgrKiEI985U ajquu1PF/gfDVazpSglh6NOrthWgdqxf4zuwLW2hFXKZRpKrV1WLUQLSBHCiPlvZmDWN 9VUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VHt28AgN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g11-20020a81fd0b000000b002e5bb9dcab9si14590728ywn.322.2022.04.07.15.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VHt28AgN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2B70124C2E; Thu, 7 Apr 2022 14:22:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231138AbiDGVYR (ORCPT + 99 others); Thu, 7 Apr 2022 17:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbiDGVYQ (ORCPT ); Thu, 7 Apr 2022 17:24:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AC0E74DCE; Thu, 7 Apr 2022 14:22:13 -0700 (PDT) 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=AP3ckG/WzqkXC8+7CiECPH3yRSiA3cIEW4UGrQf10jo=; b=VHt28AgNNEbERQekujzfAhepuF yRUYEupZiZ63Q+FrJIO2VhPpxfdNELTdKXP3+AqQFnU7rCKdEJdALxf3FU3evxIYXSXF5qigkZrCN hJ2PkDlk56mtFwIBQt+Wcm+whEwtTQzXVP8sPrwHhvwiWDHePrly6T//aWyDaG0AMqR6tqsYcNBW6 EE3PuIlV9s7etoCXhZEscei648aysaUd70wbuBhBsYUk0CEv30is5bj5UILJer52psJMA5shwPTWh 2TTpNIKotN1lTBYaXzA74xnVD6UIwQMzFY6+9u0c0nb4dBiv2sKLiNcqA/zijCmh3M/ZERhyo/oUa ITnXj9yA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncZZv-009Ciz-Cj; Thu, 07 Apr 2022 21:22:07 +0000 Date: Thu, 7 Apr 2022 22:22:07 +0100 From: Matthew Wilcox To: David Howells Cc: linux-cachefs@redhat.com, Rohith Surabattula , Steve French , Shyam Prasad N , linux-cifs@vger.kernel.org, Jeff Layton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 14/14] mm, netfs, fscache: Stop read optimisation when folio removed from pagecache Message-ID: References: <164928615045.457102.10607899252434268982.stgit@warthog.procyon.org.uk> <164928630577.457102.8519251179327601178.stgit@warthog.procyon.org.uk> <469869.1649313707@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <469869.1649313707@warthog.procyon.org.uk> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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-kernel@vger.kernel.org On Thu, Apr 07, 2022 at 07:41:47AM +0100, David Howells wrote: > Matthew Wilcox wrote: > > > On Thu, Apr 07, 2022 at 12:05:05AM +0100, David Howells wrote: > > > Fix this by adding an extra address_space operation, ->removing folio(), > > > and flag, AS_NOTIFY_REMOVING_FOLIO. The operation is called if the flag is > > > set when a folio is removed from the pagecache. The flag should be set if > > > a non-NULL cookie is obtained from fscache and cleared in ->evict_inode() > > > before truncate_inode_pages_final() is called. > > > > What's wrong with ->freepage? > > It's too late. The optimisation must be cancelled before there's a chance > that a new page can be allocated and attached to the pagecache - but > ->freepage() is called after the folio has been removed. Doing it in > ->freepage() would allow ->readahead(), ->readpage() or ->write_begin() to > jump in and start a new read (which gets skipped because the optimisation is > still in play). OK. You suggested that releasepage was an acceptable place to call it. How about we have AS_RELEASE_ALL (... or something ...) and then page_has_private() becomes a bit more complicated ... to the point where we should probably get rid of it (by embedding it into filemap_release_folio(): +++ b/mm/filemap.c @@ -3981,6 +3981,9 @@ 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_needs_release(mapping) && !folio_test_private(folio) && + !folio_test_private_2(folio)) + return false; if (folio_test_writeback(folio)) return false;