restore_exclusive_pte(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 covers address ✨
  • folio β€” the folio that's mapped
  • page β€” 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 at ptep πŸ‘‘

πŸ’– 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:

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