Skip to content

Commit 81b2952

Browse files
committed
arm64/hugetlb: Consistently use pud_sect_supported()
JIRA: https://issues.redhat.com/browse/RHEL-101059 commit 34e8e63 Author: Anshuman Khandual <anshuman.khandual@arm.com> Date: Thu, 20 Feb 2025 10:35:34 +0530 Let's be consistent in using pud_sect_supported() for PUD_SIZE sized pages. Hence change hugetlb_mask_last_page() and arch_make_huge_pte() as required. Also re-arranged the switch statement for a common warning message. Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Link: https://lore.kernel.org/r/20250220050534.799645-1-anshuman.khandual@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent 9dca847 commit 81b2952

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

arch/arm64/mm/hugetlbpage.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ unsigned long hugetlb_mask_last_page(struct hstate *h)
334334
switch (hp_size) {
335335
#ifndef __PAGETABLE_PMD_FOLDED
336336
case PUD_SIZE:
337-
return PGDIR_SIZE - PUD_SIZE;
337+
if (pud_sect_supported())
338+
return PGDIR_SIZE - PUD_SIZE;
339+
break;
338340
#endif
339341
case CONT_PMD_SIZE:
340342
return PUD_SIZE - CONT_PMD_SIZE;
@@ -356,23 +358,21 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
356358
switch (pagesize) {
357359
#ifndef __PAGETABLE_PMD_FOLDED
358360
case PUD_SIZE:
359-
entry = pud_pte(pud_mkhuge(pte_pud(entry)));
361+
if (pud_sect_supported())
362+
return pud_pte(pud_mkhuge(pte_pud(entry)));
360363
break;
361364
#endif
362365
case CONT_PMD_SIZE:
363-
entry = pmd_pte(pmd_mkcont(pte_pmd(entry)));
364-
fallthrough;
366+
return pmd_pte(pmd_mkhuge(pmd_mkcont(pte_pmd(entry))));
365367
case PMD_SIZE:
366-
entry = pmd_pte(pmd_mkhuge(pte_pmd(entry)));
367-
break;
368+
return pmd_pte(pmd_mkhuge(pte_pmd(entry)));
368369
case CONT_PTE_SIZE:
369-
entry = pte_mkcont(entry);
370-
break;
370+
return pte_mkcont(entry);
371371
default:
372-
pr_warn("%s: unrecognized huge page size 0x%lx\n",
373-
__func__, pagesize);
374372
break;
375373
}
374+
pr_warn("%s: unrecognized huge page size 0x%lx\n",
375+
__func__, pagesize);
376376
return entry;
377377
}
378378

0 commit comments

Comments
 (0)