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 7EE1FC2BBCA for ; Tue, 25 Jun 2024 14:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA9FE6B02D4; Tue, 25 Jun 2024 10:07:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E59776B02D5; Tue, 25 Jun 2024 10:07:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF9F86B02D6; Tue, 25 Jun 2024 10:07:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B11746B02D4 for ; Tue, 25 Jun 2024 10:07:05 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6F78C14189B for ; Tue, 25 Jun 2024 14:07:05 +0000 (UTC) X-FDA: 82269587610.27.364473D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id E57B116000F for ; Tue, 25 Jun 2024 14:07:02 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=b3anXdf6; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719324409; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hGiPM6C5L/nRqsdu3jq0C7CbnwzvLeffETFeFxTX0+E=; b=d8ZdwWxA0ppHnHb7wI2zjqf7MbYr6xBbNktg/gQiBf+7rdRDvGyWJL+kmV5hMq8Q5g+TVy rBJRlPHaaeabMFylp0WHqKQxzKE5eRSdJ9ZOzGvXajV3N892vFbqmdChWC19nM+2+AS0JI rpBzBC510CEW8E9W2mrraXtWmk1ff84= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719324409; a=rsa-sha256; cv=none; b=dPmfmM+4UIcX6kTq4ARJenCnAEHTP4lKdZ5jzPFii2oHdOCTNSKhzjAnie6JswguQW9oFg Ms+LnmvN4Tr1uQamgcZ40AaYOu943EtV+b22PU2P4DI5So8RRSJlAdzNoW4L2XgTq8XDRx 1aosY8kBIagN/SzoFRnrC1zj7f4M/x8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=b3anXdf6; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hGiPM6C5L/nRqsdu3jq0C7CbnwzvLeffETFeFxTX0+E=; b=b3anXdf6y1JVACdaTmYa87Qdwz IXn7N2bJIfzk9KNwWXeg8tumh7lqXZTBdx3GEINGv9BNJyMrvBKM/tmlyIK+vjWWO7lMBqI2/gW4N XQP8c9u0eYpqkmTL11wjuLbSi2rQCqK2/qoiw2rq7DlGfa9/ApwsOpqEbj3j0JZ+Uy58IC72wpm44 RVUjYWXi/WdkaINNa8n4X8Kgwq91tskrXsMl9afIlOrW59G3xNzWOCh56uVJUJram+C2/i0JjGNRT VvpU11sKddLUsxQfVklfujUBPT4Ny+My7k0dM+8H17DBjtzWVsKSKnjwEbtWus2udI+8mjTe8+C63 EkRPsf+A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM6oT-0000000BCMT-2TZf; Tue, 25 Jun 2024 14:06:25 +0000 Date: Tue, 25 Jun 2024 15:06:25 +0100 From: Matthew Wilcox To: Ryan Roberts Cc: Baolin Wang , Kefeng Wang , Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Mark Rutland , David Hildenbrand , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Yin, Fengwei" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 18/18] arm64/mm: Automatically fold contpte mappings Message-ID: References: <20240215103205.2607016-19-ryan.roberts@arm.com> <1285eb59-fcc3-4db8-9dd9-e7c4d82b1be0@huawei.com> <8d57ed0d-fdd0-4fc6-b9f1-a6ac11ce93ce@arm.com> <018b5e83-789e-480f-82c8-a64515cdd14a@huawei.com> <43a5986a-52ea-4090-9333-90af137a4735@linux.alibaba.com> <306874fe-9bc1-4dec-a856-0125e4541971@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: E57B116000F X-Stat-Signature: 5yqmpx7y7jdo3qya9j1t3nnu1c5xru18 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719324422-398201 X-HE-Meta: U2FsdGVkX1///emrGlJxOJ3fLFyZxuEJh/VJw84mnA4M4i7NqOfkWXYJAYmhBlsBgRLxss45p5odzOF7F8M6LoYnFprN0rKGCOcYzKUU+IQX9eFfcTTEtcspUwiKsX3PIb+OfB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7/oFHcCq2txlA9t/8Xd01MRCAr8is3Bvwq9z/EH+E+ES4Mmg== 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: List-Subscribe: List-Unsubscribe: On Tue, Jun 25, 2024 at 02:41:18PM +0100, Ryan Roberts wrote: > On 25/06/2024 14:06, Matthew Wilcox wrote: > > On Tue, Jun 25, 2024 at 01:41:02PM +0100, Ryan Roberts wrote: > >> On 25/06/2024 13:37, Baolin Wang wrote: > >> > >> [...] > >> > >>>>> For other filesystems, like ext4, I did not found the logic to determin what > >>>>> size of folio to allocate in writable mmap() path > >>>> > >>>> Yes I'd be keen to understand this to. When I was doing contpte, page cache > >>>> would only allocate large folios for readahead. So that's why I wouldn't have > >>> > >>> You mean non-large folios, right? > >> > >> No I mean that at the time I wrote contpte, the policy was to allocate an > >> order-0 folio for any writes that missed in the page cache, and allocate large > >> folios only when doing readahead from storage into page cache. The test that is > >> regressing is doing writes. > > > > mmap() faults also use readahead. > > > > filemap_fault(): > > > > folio = filemap_get_folio(mapping, index); > > if (likely(!IS_ERR(folio))) { > > if (!(vmf->flags & FAULT_FLAG_TRIED)) > > fpin = do_async_mmap_readahead(vmf, folio); > > which does: > > if (folio_test_readahead(folio)) { > > fpin = maybe_unlock_mmap_for_io(vmf, fpin); > > page_cache_async_ra(&ractl, folio, ra->ra_pages); > > > > which has been there in one form or another since 2007 (3ea89ee86a82). > > OK sounds like I'm probably misremembering something I read on LWN... You're > saying that its been the case for a while that if we take a write fault for a > portion of a file, then we will still end up taking the readahead path and > allocating a large folio (filesystem permitting)? Does that apply in the case > where the file has never been touched but only ftruncate'd, as is happening in > this test? There is obviously no need for IO in that case, but have we always > taken a path where a large folio may be allocated for it? I thought that bit was > newer for some reason. The pagecache doesn't know whether the file contains data or holes. It allocates folios and then invites the filesystem to fill them; the filesystem checks its data structures and then either issues reads if there's data on media or calls memset if the records indicate there's a hole. Whether it chooses to allocate large folios or not is going to depend on the access pattern; a sequential write pattern will use large folios and a random write pattern won't. Now, I've oversimplified things a bit by talking about filemap_fault. Before we call filemap_fault, we call filemap_map_pages() which looks for any suitable folios in the page cache between start and end, and maps those.