arch/arm64/mm/hugetlbpage.c
Source file repositories/reference/linux-study-clean/arch/arm64/mm/hugetlbpage.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/mm/hugetlbpage.c- Extension
.c- Size
- 13098 bytes
- Lines
- 540
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/fs.hlinux/mm.hlinux/hugetlb.hlinux/pagemap.hlinux/err.hlinux/sysctl.hasm/mman.hasm/tlb.hasm/tlbflush.h
Detected Declarations
function Copyrightfunction __hugetlb_valid_sizefunction arch_hugetlb_migration_supportedfunction find_num_contigfunction num_contig_ptesfunction huge_ptep_getfunction get_clear_contigfunction get_clear_contig_flushfunction clear_flushfunction set_huge_pte_atfunction hugetlb_mask_last_pagefunction arch_make_huge_ptefunction huge_pte_clearfunction huge_ptep_get_and_clearfunction flagsfunction huge_ptep_set_access_flagsfunction huge_ptep_set_wrprotectfunction huge_ptep_clear_flushfunction hugetlbpage_initfunction arch_hugetlb_valid_sizefunction huge_ptep_modify_prot_startfunction huge_ptep_modify_prot_commit
Annotated Snippet
if (present) {
if (pte_dirty(tmp_pte))
pte = pte_mkdirty(pte);
if (pte_young(tmp_pte))
pte = pte_mkyoung(pte);
}
}
return pte;
}
static pte_t get_clear_contig_flush(struct mm_struct *mm,
unsigned long addr,
pte_t *ptep,
unsigned long pgsize,
unsigned long ncontig)
{
pte_t orig_pte = get_clear_contig(mm, addr, ptep, pgsize, ncontig);
struct vm_area_struct vma = TLB_FLUSH_VMA(mm, 0);
unsigned long end = addr + (pgsize * ncontig);
__flush_hugetlb_tlb_range(&vma, addr, end, pgsize, TLBF_NOWALKCACHE);
return orig_pte;
}
/*
* Changing some bits of contiguous entries requires us to follow a
* Break-Before-Make approach, breaking the whole contiguous set
* before we can change any entries. See ARM DDI 0487A.k_iss10775,
* "Misprogramming of the Contiguous bit", page D4-1762.
*
* This helper performs the break step for use cases where the
* original pte is not needed.
*/
static void clear_flush(struct mm_struct *mm,
unsigned long addr,
pte_t *ptep,
unsigned long pgsize,
unsigned long ncontig)
{
struct vm_area_struct vma = TLB_FLUSH_VMA(mm, 0);
unsigned long i, saddr = addr;
for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
__ptep_get_and_clear_anysz(mm, addr, ptep, pgsize);
if (mm == &init_mm)
flush_tlb_kernel_range(saddr, addr);
else
__flush_hugetlb_tlb_range(&vma, saddr, addr, pgsize, TLBF_NOWALKCACHE);
}
void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t pte, unsigned long sz)
{
size_t pgsize;
int i;
int ncontig;
ncontig = num_contig_ptes(sz, &pgsize);
if (!pte_present(pte)) {
for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)
__set_ptes_anysz(mm, addr, ptep, pte, 1, pgsize);
return;
}
/* Only need to "break" if transitioning valid -> valid. */
if (pte_cont(pte) && pte_valid(__ptep_get(ptep)))
clear_flush(mm, addr, ptep, pgsize, ncontig);
__set_ptes_anysz(mm, addr, ptep, pte, ncontig, pgsize);
}
pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr, unsigned long sz)
{
pgd_t *pgdp;
p4d_t *p4dp;
pud_t *pudp;
pmd_t *pmdp;
pte_t *ptep = NULL;
pgdp = pgd_offset(mm, addr);
p4dp = p4d_alloc(mm, pgdp, addr);
if (!p4dp)
return NULL;
pudp = pud_alloc(mm, p4dp, addr);
if (!pudp)
return NULL;
Annotation
- Immediate include surface: `linux/init.h`, `linux/fs.h`, `linux/mm.h`, `linux/hugetlb.h`, `linux/pagemap.h`, `linux/err.h`, `linux/sysctl.h`, `asm/mman.h`.
- Detected declarations: `function Copyright`, `function __hugetlb_valid_size`, `function arch_hugetlb_migration_supported`, `function find_num_contig`, `function num_contig_ptes`, `function huge_ptep_get`, `function get_clear_contig`, `function get_clear_contig_flush`, `function clear_flush`, `function set_huge_pte_at`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.