Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3479645pxp; Tue, 8 Mar 2022 15:31:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG71dVKWtCse2Oq+wdz7BhaIAuZ18KIga4Dq1L9cxZ/HW5pVyMizzY/4rMRjvTFQgHFi9H X-Received: by 2002:a63:4a44:0:b0:372:db13:5583 with SMTP id j4-20020a634a44000000b00372db135583mr16077044pgl.210.1646782288167; Tue, 08 Mar 2022 15:31:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646782288; cv=none; d=google.com; s=arc-20160816; b=OwnxkAUqvf07Lg3kHL8URCR1Zl1/0O+KcXFK/m7IIaAKfAcum8zOcr2xsdWz4iRRtU ajl5VdeQDksM2ojG2X1CTnZlz376Z114TDONn83ZNqbvDFIc2lx7TaDzZ2QdXRELkpaS kinbwFQD6iL0zlJUrsfWhHYQizSt/VUhCM5IL4lxu2ipv/xme8fVGaizyZCndZDDSLiS FBswloMm34zAaulDxqy2GWq7PXI5sW3w8AGgw6QXW1BotY09+QL0slwudE4M+cpXw/Vy suwPrDh6szPtqsif5C5fchY6wditIRmy/5CSg24BKyA+cDMGJbTw+2EAuM91YJXCcrq/ b07g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IEARDqji+mkAe46Wz/dI63WRKETUtSJlyM/Ux3iQmRA=; b=Y6Hzy1jDiGw8hR41vPu5kxZF1Ipfu69Xnd4G6c0CdBzNp4afsp04/lM6cQl2XxaEHM QBWbMm6PrHRy2sKJzCUBcUZA4gNidzG1/MRNs/bKNh/h/N5/pe2B4G6Ike1+zztz6ZzS K4W8mc0gWqMIK2EfTZEBXzVDeVAHF6n7RrXB6zQ5rqs8JJ0NhXCx85hccd1+IAFVy7EX vsADK553F5WBcohuIRoD0Y0w7OiqZgDbe0og1iF42DuOI2Mvf90OtdM8I9gESSDScgtd sW+x+Z4NWNvkhJrK0VmmOAOdqx6XtquDVavyB+9OglkkotGvH571V3u5u8T9tDs73/vs 0NtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dM3LX4E3; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k70-20020a638449000000b0037c8b66e34bsi211096pgd.552.2022.03.08.15.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:31:28 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=dM3LX4E3; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 58F03A651D; Tue, 8 Mar 2022 15:20:07 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349152AbiCHR2j (ORCPT + 99 others); Tue, 8 Mar 2022 12:28:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349154AbiCHR2g (ORCPT ); Tue, 8 Mar 2022 12:28:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FF2F7B; Tue, 8 Mar 2022 09:27:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DCA1B61306; Tue, 8 Mar 2022 17:27:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45E63C340EB; Tue, 8 Mar 2022 17:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646760455; bh=Wyo7DT2LJqEn+VENd6dCx837uI7HnqAB2NMm453HARc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dM3LX4E3Qz2mCJs1OHF05HvFyJsXPwfK12g/YyBr9000rhGAq4e5fs4GHZ+vYJO2I iEwMLBkTqGImqGhmTWvmELXgLU+flvjC5qVaCuNSk/SK+MH5cCDLcdW0RrKLIydWEq Ls62QOa+hahmahJmMj7KACEMhGwO914/OtLqbj4y5OJzW4Ca5QgUBpvGjTerxD7siH pm3Dw4DPbIHgD1T2kHs+MopokIKVssFgGej0bi8qrRsidue/qdjNoCprDzjFt6oBlW dMgPF+Wa2U1E0QNV4/m43xQ1xonN/sTGRRy7u8wtDI3F3QXmt4WSCEgws4AztjIefd 9Qca7ysLr1XOQ== Date: Tue, 8 Mar 2022 09:27:34 -0800 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Hugh Dickins , Andrew Morton , Mikulas Patocka , Zdenek Kabelac , Lukas Czerner , 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: <20220308172734.GC1479066@magnolia> References: <20220306092709.GA22883@lst.de> <90bc5e69-9984-b5fa-a685-be55f2b64b@google.com> <20220307064434.GA31680@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220307064434.GA31680@lst.de> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, Mar 07, 2022 at 07:44:34AM +0100, Christoph Hellwig wrote: > 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 I've long wondered (for my own nefarious purposes) why tmpfs files didn't just grab the zero page, so: Acked-by: Darrick J. Wong --D