From nobody Mon Jun 29 22:11:54 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 053EEC433FE for ; Wed, 2 Feb 2022 05:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240711AbiBBFjn (ORCPT ); Wed, 2 Feb 2022 00:39:43 -0500 Received: from foss.arm.com ([217.140.110.172]:35692 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232452AbiBBFjl (ORCPT ); Wed, 2 Feb 2022 00:39:41 -0500 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 A584AED1; Tue, 1 Feb 2022 21:39:40 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.221]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 090FA3F718; Tue, 1 Feb 2022 21:39:36 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Michael Ellerman , Paul Mackerras , "David S. Miller" , Mike Kravetz , Andrew Morton , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: Merge pte_mkhuge() call into arch_make_huge_pte() Date: Wed, 2 Feb 2022 11:08:06 +0530 Message-Id: <1643780286-18798-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Each call into pte_mkhuge() is invariably followed by arch_make_huge_pte(). Instead arch_make_huge_pte() can accommodate pte_mkhuge() at the beginning. This updates generic fallback stub for arch_make_huge_pte() and available platforms definitions. This makes huge pte creation much cleaner and easier to follow. Cc: Catalin Marinas Cc: Will Deacon Cc: Michael Ellerman Cc: Paul Mackerras Cc: "David S. Miller" Cc: Mike Kravetz Cc: Andrew Morton Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Cc: sparclinux@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Acked-by: Catalin Marinas Acked-by: Mike Kravetz Reviewed-by: Christophe Leroy --- arch/arm64/mm/hugetlbpage.c | 1 + arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 1 + arch/sparc/mm/hugetlbpage.c | 1 + include/linux/hugetlb.h | 2 +- mm/hugetlb.c | 3 +-- mm/vmalloc.c | 1 - 6 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index ffb9c229610a..228226c5fa80 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -347,6 +347,7 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shif= t, vm_flags_t flags) { size_t pagesize =3D 1UL << shift; =20 + entry =3D pte_mkhuge(entry); if (pagesize =3D=3D CONT_PTE_SIZE) { entry =3D pte_mkcont(entry); } else if (pagesize =3D=3D CONT_PMD_SIZE) { diff --git a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h b/arch/powerp= c/include/asm/nohash/32/hugetlb-8xx.h index 64b6c608eca4..e41e095158c7 100644 --- a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h @@ -70,6 +70,7 @@ static inline pte_t arch_make_huge_pte(pte_t entry, unsig= ned int shift, vm_flags { size_t size =3D 1UL << shift; =20 + entry =3D pte_mkhuge(entry); if (size =3D=3D SZ_16K) return __pte(pte_val(entry) & ~_PAGE_HUGE); else diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index 0f49fada2093..d8e0e3c7038d 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -181,6 +181,7 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shif= t, vm_flags_t flags) { pte_t pte; =20 + entry =3D pte_mkhuge(entry); pte =3D hugepage_shift_to_tte(entry, shift); =20 #ifdef CONFIG_SPARC64 diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index d1897a69c540..52c462390aee 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -754,7 +754,7 @@ static inline void arch_clear_hugepage_flags(struct pag= e *page) { } static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags) { - return entry; + return pte_mkhuge(entry); } #endif =20 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 61895cc01d09..5ca253c1b4e4 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4637,7 +4637,6 @@ static pte_t make_huge_pte(struct vm_area_struct *vma= , struct page *page, vma->vm_page_prot)); } entry =3D pte_mkyoung(entry); - entry =3D pte_mkhuge(entry); entry =3D arch_make_huge_pte(entry, shift, vma->vm_flags); =20 return entry; @@ -6172,7 +6171,7 @@ unsigned long hugetlb_change_protection(struct vm_are= a_struct *vma, unsigned int shift =3D huge_page_shift(hstate_vma(vma)); =20 old_pte =3D huge_ptep_modify_prot_start(vma, address, ptep); - pte =3D pte_mkhuge(huge_pte_modify(old_pte, newprot)); + pte =3D huge_pte_modify(old_pte, newprot); pte =3D arch_make_huge_pte(pte, shift, vma->vm_flags); huge_ptep_modify_prot_commit(vma, address, ptep, old_pte, pte); pages++; diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4165304d3547..d0b14dd73adc 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -118,7 +118,6 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long add= r, unsigned long end, if (size !=3D PAGE_SIZE) { pte_t entry =3D pfn_pte(pfn, prot); =20 - entry =3D pte_mkhuge(entry); entry =3D arch_make_huge_pte(entry, ilog2(size), 0); set_huge_pte_at(&init_mm, addr, pte, entry); pfn +=3D PFN_DOWN(size); --=20 2.25.1