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 666F2C2BBCA for ; Tue, 25 Jun 2024 14:46:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDF736B0085; Tue, 25 Jun 2024 10:46:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8EF26B008C; Tue, 25 Jun 2024 10:46:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A567D6B0092; Tue, 25 Jun 2024 10:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 839656B0085 for ; Tue, 25 Jun 2024 10:46:03 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8DF36A14F6 for ; Tue, 25 Jun 2024 14:46:02 +0000 (UTC) X-FDA: 82269685764.10.BD310DB Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 5094518000C for ; Tue, 25 Jun 2024 14:46:00 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719326753; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j5ith9xZDJo8UPQgkxeZhTOHS9ehcP/L12iflSzcm18=; b=uzJbTNMxwg5pVhWW//1sb3BnkE4CkM2Tj/z5Y4TyCN0JeSEcDZQQaWGapXxGqRpQhD0YZs LEI856iVSItPbjazDNDTpmHS93vTnACAf9cHojimc3Ysc+ZpA4zXUEjOidL5nz7jC3cBjt dh/jnHSWJ/O87E2oCAqBUydfjkjNU20= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719326753; a=rsa-sha256; cv=none; b=J/TEodmcE1JnZRG888DEJodSc0M9396fvZ+IqVf47tQvuDcxSAc2j/b1fSsXTY4PdT2Nei m4kluMJZTpPaIv9YkT7YAw6KlRMjvLwKYeV2iZEIi+1ae8U83cSSf2l4c75s0l9xuZOfq0 6kj0bE0eiE5jjt6wqp1SofoLCr/mxnE= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CD45339; Tue, 25 Jun 2024 07:46:24 -0700 (PDT) Received: from [10.1.39.170] (XHFQ2J9959.cambridge.arm.com [10.1.39.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF0363F73B; Tue, 25 Jun 2024 07:45:55 -0700 (PDT) Message-ID: Date: Tue, 25 Jun 2024 15:45:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 18/18] arm64/mm: Automatically fold contpte mappings Content-Language: en-GB To: Matthew Wilcox 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 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> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5094518000C X-Stat-Signature: fy5ida74cpeqhaxzyt7ube5m87tzqhj3 X-HE-Tag: 1719326760-680249 X-HE-Meta: U2FsdGVkX1/eOqKVYNyZZo4iMmNjh0UgQpTlg9PXyO0DtbYzV3eqRdSecGbXSsLOlfA1+vtqUBzCNFtYZtQyT/TLIKE9hIzQdsNafsY7GumzNGto7K66vbpR/NJga0/1cz5p13zHdvmFoBe3QPa8dT1oNqDZGgY4/e84/47HYMljtWJ06b6PONy8GXH6uPPlrJFEoI0EdxCJEFF0dQAnI/MQAUbDnZrKZ816xs+JfHd+5xiGvs6u5dzQpPVw1rhhw3bdgBqK0APmJGpkIduZzHqlseMDeTO/ScjqVg0Wi3lgOuGuE/+ypfKBQXrGsshDkiBibjJGjAoAVK7eRGfY9m5caCcHfpim9/jj8PHIvOmSLa6wEM9gX19NWvOQiIRocB9LzBFCqzoNdn865UmgTcRF6b5mUOvO7dy3sP5eVuuqK7l7pSl2mw4rH3tZdVRm7663foDC2t0p/NZ+WWeZ1rDzFsO76b/gTNYMAw4pN5e2eD5ZIPYgbljfgngV5EiRFW9ee5AN/8QU0xlg0I9QlAZF7FG4nqMlCc6HDcW05xaxlgST/mDuiqskMU1/CVqRB/70GTGqRI42iDKKFlzAwhzLmJb+wY4P+youGGCBz3gXSC6Zdz1SXeemaSDAEotUjYOkEh+Uh9B3iW4gsK7q0Cf2UUFY9TxKcpKz+3TIIESS2/xQRh9dzYQAUkUGpQNoY9CyL7r7gjM/0abW9brfXagC53Rh1NrjM2AWvH9nU1tzK8LFCbsd+vhcce4pR6NNuGWFkF1hapKvA9DFz1Nglo69Wq0jKiBZAPyK35xiuCgHaQNYxAJvxuZUfUUjmBQcyOAo62WC6kV8fV/vlZSig+Mn2nOFwk7sn/RVrduJGMJ2Riqaq/c+rFUeoPJgfNExF8uba18lrvldK034P2Shqq0r2lZSJoA382/gbG7oe8xHLWfQvnjI4UQVW+6nSxmDTHetsCcSrd+X9uW2tT0 G+2TEKRH mS6Zz8R+Dr2zgm9S6L/S4d5H5Q/qQLX2sGchro+17Ykd22RNYT3+juWFCDWUlCxMCjaMZcm1gCNDGjuJ3Dv9zYqGTM3/Bc0iXe6zLrATQMR5sYeOep2FzPco8u38UepXc+cZJYPWyquDOgFvFLIbNtVlQbzQ85jqi42D13BfO9csqCWAbrt5I8G1T7yaRNgxPUNnSiE8gk2l4HGRRf3kIBQa2sw== 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 25/06/2024 15:06, Matthew Wilcox wrote: > 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. OK that all makes sense, thanks. I guess it just means I don't have an excuse for the perf regression. :)