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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A13F3C4332F for ; Tue, 15 Nov 2022 09:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiKOJmA (ORCPT ); Tue, 15 Nov 2022 04:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiKOJly (ORCPT ); Tue, 15 Nov 2022 04:41:54 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58431581D for ; Tue, 15 Nov 2022 01:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668505260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jXxnn30oH1htkAEq4c8BajVXG6A/m7p7p9RvVlC1SI=; b=BZZzad5u2crP14GolV0bGQ1WW1AbJAZ5api3d8MYMO+UzyG1DQME240bknXjd/fNOtQ/rp WOapD2ShUltu692SortSEW17xQLytfZCVgUP8KzAHywmOFQddMJ9pXWSGT98i92X8zUp9V 5ZPUjQoQ6M0QgOy7U+S+qkb3kMlCqJc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-373-MkvcghZ8OraPCsSquUNZLw-1; Tue, 15 Nov 2022 04:40:54 -0500 X-MC-Unique: MkvcghZ8OraPCsSquUNZLw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0E008027EB; Tue, 15 Nov 2022 09:40:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9A352024CC0; Tue, 15 Nov 2022 09:40:51 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <166844174069.1124521.10890506360974169994.stgit@warthog.procyon.org.uk> To: Matthew Wilcox Cc: dhowells@redhat.com, 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1493971.1668505249.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 15 Nov 2022 09:40:49 +0000 Message-ID: <1493972.1668505249@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Matthew Wilcox wrote: > 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 =3D 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? Why does the function do: if (mapping && mapping->a_ops->release_folio) later then? There are callers of the function, such as shrink_folio_list(= ), that seem to think that folio->mapping might be NULL. > Also this is the most inconsistent style ... Yeah, I accidentally pushed the '&&' onto the next line. > > @@ -276,7 +275,7 @@ static long mapping_evict_folio(struct address_spa= ce *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? Errr, yes: static inline void folio_start_fscache(struct folio *folio) { VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio); folio_get(folio); folio_set_private_2(folio); } Someone insisted - might even have been you;-) I'm working on getting rid of the use of PG_private_2 from the network filesystems, but it's still in progress. Kind of blocked on the iov_iter stuff. > > 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() That would be nice, but there are still places that check it, and until we= get rid of the use of PG_private_2, we can't reduce it to just a check on PG_private. Truncate, for example, checks it to see if it should can ->invalidate_folio(). It's only used in mm/, so it could be moved into mm/internal.h. > / page_has_private() now? That's used in some a number of places outside of mm/. The arch/s390/ usa= ge is just to calculate the expected refcount. I wonder if calculation of th= e expected refcount could be potted into a function as it's performed in a number of places - though the expectation isn't always the same. Ext3 and fuse both use it - but those probably need to check PG_private_2 = and could use a "folio_test_private()" function when fully foliated. David