From patchwork Thu Jun 22 14:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13289251 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 0968FEB64DA for ; Thu, 22 Jun 2023 14:42:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AD308D0007; Thu, 22 Jun 2023 10:42:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 935B28D0001; Thu, 22 Jun 2023 10:42:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 788018D0007; Thu, 22 Jun 2023 10:42:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 63B9A8D0001 for ; Thu, 22 Jun 2023 10:42:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 44D711C8421 for ; Thu, 22 Jun 2023 14:42:39 +0000 (UTC) X-FDA: 80930650038.18.E021E44 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 73EED2001E for ; Thu, 22 Jun 2023 14:42:37 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.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=1687444957; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0oPSCCAWlfmzkzgt7vGIxZAnqWTVpAld++EiGzSncrg=; b=x/DFB4S7FL3f4VN3JoKqa3ZVTouUoc2H3/oDcitAMS/LG/Yp+eWonlkNq1lgN2rLqyhi1q BZCy0/gQM4hiecu+k90AXiOB8ekR882I9eCq/FtWZs3jQU3rSOWLLjzSP105BVZcLTnnfr AdayLR0ezTQ7gFCs4/6ELtvYN+ZU2CE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.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=1687444957; a=rsa-sha256; cv=none; b=OAKotWw9GxTXpyDOy4uChlVRYP4eJ28jMfi1MM2BBpVaYwDH7Ivj0UnvdZrR9gFoOwrOfi dQ3m6KdYimz3rCe1ogiasJi0OhzUUElTu+XGWWgSf92lwTg1P5lb5qcK+WJ7mySJ/kDKVv W259+SHLnIfFTRSy6gW5O+qiX85q0mE= 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 4662B14BF; Thu, 22 Jun 2023 07:43:20 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B63163F663; Thu, 22 Jun 2023 07:42:33 -0700 (PDT) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 03/14] arm64/mm: pte_clear(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:41:58 +0100 Message-Id: <20230622144210.2623299-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230622144210.2623299-1-ryan.roberts@arm.com> References: <20230622144210.2623299-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 73EED2001E X-Stat-Signature: zym34t8kzncuwofym6oye14x69zk45t3 X-HE-Tag: 1687444957-219652 X-HE-Meta: U2FsdGVkX187ZHz9JiIOGCBcLw779OOgMSQTMnW4pKXufbQ5zXG0rUxMNVlmeAmbKPAkz4jJUVRNVnkanUOtqwJyu5EOSQFfH8YQGJd8MTqK12VtCqilbN/roXFjMZvtdZjVQtjgxwpI3YtN0XuyAE7AOJ83Thy9IfmbG77c5o6YvsfnDbdAxIH/Vqm4LQt+pgLAtUekyjHUIfKUK4w94ICFiTWEoo1VUlPP+YGR/iJErDvHhtM2oNrA5U8CtnIx4+vbQw63g6IN4ukr2PCTRZhaDtCToqi+hUQABRhRXFhUU18AX9I2lDZG+Z3IPGAy3xkX/ASB9fUXaHieByN85DI+NmBnfDejx7S7sS0Lv/dEu4PCnoJ8PUJrjwEXr58M45xQtY0OmnoE02g+IxHxnJ5+thoA2K7Zok1sZgxYrzaMjMzmNSpyReh+B9CbzJmUyQFnNADkXtn8w2rA1rHDUM5AiuLWo1X61xwI/a6qkbgpEXWZkNi2L/znmR+qvEIj2IV1QrsbRrZ7unFo3Fnrn99S4/ovhGvXQ6bJI8ctTprpwBTWEnpxKkAqznvaX3Kbc75bB9+8zUfRWtSI6p9COndyjrsIv20xWRMs9JYpu+Ahz5KchHD6cPzPL6HNNq5EiYmrre7hZ6zPhJ+aPSO74wZKXPYg2ynfOr0oW6rAydOgK927iwWIupAguNR6AuMYi9ErV3g1hlkAJGjYJgabT12I94IWSUyFS5Yw7GulVCbx0BtxI63jQ+XSLp56xh9im+1SUHQvC8Ntbk5miHrY5/yVUlW6Ocg54YqmelXkI+xA8twnPZppnGotgtS9PwBB2FTdWLh6CC8MyHvr7SSNFofRPFhZ5v6Ny4uDXumaZHldQuo1ahARSedHETehE5Jx0Dlwd31m+nQ7Ty5EAJyf+Cd/0nIfx5JTJSsiCKKtw/kZk3WCK2iXHmLQqYJFsNQ4MvL/9LbWSxUboRTsVzz fFni8S96 /csGZ0b1gaJPbEyumFcaPkXum8DdUkKqHssrHEHt5K5imMJzNPPilRSRQb2jAPTs/g3W7xs5nP/kRo2HT6trqbCvjmH0hHBli7TW76oEl7fiJiDa+7x8PdPd1ZgtqnzhstiJxS9znNLIPgZ/Pp6e/glhaHQ8O8WdOu6/qM76tGB8ffn6yJfp5vKS/uvXzIe+MqFCgOuFXgkFbsmlhggBKzp5rThhmmf9hpk3Fo4+G/oixtHyXR2kHx37tFCH+o2lWszaaO6M9G0esatJJlBpICjZrxg== 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: Create a new layer for the in-table PTE manipulation APIs. For now, The existing API is prefixed with double underscore to become the arch-private API and the public API is just a simple wrapper that calls the private API. The public API implementation will subsequently be used to transparently manipulate the contiguous bit where appropriate. But since there are already some contig-aware users (e.g. hugetlb, kernel mapper), we must first ensure those users use the private API directly so that the future contig-bit manipulations in the public API do not interfere with those existing uses. No behavioural changes intended. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 8 +++++++- arch/arm64/mm/fixmap.c | 2 +- arch/arm64/mm/hugetlbpage.c | 4 ++-- arch/arm64/mm/mmu.c | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 84919a3c558e..06b5dca469f5 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -93,7 +93,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) #define pte_none(pte) (!pte_val(pte)) -#define pte_clear(mm, addr, ptep) \ +#define __pte_clear(mm, addr, ptep) \ __set_pte(ptep, __pte(0)) #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) @@ -1140,6 +1140,12 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long addr, __set_ptes(mm, addr, ptep, pte, nr); } +static inline void pte_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + __pte_clear(mm, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c index 51cd4501816d..bfc02568805a 100644 --- a/arch/arm64/mm/fixmap.c +++ b/arch/arm64/mm/fixmap.c @@ -123,7 +123,7 @@ void __set_fixmap(enum fixed_addresses idx, if (pgprot_val(flags)) { __set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags)); } else { - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr+PAGE_SIZE); } } diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 31a1da655bf1..eebd3107c7d2 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -236,7 +236,7 @@ static void clear_flush(struct mm_struct *mm, unsigned long i, saddr = addr; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); + __pte_clear(mm, addr, ptep); flush_tlb_range(&vma, saddr, addr); } @@ -418,7 +418,7 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr, ncontig = num_contig_ptes(sz, &pgsize); for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); + __pte_clear(mm, addr, ptep); } pte_t huge_ptep_get_and_clear(struct mm_struct *mm, diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index c84dc87d08b9..085a7e3eec98 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -853,7 +853,7 @@ static void unmap_hotplug_pte_range(pmd_t *pmdp, unsigned long addr, continue; WARN_ON(!pte_present(pte)); - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr + PAGE_SIZE); if (free_mapped) free_hotplug_page_range(pte_page(pte),