Skip to content

Commit f819281

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/mm: Re-organize arch_make_huge_pte()
Core HugeTLB defines a fallback definition for arch_make_huge_pte(), which calls platform provided pte_mkhuge(). But if any platform already provides an override for arch_make_huge_pte(), then it does not need to provide the helper pte_mkhuge(). arm64 override for arch_make_huge_pte() calls pte_mkhuge() internally, thus creating an impression, that both of these callbacks are being used in core HugeTLB and hence required to be defined. This drops off pte_mkhuge() which was never required to begin with as there could not be any section mappings at the PTE level. Re-organize arch_make_huge_pte() based on requested page size and create the entry for the applicable page table level as needed. It also removes a redundancy of clearing PTE_TABLE_BIT bit followed by setting both PTE_TABLE_BIT and PTE_VALID bits (via PTE_TYPE_MASK) in the pte, while creating CONT_PTE_SIZE size entries. Cc: Will Deacon <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Mark Rutland <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Anshuman Khandual <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 0448a96 commit f819281

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,6 @@ static inline void __set_ptes(struct mm_struct *mm,
438438
}
439439
}
440440

441-
/*
442-
* Huge pte definitions.
443-
*/
444-
#define pte_mkhuge(pte) (__pte(pte_val(pte) & ~PTE_TABLE_BIT))
445-
446441
/*
447442
* Hugetlb definitions.
448443
*/

arch/arm64/mm/hugetlbpage.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,25 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
361361
{
362362
size_t pagesize = 1UL << shift;
363363

364-
entry = pte_mkhuge(entry);
365-
if (pagesize == CONT_PTE_SIZE) {
366-
entry = pte_mkcont(entry);
367-
} else if (pagesize == CONT_PMD_SIZE) {
364+
switch (pagesize) {
365+
#ifndef __PAGETABLE_PMD_FOLDED
366+
case PUD_SIZE:
367+
entry = pud_pte(pud_mkhuge(pte_pud(entry)));
368+
break;
369+
#endif
370+
case CONT_PMD_SIZE:
368371
entry = pmd_pte(pmd_mkcont(pte_pmd(entry)));
369-
} else if (pagesize != PUD_SIZE && pagesize != PMD_SIZE) {
372+
fallthrough;
373+
case PMD_SIZE:
374+
entry = pmd_pte(pmd_mkhuge(pte_pmd(entry)));
375+
break;
376+
case CONT_PTE_SIZE:
377+
entry = pte_mkcont(entry);
378+
break;
379+
default:
370380
pr_warn("%s: unrecognized huge page size 0x%lx\n",
371381
__func__, pagesize);
382+
break;
372383
}
373384
return entry;
374385
}

0 commit comments

Comments
 (0)