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 95474C47DD9 for ; Wed, 27 Mar 2024 12:23:40 +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=iJO9PwSjfA/QuJPnEb/Am7DR89JvboScBtNg2IQ/UT4=; b=4V0OAIhfOjgVPi SlviBHaUKuoNnKnh+TOk+pVIjyA1z35dyHxYGrRKt37FrCo7P5tEf4IlR7rOxOT4WUtZIOS5uzfDz jFih0uGJVLAI/FvNVFBKLe+zzhpAvWSPpSTzowBo9k2iMccnz5Q5ooFFnAPAn5nSM2h8U5lkOAM1N S6StYk2og+qEdxfD+Mpzjraf1jaOWpKEEL558vtu6yjHtj8sjyfrZIf0M5V6dsaLPccxDibKwdwfN Q8yVZ2+HItaUiZ+pKrSeATNS1UJ74uynMqQc06/s6U8dQJcQ2zp4hVd4Epy/qWArvXT0WfvSZ47QX qraPpxAdL6gP0xP2k68w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpSJQ-00000008pcS-0DeW; Wed, 27 Mar 2024 12:23:24 +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 1rpSJN-00000008pao-0HnO for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 12:23:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0CFE461506; Wed, 27 Mar 2024 12:23:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3663BC433C7; Wed, 27 Mar 2024 12:23:15 +0000 (UTC) Date: Wed, 27 Mar 2024 12:23:12 +0000 From: Catalin Marinas To: Barry Song <21cnbao@gmail.com> Cc: 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, ryan.roberts@arm.com, steven.price@arm.com, david@redhat.com, willy@infradead.org, 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240322114136.61386-2-21cnbao@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_052321_233191_93A30A6C X-CRM114-Status: GOOD ( 19.64 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Mar 23, 2024 at 12:41:36AM +1300, Barry Song wrote: > From: Barry Song > > 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. > > arch_prepare_to_swap() should take folio rather than page as parameter > because we support THP swap-out as a whole. It saves tags for all > pages in a large folio. > > As now we are restoring tags based-on folio, in arch_swap_restore(), > we may increase some extra loops and early-exitings while refaulting > a large folio which is still in swapcache in do_swap_page(). In case > a large folio has nr pages, do_swap_page() will only set the PTE of > the particular page which is causing the page fault. > Thus do_swap_page() runs nr times, and each time, arch_swap_restore() > will loop nr times for those subpages in the folio. So right now the > algorithmic complexity becomes O(nr^2). > > Once we support mapping large folios in do_swap_page(), extra loops > and early-exitings will decrease while not being completely removed > as a large folio might get partially tagged in corner cases such as, > 1. a large folio in swapcache can be partially unmapped, thus, MTE > tags for the unmapped pages will be invalidated; > 2. users might use mprotect() to set MTEs on a part of a large folio. > > arch_thp_swp_supported() is dropped since ARM64 MTE was the only one > who needed it. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Ryan Roberts > Cc: Mark Rutland > Cc: David Hildenbrand > Cc: Kemeng Shi > Cc: "Matthew Wilcox (Oracle)" > Cc: Anshuman Khandual > Cc: Peter Collingbourne > Cc: Steven Price > Cc: Yosry Ahmed > Cc: Peter Xu > Cc: Lorenzo Stoakes > Cc: "Mike Rapoport (IBM)" > Cc: Hugh Dickins > CC: "Aneesh Kumar K.V" > Cc: Rick Edgecombe > Signed-off-by: Barry Song > Reviewed-by: Steven Price > Acked-by: Chris Li Acked-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel