clear_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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


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