Skip to content

Commit 34e8e63

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/hugetlb: Consistently use pud_sect_supported()
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>
1 parent 2d7872f commit 34e8e63

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
@@ -342,7 +342,9 @@ unsigned long hugetlb_mask_last_page(struct hstate *h)
342342
switch (hp_size) {
343343
#ifndef __PAGETABLE_PMD_FOLDED
344344
case PUD_SIZE:
345-
return PGDIR_SIZE - PUD_SIZE;
345+
if (pud_sect_supported())
346+
return PGDIR_SIZE - PUD_SIZE;
347+
break;
346348
#endif
347349
case CONT_PMD_SIZE:
348350
return PUD_SIZE - CONT_PMD_SIZE;
@@ -364,23 +366,21 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
364366
switch (pagesize) {
365367
#ifndef __PAGETABLE_PMD_FOLDED
366368
case PUD_SIZE:
367-
entry = pud_pte(pud_mkhuge(pte_pud(entry)));
369+
if (pud_sect_supported())
370+
return pud_pte(pud_mkhuge(pte_pud(entry)));
368371
break;
369372
#endif
370373
case CONT_PMD_SIZE:
371-
entry = pmd_pte(pmd_mkcont(pte_pmd(entry)));
372-
fallthrough;
374+
return pmd_pte(pmd_mkhuge(pmd_mkcont(pte_pmd(entry))));
373375
case PMD_SIZE:
374-
entry = pmd_pte(pmd_mkhuge(pte_pmd(entry)));
375-
break;
376+
return pmd_pte(pmd_mkhuge(pte_pmd(entry)));
376377
case CONT_PTE_SIZE:
377-
entry = pte_mkcont(entry);
378-
break;
378+
return pte_mkcont(entry);
379379
default:
380-
pr_warn("%s: unrecognized huge page size 0x%lx\n",
381-
__func__, pagesize);
382380
break;
383381
}
382+
pr_warn("%s: unrecognized huge page size 0x%lx\n",
383+
__func__, pagesize);
384384
return entry;
385385
}
386386

0 commit comments

Comments
 (0)