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 1744DC36013 for ; Fri, 28 Mar 2025 13:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8591280147; Fri, 28 Mar 2025 09:50:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B35B128013E; Fri, 28 Mar 2025 09:50:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2435280147; Fri, 28 Mar 2025 09:50:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 85ADE28013E for ; Fri, 28 Mar 2025 09:50:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E2CF3120207 for ; Fri, 28 Mar 2025 13:50:57 +0000 (UTC) X-FDA: 83271095754.06.A37CCAA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id CC55D1A0003 for ; Fri, 28 Mar 2025 13:50:55 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743169856; a=rsa-sha256; cv=none; b=Rt7T3APG+DjXPhpCSEpydc5NmpQuyNzFyc+sQarkIJ0c4WVfKfZzKeDrasvA2ezaIwbmbb h2AnU+Y45BDrJn+HehnUzYfgkncSYp4fHhXeo4KQ+jzrw7gLtKHNyExMMs8/qCVDmC9NBt xt9EUjZHUEYaXS0j/a17p8Adq3pcC9Q= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743169856; 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=/Ogm0LJ7VkP94MhhD6dwlFnwqrw4sCcq6nxTdivNOtU=; b=qZOpmCIstonzxO7i8+zocBGQVXkjouY/muDWNTKU9mKruKPP6brUhyusjgVHY9crVlf+0T 0QaEGJ8mYIvVzmF9jf4nxFKvIhFMbwAViodZpuSok+IG7MPfhiQtEnt3fJ2pjBxTQryoYg 0uZHToS5p09hM3AK9jdY1ZET3MFIhg4= 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 98F041691; Fri, 28 Mar 2025 06:50:59 -0700 (PDT) Received: from [10.57.87.112] (unknown [10.57.87.112]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1646F3F63F; Fri, 28 Mar 2025 06:50:52 -0700 (PDT) Message-ID: Date: Fri, 28 Mar 2025 13:50:51 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/filemap: Allow arch to request folio size for exec memory Content-Language: en-GB To: Zi Yan Cc: Matthew Wilcox , Andrew Morton , David Hildenbrand , Dave Chinner , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20250327160700.1147155-1-ryan.roberts@arm.com> <731D8D6E-52A0-4144-A2BB-7243BFACC92D@nvidia.com> <8DEB30F0-52D0-4857-9BAC-CDAC045A396E@nvidia.com> From: Ryan Roberts In-Reply-To: <8DEB30F0-52D0-4857-9BAC-CDAC045A396E@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CC55D1A0003 X-Stat-Signature: a9i6jdh5pmttubg6uxuhj5nsccbmr13g X-HE-Tag: 1743169855-61779 X-HE-Meta: U2FsdGVkX1/VMQqzJqmWNQi+Ga+Q6xS9avBbuKVy+zqIaaHo9Gpv/coVn9PJNDxQB9ZO4HAKv3K8YI+ltf8MO6DYWN/qQiq6L5JN8j3r0uPmUhT42DOnNjBMTr/eQAIr0wl43v80bBwm2VQMwN9/FBYjriKVLgyQF3dAeFa8IN64UqV9udp/rmOYLGamzt3xTjyj+QqiAMsvfMxT2TCwQmn5eQJlo0G6qUJV8sTdYo1L7PYDT6rbtd3ViIUuvSU7v+D6pyJGoKmztHJGwV7I93mKck2ivmKiwEDchWhAP21qQm9mFBldBsET9pYRmcZcNBEjjcjtHsci8E00B3lu25MthRlzvNvDnWVqXnfbbekM0G2UJYibNstI8HFPLy1sXT69OQFSTfJzxyTuqdr5m7/TE9ZLe73bOZz5Mw5S5iBCI5aU5cfDp8B8S1w2d/gnbBZxnBd80NcG/R6xpbi0iFcyG0Kr/xIwKLMbCexHFRJM1tEFTlTbwAmT5I7eAwhjaZ4gQxVZCbIUleGyaioyFWHec9zOYj6HWXhqD0E9Fz1h+hUACZJEgK1dWa4Bhv1HIYPHr9SeYXaXXvRUAD7CWrMthYLTaTqqexA7jMudbBXMlQ2EDAn6aCTZV2DjvAtFwu2gLRb5Jp6wVcCM0AOPkejrwpJ/UkPe6DQGTvvrMiLioG8a+U4CNfEySSQYzKpv3ggYRaegGZ7n6Y8lf1cqOmdAA6CgE4XKoXwbpXIVsAQBjqtFkv3ELZpnt+LDoEA15nrn0YgViZwI8Fl2bUbwUhaPlrVlNIsUmllpDoN2pe//yG0qbIPExr6U/DJk++iEXOKVDOpmN9HlJCKpPsLP2eR9PIy8099GTYr+gh3i/vs3jab4gdFmJfl9vDycomsBp5uTA9ISE2Qs3VLv/G5SUo0gc9qtCoUJ76uDWlPxIoTyD3N7+WpvLhIJKGlXpx66fHAEG7HqxPAEazhdU7v UoYe7PdO 9eKq84KHfqRvtSH7rs1TCQSkU7WgdW9DQE6C5mH9FSAFHVSV3Z3M42alaY5/NjwigQyi+rKOZQyxLNPGumbiTLAs3MCfDE8Z3OREuVogWUtXdub6FSVrb5Bsx6eXER7mLjlr2ESol02IYsfolEgk3FH/tUUSL530ITMK5dDTourqRWA4= 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 28/03/2025 09:32, Zi Yan wrote: > On 28 Mar 2025, at 9:09, Ryan Roberts wrote: > >> On 27/03/2025 20:07, Zi Yan wrote: >>> On 27 Mar 2025, at 12:44, Matthew Wilcox wrote: >>> >>>> On Thu, Mar 27, 2025 at 04:06:58PM +0000, Ryan Roberts wrote: >>>>> So let's special-case the read(ahead) logic for executable mappings. The >>>>> trade-off is performance improvement (due to more efficient storage of >>>>> the translations in iTLB) vs potential read amplification (due to >>>>> reading too much data around the fault which won't be used), and the >>>>> latter is independent of base page size. I've chosen 64K folio size for >>>>> arm64 which benefits both the 4K and 16K base page size configs and >>>>> shouldn't lead to any read amplification in practice since the old >>>>> read-around path was (usually) reading blocks of 128K. I don't >>>>> anticipate any write amplification because text is always RO. >>>> >>>> Is there not also the potential for wasted memory due to ELF alignment? >>>> Kalesh talked about it in the MM BOF at the same time that Ted and I >>>> were discussing it in the FS BOF. Some coordination required (like >>>> maybe Kalesh could have mentioned it to me rathere than assuming I'd be >>>> there?) >>>> >>>>> +#define arch_exec_folio_order() ilog2(SZ_64K >> PAGE_SHIFT) >>>> >>>> I don't think the "arch" really adds much value here. >>>> >>>> #define exec_folio_order() get_order(SZ_64K) >>> >>> How about AMD’s PTE coalescing, which does PTE compression at >>> 16KB or 32KB level? It covers 4 16KB and 2 32KB, at least it will >>> not hurt AMD PTE coalescing. Starting with 64KB across all arch >>> might be simpler to see the performance impact. Just a comment, >>> no objection. :) >> >> exec_folio_order() is defined per-architecture and SZ_64K is the arm64 preferred >> size. At the moment x86 is not opted in, but they could choose to opt in with >> 32K (or whatever else makese sense) if the HW supports coalescing. > > Oh, I missed that part. I thought, since arch_ is not there, it was the same > for all arch. > >> >> I'm not sure if you thought this was global and are arguing against that, or if >> you are arguing for it to be global because it will more easily show us >> performance regressions earlier if x86 is doing this too? > > I thought it was global. It might be OK to set it global and let different arch > to optimize it as it rolls out. Opt-in might be "never" until someone looks > into it, but if it is global and it changes performance, people will notice > and look into it. Ahh now that we are both clear, I'd prefer to stick with the policy as implemented; exec_folio_order() defaults to "use the existing readahead method" but can be overridden by arches (arm64) that want specific behaviour (64K folios). > > -- > Best Regards, > Yan, Zi