Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp48755pxh; Thu, 7 Apr 2022 13:36:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPpEQoTEMvBMEou1oNQ0D2LWLtqoV6oe/CCxld/uvI9RcSPei2HCFQGrXpuJ9F3qcnkabl X-Received: by 2002:a17:90a:bf12:b0:1ca:69bd:9a10 with SMTP id c18-20020a17090abf1200b001ca69bd9a10mr17753267pjs.92.1649363781116; Thu, 07 Apr 2022 13:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363781; cv=none; d=google.com; s=arc-20160816; b=jIbnPepML3eFLFWYqIrGOssUHBmbq4ZJ2yMVRF1TG+Ez46/naBJrBx/IbCE2Cc0Xx+ rL0QRbM65Rp7d8TKV+CvRCI3ePhPlpwLhRznTxWTfatsYRYQxaHEwbZJ+/QqO/Ts4FtK uemHLaK60VWCV4o1iECJyevn/rTTdkx335PSYPQ4TfPJ5iwZsAImPah4y+dyp6blEw77 piadjLKU2s7G/cZtHFIqAqA632dbMTtB9dECGcCanHrls2ieZND3CXWwhp3s+zXq9A0V nD+PCv8Ej+hYVtR++eri/LLP/ALqaJU7ybg1y2vljsZBgxdLedZmWM3bhMlzzwa6x9tL DK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=ghX0s+qnM0zTWcdVKam262S3A8knYr1UnlFhPf0e+YY=; b=lGHFr97SChUTGSGPQnvkQt6/Vw3Ehf+jJSXxvjsVFgM/hAf2tPuvWruNpM+8iTuCWu i1zEDmOmZ9TG3W5doqWThCYyNO446mv3eHIWyw33fDG/wmeXSLy+iA8k6S2zhTQFlb6P hLNCDq4sxKfH0F6AQycrVkW1G0EjFJHx2+XjX9gYnPw3JgSBDhgtGTWhmi9S+Vb5qZPW xQsj8gB225j1Y+73fIN4WYDHc9Vu2fY0DnFrN9fRu/giwG2XfG5R3PzCwtyWkog0h5SM APXyQoe2ifpEaSl08sGOCLLEIs4iQPolIl3YySn+Uv+Zr7Hw5go8MAZOyCk/DsAfJPDQ vGKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H+mw47uJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m6-20020a635806000000b0039934530043si12554020pgb.293.2022.04.07.13.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:36:21 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H+mw47uJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49C793AF4AF; Thu, 7 Apr 2022 12:49:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240864AbiDGGoH (ORCPT + 99 others); Thu, 7 Apr 2022 02:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236430AbiDGGoF (ORCPT ); Thu, 7 Apr 2022 02:44:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B53A11BE4D for ; Wed, 6 Apr 2022 23:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649313725; 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=ghX0s+qnM0zTWcdVKam262S3A8knYr1UnlFhPf0e+YY=; b=H+mw47uJ+hqBffm/n0apuB6CUrDEgyYnmHVMCXA2J3h/VdPMKicGGvjoQ1BClxkn2D/Vih bTOHxb+lMDEWbL+LUtf2r/bcXQE6IxsFeJ0GzkqMrMkYVvd+YaR5DtG8bN+1lZh4iO5TT3 jNzzL2Jtq620NFZZEImZ3kbEpFM3hBk= 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-79-HESEfiTVOlu5reogbnkCLQ-1; Thu, 07 Apr 2022 02:42:01 -0400 X-MC-Unique: HESEfiTVOlu5reogbnkCLQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B4DA811E80; Thu, 7 Apr 2022 06:41:54 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.37.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id E753D401E2B; Thu, 7 Apr 2022 06:41:48 +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: <164928615045.457102.10607899252434268982.stgit@warthog.procyon.org.uk> <164928630577.457102.8519251179327601178.stgit@warthog.procyon.org.uk> To: Matthew Wilcox Cc: dhowells@redhat.com, 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <469868.1649313707.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 07 Apr 2022 07:41:47 +0100 Message-ID: <469869.1649313707@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 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 fl= ag is > > set when a folio is removed from the pagecache. The flag should be se= t if > > a non-NULL cookie is obtained from fscache and cleared in ->evict_inod= e() > > 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). Another possibility could be that the FSCACHE_COOKIE_HAVE_DATA and FSCACHE_COOKIE_NO_DATA_TO_READ flags could be moved from cookie->flags to mapping->flags and the VM could do the twiddling itself (no aop required) = - except that fscache can't currently then find them (maybe use an aop for that?). David