get_and_clear_full_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… get_and_clear_full_ptes(9) β€” from the Kernel API Manual, bestie

okay so picture this: you're deep in the kernel, you've got a whole run of PTEs pointing at consecutive pages of the same folio, and you need them GONE but you also need to pocket the dirty/accessed bits on the way out. that's this function. she's giving cleanup crew with a clipboard. 🧹✨


✨ SYNOPSIS ✨

pte_t get_and_clear_full_ptes (struct mm_struct *mm , unsigned long addr
, pte_t *ptep , unsigned int nr , int full );

like, it returns a pte_t. don't ask questions, just accept the gift. 🎁


🫢 ARGUMENTS 🫢

  • mm β€” the address space these pages are living in. her whole world, basically.
  • addr β€” the address where the first page is mapped. everything else lines up after her.
  • ptep β€” the page table pointer for that first entry. your starting point, your main character pointer. πŸ‘‘
  • nr β€” how many entries we're clearing. the headcount.
  • full β€” whether we're clearing a full mm or not. yes/no energy, but please pass the actual value it expects, not my vibes.

πŸ’– DESCRIPTION πŸ’–

so, architectures are allowed to override this one β€” it's a "may be overridden" situation, lowkey iconic of her. but if nobody overrides it, the default implementation is literally just a simple loop over ptep_get_and_clear_full, merging those dirty/accessed bits into the returned PTE. that's it. that's the whole thing. no cap.

⚠️ heads up bestie: the PTE bits in the PTE range besides the PFN can absolutely differ between entries. for example, some PTEs might be write-protected. so don't go assuming the whole range is uniform β€” she's not. 😭

🌸 CONTEXT 🌸

the rules of the group chat, fr fr:

  • the caller holds the page table lock. no lock, no entry. πŸ’…
  • the PTEs map consecutive pages that belong to the same folio.
  • the PTEs are all in the same PMD. all of them. every single one.

πŸ¦‹ SEE ALSO πŸ¦‹

the whole extended friend group, in order, no one left out because we do NOT do that here:

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_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)


aight that's the page! πŸŽ€ this one lives over in ./include/linux and she's stamped October 2026 β€” go off, calendar. mwah, stay hydrated, and remember to hold the page table lock. πŸ“πŸ’œ

πŸ“¦ where this page comes from