Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1697825pxp; Sun, 6 Mar 2022 23:48:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/uJsol6dSmkKfwaVWGKpXgnuPF089S6HABxqqmqnUIyll9fWPAsyHLH3gSbUWaWSoC7DD X-Received: by 2002:a65:43c8:0:b0:378:7add:ec4c with SMTP id n8-20020a6543c8000000b003787addec4cmr8496099pgp.570.1646639339023; Sun, 06 Mar 2022 23:48:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646639339; cv=none; d=google.com; s=arc-20160816; b=q+tqPb5cMEuU/U617pE7+MUiVk9NMytIs19F+XStWrGKnsInPXZuZaN44HXYw3io+y Wjd/42Q5kxhufu0CyQ2S7xQDWpSGadq954zRJ6H1chYC3ySZz5yrbTnfWRejMkblL3gQ 0leSio4cZTC23fWLRxOXDVfxdIH8DPRkLK8DsjP08Za8B2HB9NTcfkHByFXS9gKXa5eZ bIWnCJXByMvb+fb4ytpFoR6VPvjWO2ejHsAozg1PEvQjAcbBURQSpsEhoh6+myqPK2xD HYMpShfzle6k9vkTummRnbIgGlVWu1rOhQaVAMtJbb8ndckJ3SJbBe903vmuqDxpNWdg O5Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=S61tyqMXjWaCcg4OR/0YRyCYd3Nii2IGwrjvsXR3WMM=; b=rqJQp1sIWD6988VtzwumlOiElEP2MYVIXrFF1CIZTYRWyWLM5HsdU3BCexpK6ouezF +WNHE6k+0dcyoyeCfK7qEIMrCkEww4FOTr4FpD8hpdDAM+Cmb/4oDPwu93db12bhh0Qn +meoSaldzIDg7oBghC/weLKqxbFHY0AqXiZWsggmeuvOuoULmAKw3lIr53hZxOOxuNYk gDwSWdvDjXpdKI+rJB4decGgrYR6JK72yRpMbcNhfJYmCIek9zly2efa34nhqgD1bSGL JO5ut4UdSdFCKff7sSISxBCZxiOl+Sg7Gql9Lsbf43BhYO4qRuTuM1t+4omUUgqPzczh wJqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 i12-20020a17090a64cc00b001bf3ba2f025si6151603pjm.107.2022.03.06.23.48.45; Sun, 06 Mar 2022 23:48:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233728AbiCGGpe (ORCPT + 99 others); Mon, 7 Mar 2022 01:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiCGGpd (ORCPT ); Mon, 7 Mar 2022 01:45:33 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED633443F9; Sun, 6 Mar 2022 22:44:38 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 4130168AA6; Mon, 7 Mar 2022 07:44:34 +0100 (CET) Date: Mon, 7 Mar 2022 07:44:34 +0100 From: Christoph Hellwig To: Hugh Dickins Cc: Andrew Morton , Christoph Hellwig , Mikulas Patocka , Zdenek Kabelac , Lukas Czerner , "Darrick J. Wong" , Miklos Szeredi , Borislav Petkov , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH mmotm v2] tmpfs: do not allocate pages on read Message-ID: <20220307064434.GA31680@lst.de> References: <20220306092709.GA22883@lst.de> <90bc5e69-9984-b5fa-a685-be55f2b64b@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <90bc5e69-9984-b5fa-a685-be55f2b64b@google.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Sun, Mar 06, 2022 at 02:59:05PM -0800, Hugh Dickins wrote: > Mikulas asked in > https://lore.kernel.org/linux-mm/alpine.LRH.2.02.2007210510230.6959@file01.intranet.prod.int.rdu2.redhat.com/ > Do we still need a0ee5ec520ed ("tmpfs: allocate on read when stacked")? > > Lukas noticed this unusual behavior of loop device backed by tmpfs in > https://lore.kernel.org/linux-mm/20211126075100.gd64odg2bcptiqeb@work/ > > Normally, shmem_file_read_iter() copies the ZERO_PAGE when reading holes; > but if it looks like it might be a read for "a stacking filesystem", it > allocates actual pages to the page cache, and even marks them as dirty. > And reads from the loop device do satisfy the test that is used. > > This oddity was added for an old version of unionfs, to help to limit > its usage to the limited size of the tmpfs mount involved; but about > the same time as the tmpfs mod went in (2.6.25), unionfs was reworked > to proceed differently; and the mod kept just in case others needed it. > > Do we still need it? I cannot answer with more certainty than "Probably > not". It's nasty enough that we really should try to delete it; but if > a regression is reported somewhere, then we might have to revert later. > > It's not quite as simple as just removing the test (as Mikulas did): > xfstests generic/013 hung because splice from tmpfs failed on page not > up-to-date and page mapping unset. That can be fixed just by marking > the ZERO_PAGE as Uptodate, which of course it is: do so in > pagecache_init() - it might be useful to others than tmpfs. > > My intention, though, was to stop using the ZERO_PAGE here altogether: > surely iov_iter_zero() is better for this case? Sadly not: it relies > on clear_user(), and the x86 clear_user() is slower than its copy_user(): > https://lore.kernel.org/lkml/2f5ca5e4-e250-a41c-11fb-a7f4ebc7e1c9@google.com/ > > But while we are still using the ZERO_PAGE, let's stop dirtying its > struct page cacheline with unnecessary get_page() and put_page(). > > Reported-by: Mikulas Patocka > Reported-by: Lukas Czerner > Signed-off-by: Hugh Dickins I would have split the uptodate setting of ZERO_PAGE into a separate, clearly documented patch, but otherwise this looks good: Reviewed-by: Christoph Hellwig