restore_exclusive_pte(9)
π restore_exclusive_pte(9) β the Kernel API Manual, bestie edition β¨
okay so you're in the restore_exclusive_pte(9) girlies now, congrats π this one lives in the Kernel API Manual and it's lowkey a glow-up function: it takes a device-exclusive entry and puts it back to being a normal present pte. iconic behavior honestly π¦
πΈ NAME πΈ
restore_exclusive_pte β restore a device-exclusive entry π
β¨ SYNOPSIS β¨
void restore_exclusive_pte (struct vm_area_struct *vma , struct folio
*folio , struct page *page , unsigned long address , pte_t *ptep , pte_t
orig_pte );
yeah she takes six arguments, she's high-maintenance, we love her for it π
π«Ά ARGUMENTS π«Ά
vmaβ the VMA that coversaddressβ¨folioβ the folio that's mappedpageβ the mapped folio page (yes bestie, the page of the folio, not a different thing, they're a set π)addressβ the virtual address, the actual spot, the address-address πΊοΈptepβ a pte pointer into the locked page table mapping the folio page πorig_pteβ the pte value sitting atptepπ
π DESCRIPTION π
So what she does: restore a device-exclusive non-swap entry back to an ordinary present pte. that's the whole vibe. a little "never mind, put it back" moment π
The rules though, fr fr: the folio and the page table must be locked, and MMU notifiers must have been called to invalidate any (exclusive) device mappings. no shortcuts, no vibes-only locking, it's giving "read the instructions" π
Why the folio lock? okay so bestie, locking the folio makes sure that anybody who just converted the pte to a device-exclusive entry can map it into the device to make forward progress without others converting it back until the folio was unlocked. it's a whole "let her finish" situation πβ¨
If the folio lock ever becomes an issue, we can stop relying on the folio lock β it might make some scenarios with heavy thrashing less likely to make forward progress, but these scenarios might not be valid use cases. so like, possible, but also maybe not a real problem, iykyk π€·ββοΈ
β οΈ important caveat time: note that the folio lock does not protect against all cases of concurrent page table modifications (e.g.,MADV_DONTNEED,mprotect), so device drivers must use MMU notifiers to sync against any concurrent changes. the folio lock is not the main character here, the MMU notifiers are π
π₯ SEE ALSO π₯
Kernel file ./mm/memory.c:
free_pgd_range(9)free_pgtables(9)__vm_normal_page(9)vm_normal_page(9)vm_normal_folio(9)vm_normal_page_pmd(9)vm_normal_folio_pmd(9)vm_normal_page_pud(9)cond_install_uffd_wp_ptes(9)zap_vma_for_reaping(9)unmap_vmas(9)zap_vma_range_batched(9)zap_vma_range(9)zap_special_vma_range(9)vm_insert_pages(9)vm_insert_page(9)vm_map_pages(9)vm_map_pages_zero(9)vmf_insert_pfn_prot(9)vmf_insert_pfn(9)remap_pfn_range(9)vm_iomap_memory(9)__vmf_anon_prepare(9)finish_mkwrite_fault(9)unmap_mapping_folio(9)unmap_mapping_pages(9)unmap_mapping_range(9)set_pte_range(9)finish_fault(9)mm_account_fault(9)follow_pfnmap_start(9)follow_pfnmap_end(9)generic_access_phys(9)access_remote_vm(9)copy_remote_vm_str(9)folio_zero_user(9)
like, that's a whole reading list, go off sis ππ
okay that's the page!! sign-off time π«Ά this beauty came from ./mm, dated October 2026, and she answers to restore_exclusive_pte(9) if you need her again. mwah πβ¨π
π¦ 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