clear_ptes(9)
π clear_ptes(9) β the Kernel API Manual, bestie edition π
okay so this is clear_ptes, section 9 of the Kernel API Manual, and it's lowkey one of those pages you're gonna be so glad you read instead of guessing, because guessing here is giving "undefined behaviour at 3am" π
β¨ NAME β¨
clear_ptes β clears present PTEs that map consecutive pages of the same folio. that's it, that's the whole job, and it eats π
πΈ SYNOPSIS πΈ
void clear_ptes (struct mm_struct *mm , unsigned long addr , pte_t *ptep , unsigned int nr );
four arguments, one void, zero drama β¨
π¦ ARGUMENTS π¦
mmβ the address space the pages are mapped into. it's the whole vibe container π«Άaddrβ the address where the first page is mapped. like, entry zero of your little PTE party πptepβ the page table pointer for that first entry. the main character pointer, honestly πnrβ how many entries you're clearing. count them, bestie, don't vibe-guess the number π
π DESCRIPTION π
use this instead of clear_full_ptes if you know you don't need to clear the full mm β which is mostly the case, fr fr. like, most of the time you're not clearing the entire address space, you're doing a little targeted cleanup, and this is the function for that π
heads up π¨ the PTE bits in the PTE range besides the PFN can totally differ! for example, some PTEs might be write-protected. so do not come in assuming every entry looks identical β that's not the vibe check this function is passing π
π₯ CONTEXT π₯
these are the rules of the house, no cap:
- the caller holds the page table lock π
- the PTEs map consecutive pages that belong to the same folio π
- the PTEs are all in the same PMD β
miss any of these and you're not in the club anymore, sorry, that's just how it is π§
π SEE ALSO π
so much lore in this kernel file, honestly: kernel file ./include/linux/pgtable.h plus this whole friend groupβ
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)set_ptes(9)clear_young_dirty_ptes(9)get_and_clear_full_ptes(9)get_and_clear_ptes(9)clear_full_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!! you did it, you read the whole thing π«Ά this one lives in ./include/linux, dated October 2026, and it's clear_ptes(9) β go clear some PTEs, slay π
β¨
π¦ 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