get_and_clear_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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


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