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 D6001EB64D9 for ; Fri, 7 Jul 2023 09:52:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 528658D0002; Fri, 7 Jul 2023 05:52:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D7978D0001; Fri, 7 Jul 2023 05:52:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C6DE8D0002; Fri, 7 Jul 2023 05:52:46 -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 2F71B8D0001 for ; Fri, 7 Jul 2023 05:52:46 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E6A3880D00 for ; Fri, 7 Jul 2023 09:52:45 +0000 (UTC) X-FDA: 80984351490.05.D5EE3B6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 3027E100019 for ; Fri, 7 Jul 2023 09:52:43 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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=1688723564; 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=T44E6yhPUhlQx4fPHFAqbiEHMt+6vWxLZGL6p9gkIP4=; b=7mUHPM7sij5EL4AKZGyg8hXwH7ZS00qqiekYVgmPGcHr5ZVRFoSx+BFLGGxnuyA+VTEzoi ZUmVqF+VsRnKFWBuIwhIhH5HOGJOPF2FHqqb/PhoUgvYd9IRorBXEz0Ct7SBGXB+Yz29hR FuTbLVFJ+zmkyaHl136Y5oNMAxgiyVY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688723564; a=rsa-sha256; cv=none; b=VZV07WIQ6hqWa6LxSw5N+NY4vKV9OP+JZrRs0lUjfuzziaJ5+0gbkL3sw9o3YCGgg09PNY Z3azoUzlllTfChQD1j83H/p+RW9tU659L6Wo7OkndLaUnfJmUiHplbwwx87cgGhLc4hzy3 ECrao3iJmJV24q3dlXqJR3itBCdzDZw= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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 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 59F45D75; Fri, 7 Jul 2023 02:53:25 -0700 (PDT) Received: from [10.57.77.63] (unknown [10.57.77.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEF063F740; Fri, 7 Jul 2023 02:52:40 -0700 (PDT) Message-ID: <44e60630-5e9d-c8df-ab79-cb0767de680e@arm.com> Date: Fri, 7 Jul 2023 10:52:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2 4/5] mm: FLEXIBLE_THP for improved performance To: "Huang, Ying" Cc: Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , Yin Fengwei , David Hildenbrand , Yu Zhao , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230703135330.1865927-1-ryan.roberts@arm.com> <20230703135330.1865927-5-ryan.roberts@arm.com> <87edlkgnfa.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Ryan Roberts In-Reply-To: <87edlkgnfa.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 3027E100019 X-Rspam-User: X-Stat-Signature: 3dgss5rkfduycn6gh64c8p93r5m3xiyn X-Rspamd-Server: rspam03 X-HE-Tag: 1688723563-753104 X-HE-Meta: U2FsdGVkX18KC3Z3Z2gUFeel6qxMQKsPnLTvHet+pp9Xabd1PDginn87pAHdsOGxsntmVWTSA64eAbhR5sBZe5M9KOGgjojDyxEoPsgsPNC7rny8xfyxxizYOGus4xvi4W67+vMd0sQNK1NFASg6iyN3BbP6IeHtGyhMzX2qGv4kvng4Jc6wooIxbELazG0CwK+2VApSOgDsMgqxpB7n+jpJwt83DyMyC58K+uBQhb0mPD2EM2GYhSnCXGtXL5vcgoNyc56x7K9bzj0szFDKEsgpnzRGG5dNgqN3zHHfCv7lLhWU6P2ax9eD2gMEJlamujf+kHftAPrHxo5KcPFZqvaiHO87vRpvXoDKgr9jkkvIm2ShAup2WKS9SM7J8OTU9VSBTtV26Wc8BONbd2kB2UO10jbH+yjoYHFwpASGebUEeMWkn5naJpvsZujehvz9Pzlhky9bfyXMo6yr+OQJeqhLx/Pxvz95LkXQvulrc1uuE/C/+QMNRyvrFfiuq2StK4nIPk+uP33WG9eTbbCP/XiytbF8dQP1VQGZxqiySX+A0qo+9ectlsjpFWMwI/wXzIWtRGXEf0TSIxdHsPo0ZqZsxDbLpamK0vjYkNn8dsG0ZDug73ybGwjJpJkMEVVi/urTiSy6I4ezt9EOy+jZOMIGn5R+aTSm7wWKd0ZTFgSVUsNdeelkOMM+qjhCXddyz9nSwYbQjgvpYipS6IbHeFlWKI8038SyhFdc9L3IEjQUVpCI88ogDmGKZZD+M0L334xQFkHbdz+nqimop28Fdcf/dJa/iQtKcPn+WxoczqCfFOgE1RRqn3mul5k4xALwE6HCsioLs2980Mk+OcwWGdvjw4D9Sw5oPJqWEtROLQtIn7ibOIZMDOsA56qEhBbTbZQqc+EzJwCl/FJh8a81r3+Nwz1aolbKgKkEZTTXnHnhKPX772eQJNK+E2dTb8CK1Wrq1eSyQ7eAGL5lJdL sX7ZDagJ OmD0oXpedr+QT2XqMYuVTIRfOV+YFQrzpyRIEZNr0TeIQ5kvq5r7ej4rXoAg1ZQC350msxrK/chez5RNb7plDItSK4o3IsulYNLgj30ecINfCj7eIrAcpQ1uJz7HpA37U3LrIcmFBNuX5REl+VQImFWnbZQdAAyE5voaj+1i1TZSeg2KH57hDCGoaagZ71FwbedziPVLDNfMD6dPX9xaxeXmjWw== 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 07/07/2023 09:01, Huang, Ying wrote: > Ryan Roberts writes: > >> Introduce FLEXIBLE_THP feature, which allows anonymous memory to be >> allocated in large folios of a specified order. All pages of the large >> folio are pte-mapped during the same page fault, significantly reducing >> the number of page faults. The number of per-page operations (e.g. ref >> counting, rmap management lru list management) are also significantly >> reduced since those ops now become per-folio. > > I likes the idea to share as much code as possible between large > (anonymous) folio and THP. Finally, THP becomes just a special kind of > large folio. > > Although we can use smaller page order for FLEXIBLE_THP, it's hard to > avoid internal fragmentation completely. So, I think that finally we > will need to provide a mechanism for the users to opt out, e.g., > something like "always madvise never" via > /sys/kernel/mm/transparent_hugepage/enabled. I'm not sure whether it's > a good idea to reuse the existing interface of THP. I wouldn't want to tie this to the existing interface, simply because that implies that we would want to follow the "always" and "madvise" advice too; That means that on a thp=madvise system (which is certainly the case for android and other client systems) we would have to disable large anon folios for VMAs that haven't explicitly opted in. That breaks the intention that this should be an invisible performance boost. I think it's important to set the policy for use of THP separately to use of large anon folios. I could be persuaded on the merrits of a new runtime enable/disable interface if there is concensus. > > Best Regards, > Huang, Ying