get_and_clear_ptes(9)
π get_and_clear_ptes β Kernel API Manual, bestie edition
okay so you're in the get_and_clear_ptes(9) page of the Kernel API Manual and honestly? you're about to have a great time. this one's a little pte-clearing baddie and she slays. let's get into it. π
β¨ NAME β¨
get_and_clear_ptes β clears the present PTEs that map consecutive pages of the same folio, and collects the dirty/accessed bits while she's at it. multitasking icon. π
π¦ SYNOPSIS π¦
pte_t get_and_clear_ptes (struct mm_struct *mm , unsigned long addr ,
pte_t *ptep , unsigned int nr );
look at her. four args, zero chill. π
πΈ ARGUMENTS πΈ
mmβ the address space these pages are mapped into. it's giving "whose house are we in" energy.addrβ the address where the first page is mapped. first one's the main character, the rest just follow. β¨ptepβ page table pointer for that first entry. the starting point. the anchor. the moment before the slay.nrβ how many entries we're clearing. the count. the vibe check number. π’
π DESCRIPTION π
okay so here's the tea: use this one instead of get_and_clear_full_ptes whenever you know you don't need to clear the full mm β which, ngl, is mostly the case. like, why clear the whole house when you only need to tidy one room? π
β οΈ important little note, bestie: the PTE bits in the PTE range besides the PFN can totally differ. for example, some PTEs might be write-protected. don't assume they're all matching, because they're not, and she will catch you. π
π§ CONTEXT π§
the rules of the room, lowkey:
- the caller holds the page table lock. π
- the PTEs map consecutive pages that belong to the same folio. they're a friend group, fr fr.
- the PTEs are all in the same PMD. all in the same group chat. no stragglers. π
π₯ SEE ALSO π₯
so many links, so little time. the whole squad:
Kernel file ./include/linux/pgtable.h
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)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)
aaaand that's the page!! π«Ά this cutie came to you from ./include/linux, dated October 2026 β so go forth, clear those PTEs, collect those dirty/accessed bits, and remember: same folio, same PMD, hold the lock. periodt. π
β¨π
π¦ 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