test_and_clear_young_ptes(9)
π 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:
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)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)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)
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
- 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