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 BAFC2C54E67 for ; Wed, 27 Mar 2024 17:58:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 311FB6B008A; Wed, 27 Mar 2024 13:58:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C1DA6B008C; Wed, 27 Mar 2024 13:58:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1896E6B0092; Wed, 27 Mar 2024 13:58:41 -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 F01AD6B008A for ; Wed, 27 Mar 2024 13:58:40 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AF4B91C0ABA for ; Wed, 27 Mar 2024 17:58:40 +0000 (UTC) X-FDA: 81943579200.16.4254BC8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 2396640014 for ; Wed, 27 Mar 2024 17:58:38 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711562319; 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=FGNKv2VIjYF+1vr5zVJ0KKfLidimO4k+GmCS7kOGS3I=; b=yjkTJbF0mc9ICCg2iA2ei+8sVxeLBCJ8EpZiwIWLNIENcPBJ9GxA1T4F7nBhmaRLNNsdca p8v2hRGD4vmIqRfZjT97zuJODdXsTiZY28E1fWBh7gPXScrJvZJzJ3QGRR71wL3coVzeXp kA+vlDPiq8RiH9Q+g6YY45Dt3hVjKtU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711562319; a=rsa-sha256; cv=none; b=eZFyDlUttj2Th22oiBB4zxu24wnMaj62SFGPDgRVM0qYwhIIW2AYmY6uZEdVybFS3OegU/ qce7Xb0pNnHMVE5Z90jDE8d6q17UjOYA0ZvuClEnIsyN4jeN6XMX7sB19Wc++xevf90CMy mizD1EIr7PahmUZLyd5lF1VGVMZggfg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1BA836162D; Wed, 27 Mar 2024 17:58:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07BE2C433C7; Wed, 27 Mar 2024 17:58:21 +0000 (UTC) Date: Wed, 27 Mar 2024 17:58:19 +0000 From: Catalin Marinas To: Ryan Roberts Cc: David Hildenbrand , Matthew Wilcox , Barry Song <21cnbao@gmail.com>, will@kernel.org, akpm@linux-foundation.org, hughd@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, chrisl@kernel.org, mark.rutland@arm.com, steven.price@arm.com, Barry Song , Kemeng Shi , Anshuman Khandual , Peter Collingbourne , Yosry Ahmed , Peter Xu , Lorenzo Stoakes , "Mike Rapoport (IBM)" , "Aneesh Kumar K.V" , Rick Edgecombe Subject: Re: [PATCH 1/1] arm64: mm: swap: support THP_SWAP on hardware with MTE Message-ID: References: <20240322114136.61386-1-21cnbao@gmail.com> <20240322114136.61386-2-21cnbao@gmail.com> <1006392c-c437-46c0-9a2e-e25e52236b67@redhat.com> <46ba09c5-4186-4e03-81cc-ca27c0301fef@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <46ba09c5-4186-4e03-81cc-ca27c0301fef@arm.com> X-Rspamd-Queue-Id: 2396640014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 4zx3jp85b88cxpi7d6t8keqkm1ntyyfc X-HE-Tag: 1711562318-973245 X-HE-Meta: U2FsdGVkX19LnZ2lEuyRNE0sumjfC146HI64ZJ2QPCu/ZLYEnDAI4g1CLEwcSneLUHL3p8pITmXCgA+FbYm3O2dT605JYCLnLRa+aeDJ2iSSpxzFAnSvNFyKSdlvPNF+Z6GAHvqr9ErRUYvVGsUJ/0A1PxyTyXoa2QqKv39eN9psJ8ZuEKb7QWceMT4B5BcyU6W7N/wvcnvJBHH6Jsyl86WeoNhsnY746oQHUGqRIB/jwQGGoS+oCzYQVeNwrhTr/SnMOAFpz99EEv8CZAJInkk3BNxU9Iu/fMw2J+8BTasxIDdZKVuJGNRhqS8+0YcRMnrtWXeIYjy3uvnD9IavEmisKYhtg7BaEOtYhGdIAd6cSD1cifsVu6lR1jS6DN99agLq1xQ9nJgHqC5wngOwo1X6duOBQEWAEO5OTzMtWwSNhdEkXmmXuV5zP+FBxW5GHLQsbxiBZ82QhvCvCHU8/UlMTFGBi8qUe3aUwuWfIOVwZTguaDvl9PuQgxhpkGY/mEGVTR/2S1tiuXEqAKCqpZG6VmOma4Tz+UEK3fvQ9nTlcdjv8TUVI3BWbtF3AnWiDtFHj/85rzYFr2zUYz2paMwmSgldsZNjOL+z6vvKTNb9S7PPvO23e7tSQQrgR06klS2Iw7IVqNRuK1Yj8LzaxMRVrpw+duNShbzrH3IpkGqaa2ufPOvtk3LNdakVk/fTqfI1W2MUhzSEZdkmBUO8SAnAm1TBUsmjXMbBsbUFtHKuh2EuZCLXGivy9II/evbAlJua5B2h1IT+PmlwNT6gWRhrAV9h/FeEwH4V47vfpr9tLVbmE60CbmyB1zvsK5IxyLorZDxJpIlo8HvgYPFAwgne3XGdu5sqYLR84XKRHzzyD4h6p/b/aTHxwluHDfJ9kNduFKkHSqc8sihBg/VZz5upXNoa9ixky39Vkn4hxtt6nXkWAOe3od67U89ICFPhJZCJoO+VRmM1B05/5/j Z+LSF8JK tZHYUcMFFJ6pGCJeO2E5KWQ/8heFyx9geW2MYpEt/9TbTHjOlrRE9pcro3pHohv2biW9SUBedgOMrd2oRhteCtB+Juabr3UW/d1u6u2JoYG3VT9GF64YL6KEX86e8ndXNoTKIum0qXhXkFbgNsPAmKfMCd+dhVxrSHjWZzvRSvE8VO9xCt86hE8oCERJk5pRUnUgGV3N6oq7F/TRJQGE5ly6/GPx1r+ipOKnjc2si3KsyPV/IA12CvuPHBHKiVAIAviMsgl8wPw7pZKaqs3olM4Yw9V6Noa8GZSbJ2amQFbNhoIAsOBMpjXx4j3H7nBXrVV3B/emKDFjIzdZ/UE23sN4scLhAICfV7Tz13g/25xQA1k16h/7gvMY2dVN3kjdDpXiPcqWg9NCj75uLIEB7qd5yMUJgjAgyxppQoHPBfYY7tsf5RcnaOL/H33hf9jNAZddPwtiWIBQDMl/oRq6pFsDJ2c5fusP4OnbPqKx7DKTac2P3WRwIl/a1j6iqwDA11ksq 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 Wed, Mar 27, 2024 at 03:13:18PM +0000, Ryan Roberts wrote: > On 27/03/2024 14:57, David Hildenbrand wrote: > > On 27.03.24 15:53, Matthew Wilcox wrote: > >> On Sat, Mar 23, 2024 at 12:41:36AM +1300, Barry Song wrote: > >>> Commit d0637c505f8a1 ("arm64: enable THP_SWAP for arm64") brings up > >>> THP_SWAP on ARM64, but it doesn't enable THP_SWP on hardware with > >>> MTE as the MTE code works with the assumption tags save/restore is > >>> always handling a folio with only one page. > >>> > >>> The limitation should be removed as more and more ARM64 SoCs have > >>> this feature. Co-existence of MTE and THP_SWAP becomes more and > >>> more important. > >>> > >>> This patch makes MTE tags saving support large folios, then we don't > >>> need to split large folios into base pages for swapping out on ARM64 > >>> SoCs with MTE any more. > >> > >> Can we go further than this patch and only support PG_mte_tagged and > >> PG_mte_lock on folio->flags instead of page->flags?  We're down to using > > > > I think we discussed that already and what I learned is that it "gets a bit > > complicated". But I'm hoping we can get that discussion started again. > > The original conversation starts here: > https://lore.kernel.org/linux-mm/fb34d312-1049-4932-8f2b-d7f33cfc297c@arm.com/ > > The issue is that you can have a large folio mapped to user space, and user > space only wants to activate MTE for a portion of it. So at that point, you > either have to deal with only part of it being tagged (as we do today with the > per-page flag) or you have to split the folio. It needs splitting since the PROT_MTE property ends up in the pte as a memory attribute. So we can't have a THP mapping with PROT_MTE but only specific pages tagged. I had an attempt last year to only keep the PG_mte_tagged flag in the head page but I recall folio_copy() got in the way since it was calling copy_highpage() on individual pages and the arm64 code was not seeing the head PG_mte_tagged. I think it can be worked around but I got distracted and forgot about this. -- Catalin