set_ptes(9)
π set_ptes(9) β like, the kernel API manual, bestie β¨
Okay so welcome to the set_ptes(9) page from the Kernel API Manual β grab a strawberry π and let's get into it, because this one is genuinely iconic if you're into page tables (and you are, or you wouldn't be here).
πΈ NAME πΈ
set_ptes β map consecutive pages to a contiguous range of addresses. That's the whole vibe. Consecutive pages, contiguous addresses, no cap. π«Ά
β¨ SYNOPSIS β¨
void set_ptes (struct mm_struct *mm , unsigned long addr , pte_t *ptep ,
pte_t pte , unsigned int nr );
She takes five things and returns nothing (void, queen of not needing to prove anything π
).
π ARGUMENTS π
mmβ the address space you're mapping the pages into. The whole neighborhood, basically.addrβ the address where the first page goes. Everyone else lines up behind her.ptepβ page table pointer for the first entry. Your starting point, your main character position.pteβ the page table entry for the first page. The blueprint.nrβ number of pages to map. How many besties are we bringing.
π₯ DESCRIPTION π₯
Okay so here's the tea, and it's important tea, so read carefully pookie:
When nr==1, the initial state of pte may be present or not present, and the new state may be present or not present. Free and easy. Lowkey the chill case.
When nr>1, the initial state of all the ptes must be not present, and the new state must be present. No exceptions. That's the rule, fr fr. π€
Also β this function may be overridden by the architecture, or the architecture can define set_pte and PFN_PTE_SHIFT. So like, your arch might have opinions. Respect them. π§
π CONTEXT π
Three things you need to know before you call her, and yes they're all mandatory:
- The caller holds the page table lock.
- The pages all belong to the same folio.
- The PTEs are all in the same PMD.
Squad requirements. Don't show up without them. π―
π SEE ALSO π
Kernel file ./include/linux/pgtable.h, plus this absolute friend group right here β go say hi to all of them:
lazy_mmu_mode_enable(9)lazy_mmu_mode_disable(9)__task_lazy_mmu_mode_pause(9)lazy_mmu_mode_pause(9)__task_lazy_mmu_mode_resume(9)lazy_mmu_mode_resume(9)pte_batch_hint(9)clear_young_dirty_ptes(9)get_and_clear_full_ptes(9)get_and_clear_ptes(9)clear_full_ptes(9)clear_ptes(9)clear_nonpresent_ptes(9)ptep_try_set(9)flush_tlb_before_set(9)wrprotect_ptes(9)clear_flush_young_ptes(9)test_and_clear_young_ptes(9)modify_prot_start_ptes(9)modify_prot_commit_ptes(9)pfnmap_setup_cachemode(9)pfnmap_track(9)pfnmap_untrack(9)pfnmap_setup_cachemode_pfn(9)
and that's the page, bestie π This one lives under ./include/linux and the doc crew stamped it October 2026 β so yeah, go map those consecutive pages, stay in your folio, and don't forget the lock. mwah ππ¦
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms