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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5595C4332F for ; Tue, 15 Nov 2022 09:41:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20C096B0071; Tue, 15 Nov 2022 04:41:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 195A96B0072; Tue, 15 Nov 2022 04:41:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 037E86B0073; Tue, 15 Nov 2022 04:41:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E50D76B0071 for ; Tue, 15 Nov 2022 04:41:00 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B24ADA0FD6 for ; Tue, 15 Nov 2022 09:41:00 +0000 (UTC) X-FDA: 80135182680.02.06085D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id BC39B4000B for ; Tue, 15 Nov 2022 09:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668505259; 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=JG7XnaBW7BYDgjhiTFGHCngASN9puOYOTtAxmPH7xnofTJR4+BUbpAbaQzNpNWzL1v8MqU 5E3xW9KEtRuRVs8DEh05ZkJ9QBDykxiJ7wcHOkN+hErZM1Gj5GDGaLqxJ19Uq0jYl2y4/Z U5h4sZc8Clf8kUowZRRTMkXxzHlUvNU= 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 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JG7XnaBW; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668505260; a=rsa-sha256; cv=none; b=mNd+dtNLrI2PwSeRRwrEJH2dyOYmse5RCLg1FlLzwuToTv8dz9Oqrg9UlznqPLYj0jkMpb Pmw1xiWS7kqZ02eUmfw3DLUGDj8DwqfUlqywk5qbpcrUMr4lVNhZFcXLW5k7ONFVP0kwBL wV4FSr+C6YaqrZjc32WhkFgyAcDk4Ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668505260; h=from:from:sender: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:dkim-signature; bh=/jXxnn30oH1htkAEq4c8BajVXG6A/m7p7p9RvVlC1SI=; b=xe+V3Jz6D3HFeUYR/wATOaK5afjzu8pAZ2e9Uic5z6pdxKrEl/am9lUuACb/D6ZZlq+30Q xQ35kuSdbrLWVsw9x+G/45q+yB75lKo/qwJpsWC0ey3Wv0Dr2tuswS9tHYmqW55Xrj71Qx 2fg8ti1kHmydSdeuQ5byCYoUoxZPLuM= X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JG7XnaBW; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: mhfqiqwttddy44t6439ejx7ycnmjdeb8 X-Rspamd-Queue-Id: BC39B4000B X-Rspamd-Server: rspam09 X-HE-Tag: 1668505259-101241 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: 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