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 933F1C433F5 for ; Mon, 7 Mar 2022 06:44:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E39E78D0002; Mon, 7 Mar 2022 01:44:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE9938D0001; Mon, 7 Mar 2022 01:44:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFF998D0002; Mon, 7 Mar 2022 01:44:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id C0F178D0001 for ; Mon, 7 Mar 2022 01:44:39 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 703E1A78D5 for ; Mon, 7 Mar 2022 06:44:39 +0000 (UTC) X-FDA: 79216651878.29.869B171 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf27.hostedemail.com (Postfix) with ESMTP id 755B740002 for ; Mon, 7 Mar 2022 06:44:38 +0000 (UTC) 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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 755B740002 X-Stat-Signature: itu6tohzxjeb4eom1hhsaf4szhehg7hi Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=none (imf27.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de X-HE-Tag: 1646635478-462035 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: 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