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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAB25C54E67 for ; Wed, 27 Mar 2024 17:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vFuK2qryxCVzHq72SePyth6JxkhVZXXfZI8QLOVj3tw=; b=VcqbNkyZK+ZL+V xLlyMr9zmkYjkkYWAQGtMaHpmzkZeHwvwvsPPEJA42FA6Yfog/sJktFnlfbvF3fpiilpgG65YQBim 2wW3d75+WwMIYR8m0r/ZEZzxSrFaz91CSZaSbz/bnf6i3E3b2PWPHL8MkCDHG3DYwEKTL58i0LH3o 0eHHe/b7SZ3lz2pRQCGqM8l3nR7elONXLxmFf8hqXw4OsmBBwqTS1qjYsPvOa1OkGGtqcNvIRHg7D 3KEtG4G+rzlAByRhUH+kvPbGgIZYTPckWtizYRtJuqwMR2sZqQSw+f2wI8Y2h45qFVrLglD14LjhB BMGYpW1O+CQcS7ZuAHnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXXw-0000000AQae-29Hn; Wed, 27 Mar 2024 17:58:44 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpXXq-0000000AQW7-2zdG for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 17:58:40 +0000 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-Disposition: inline In-Reply-To: <46ba09c5-4186-4e03-81cc-ca27c0301fef@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_105838_839663_44F81C3C X-CRM114-Status: GOOD ( 24.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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?=A0 We're down to u= sing > > = > > 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 us= er > space only wants to activate MTE for a portion of it. So at that point, y= ou > either have to deal with only part of it being tagged (as we do today wit= h 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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