finish_mkwrite_fault(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… finish_mkwrite_fault β€” the kernel API manual, bestie edition ✨

okay so real talk, we're in the <pink>finish_mkwrite_fault(9)</pink> page of the Kernel API Manual and it's genuinely such a slay little function. let me put you on 🫢


✨ NAME ✨

finish_mkwrite_fault β€” it finishes the page fault for a shared mapping, and it makes the PTE writeable once the page is all prepared. that's it, that's the whole vibe πŸ’…


🌸 SYNOPSIS 🌸

vm_fault_t finish_mkwrite_fault (struct vm_fault *vmf , struct folio
*folio );

like yes, two args, returns a vm_fault_t, iconic behavior honestly ✨


πŸŽ€ ARGUMENTS πŸŽ€

  • vmf β€” the structure that describes the fault πŸ’– like, it's the context bestie, it knows what's going on
  • folio β€” the folio of vmf->page 🌸 literally just that, the folio belonging to that page

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” this function handles all that is needed to finish a write page fault in a shared mapping, and the reason it even exists is that the PTE is read-only once the mapped page is prepared 😭. so somebody's gotta come in and deal with it. it handles the locking of the PTE and the modifying of it β€” both, no cap, it's doing the most and we respect it πŸ‘‘

and like, heads up bestie: the function expects the page to be locked, or expects some other protection against concurrent faults / writeback (think DAX radix tree locks). so don't come in here unlocked, that's not the vibe πŸ™ˆ

πŸ”₯ RETURN πŸ”₯

  • 0 on success ✨ we love a clean win
  • VM_FAULT_NOPAGE when the PTE got changed before we acquired the PTE lock πŸ’€ yeah, someone sniped it, it happens, not our fault

🌈 SEE ALSO 🌈

Kernel file ./mm/memory.c β€” and the whole friend group came through, fr fr:

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), restore_exclusive_pte(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), 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)


and that's the page bestie 🧚 this lil source is hanging out in ./mm, it's dated October 2026, and it's <rainbow>finish_mkwrite_fault(9)</rainbow> β€” go forth and finish those faults, ily, mwah πŸ’œπŸŽ€

πŸ“¦ where this page comes from