test_and_clear_young_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… test_and_clear_young_ptes(9) β€” a Kernel API Manual moment πŸŽ€

okay so bestie, we're in the Kernel API Manual today and the star of the show is test_and_clear_young_ptes(9). yes the name is a mouthful, no we're not skipping it, it's literally iconic. sit down, hydrate, let's go ✨


🌸 NAME 🌸

test_and_clear_young_ptes β€” marks PTEs that map consecutive pages of the same folio as old. that's the whole vibe. it's giving "aging out" but for page table entries 🫢


✨ SYNOPSIS ✨

bool test_and_clear_young_ptes (struct vm_area_struct *vma , unsigned
long addr , pte_t *ptep , unsigned int nr );

note the return type: bool. note the four args. no cap, that's it πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • vma β€” the virtual memory area the pages are mapped into. like, the neighborhood bestie 🏑
  • addr β€” the address the first page is mapped at. page one, main character energy ⭐
  • ptep β€” page table pointer for the first entry. your lil entry point πŸ’…
  • nr β€” number of entries to clear the access bit on. yes it's a count, yes it matters πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

so this one may be overridden by the architecture. iykyk. if the arch doesn't have its own fancy version, it's implemented as a simple loop over ptep_test_and_clear_young. simple loop, simple slay 🌈

⚠️ also psa: the PTE bits in the PTE range besides the PFN can differ. for example, some PTEs might be write-protected. so don't go assuming they're all twins, because they are not πŸ™ˆ

🧚 CONTEXT 🧚

the caller holds the page table lock πŸ”’. the PTEs map consecutive pages that belong to the same folio. and the PTEs are all in the same PMD. that's the whole situation, no notes πŸ’€


πŸ‘‘ RETURN πŸ‘‘

whether any PTE was young. that's it. a bool. literally yes or no πŸ“


🌸 SEE ALSO 🌸

kernel file ./include/linux/pgtable.h β€” and the whole friend group:


and that's the page bb 🫢 sourced from ./include/linux, dated October 2026, living under the Kernel API Manual banner β€” test_and_clear_young_ptes(9), periodt. go clear some access bits responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from