include/linux/pgtable.h
Source file repositories/reference/linux-study-clean/include/linux/pgtable.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/pgtable.h- Extension
.h- Size
- 71006 bytes
- Lines
- 2501
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pfn.hasm/pgtable.hlinux/mm_types.hlinux/bug.hlinux/errno.hasm-generic/pgtable_uffd.hlinux/page_table_check.h
Detected Declarations
struct mm_structstruct fileenum pgtable_levelfunction pXx_indexfunction pmd_indexfunction pud_indexfunction kernel_pte_initfunction pte_unmapfunction pmd_youngfunction pmd_dirtyfunction arch_enter_lazy_mmu_modefunction lazy_mmu_mode_disablefunction __task_lazy_mmu_mode_pausefunction arch_leave_lazy_mmu_modefunction __task_lazy_mmu_mode_resumefunction lazy_mmu_mode_pausefunction lazy_mmu_mode_enablefunction pte_advance_pfnfunction set_ptefunction pmdp_set_access_flagsfunction pudp_set_access_flagsfunction ptep_getfunction pmdp_getfunction pudp_getfunction p4dp_getfunction pgdp_getfunction ptep_test_and_clear_youngfunction pmdp_test_and_clear_youngfunction pmdp_test_and_clear_youngfunction PageTransHugefunction arch_has_hw_nonleaf_pmd_youngfunction arch_has_hw_pte_youngfunction exec_folio_orderfunction arch_check_zapped_ptefunction clear_young_dirty_ptesfunction ptep_clearfunction ptep_get_locklessfunction pmdp_get_locklessfunction ptep_get_locklessfunction pmdp_get_locklessfunction pmdp_get_lockless_syncfunction pudp_huge_get_and_clearfunction pmdp_huge_get_and_clear_fullfunction pudp_huge_get_and_clear_fullfunction ptep_get_and_clear_fullfunction ptep_get_and_clear_fullfunction get_and_clear_full_ptesfunction ptep_get_and_clear_full
Annotated Snippet
static inline void lazy_mmu_mode_enable(void) {}
static inline void lazy_mmu_mode_disable(void) {}
static inline void lazy_mmu_mode_pause(void) {}
static inline void lazy_mmu_mode_resume(void) {}
#endif
#ifndef pte_batch_hint
/**
* pte_batch_hint - Number of pages that can be added to batch without scanning.
* @ptep: Page table pointer for the entry.
* @pte: Page table entry.
*
* Some architectures know that a set of contiguous ptes all map the same
* contiguous memory with the same permissions. In this case, it can provide a
* hint to aid pte batching without the core code needing to scan every pte.
*
* An architecture implementation may ignore the PTE accessed state. Further,
* the dirty state must apply atomically to all the PTEs described by the hint.
*
* May be overridden by the architecture, else pte_batch_hint is always 1.
*/
static inline unsigned int pte_batch_hint(pte_t *ptep, pte_t pte)
{
return 1;
}
#endif
#ifndef pte_advance_pfn
static inline pte_t pte_advance_pfn(pte_t pte, unsigned long nr)
{
return __pte(pte_val(pte) + (nr << PFN_PTE_SHIFT));
}
#endif
#define pte_next_pfn(pte) pte_advance_pfn(pte, 1)
#ifndef set_ptes
/**
* set_ptes - Map consecutive pages to a contiguous range of addresses.
* @mm: Address space to map the pages into.
* @addr: Address to map the first page at.
* @ptep: Page table pointer for the first entry.
* @pte: Page table entry for the first page.
* @nr: Number of pages to map.
*
* When nr==1, initial state of pte may be present or not present, and new state
* may be present or not present. When nr>1, initial state of all ptes must be
* not present, and new state must be present.
*
* May be overridden by the architecture, or the architecture can define
* set_pte() and PFN_PTE_SHIFT.
*
* Context: The caller holds the page table lock. The pages all belong
* to the same folio. The PTEs are all in the same PMD.
*/
static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
pte_t *ptep, pte_t pte, unsigned int nr)
{
page_table_check_ptes_set(mm, addr, ptep, pte, nr);
for (;;) {
set_pte(ptep, pte);
if (--nr == 0)
break;
ptep++;
pte = pte_next_pfn(pte);
}
}
#endif
#define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
extern int ptep_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pte_t *ptep,
pte_t entry, int dirty);
#endif
#ifndef __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern int pmdp_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmdp,
pmd_t entry, int dirty);
extern int pudp_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pud_t *pudp,
pud_t entry, int dirty);
#else
static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmdp,
pmd_t entry, int dirty)
{
Annotation
- Immediate include surface: `linux/pfn.h`, `asm/pgtable.h`, `linux/mm_types.h`, `linux/bug.h`, `linux/errno.h`, `asm-generic/pgtable_uffd.h`, `linux/page_table_check.h`.
- Detected declarations: `struct mm_struct`, `struct file`, `enum pgtable_level`, `function pXx_index`, `function pmd_index`, `function pud_index`, `function kernel_pte_init`, `function pte_unmap`, `function pmd_young`, `function pmd_dirty`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.