fixup_user_fault(9)
β¨ fixup_user_fault(9) β¨
okay so real talk, this is a page from the Kernel API Manual and it's all about fixup_user_fault β manually resolving a user page fault. bestie, let's get into it π
πΈ SYNOPSIS πΈ
int fixup_user_fault (struct mm_struct *mm , unsigned long address ,
unsigned int fault_flags , bool *unlocked );
π ARGUMENTS π
mmβ themm_structof the target mm. that's the memory map you're working with, periodt.addressβ the user address. yep, that one.fault_flagsβ flags to pass down tohandle_mm_fault. literally handing them off, no notes.unlockedβ did we unlock themmap_lockwhile retrying? it can maybe beNULLif the caller does not allow retry. β οΈ and if it isNULL, the caller must guarantee thatfault_flagsdoes not containFAULT_FLAG_ALLOW_RETRY. no cap, that's a hard requirement.
π¦ DESCRIPTION π¦
so this is meant to be called in the very specific scenario where, for locking reasons, we try to access user memory in atomic context (within a pagefault_disable section), it returns -EFAULT, and we want to resolve the user fault before trying again. it's giving "let me fix this before we go back in" energy πβ¨
typically this is meant to be used by the futex code. iykyk.
the main difference with get_user_pages is that this function will unconditionally call handle_mm_fault, which will in turn perform all the necessary SW fixup of the dirty and young bits in the PTE β whereas get_user_pages only guarantees to update these in the struct page. okay so that's a whole thing. π₯
this is important for some architectures where those bits also gate the access permission to the page, because they are maintained in software. on such architectures, gup will not be enough to make a subsequent access succeed. fr fr, it just won't. π
this function will not return with an unlockedmmap_lock. so it has not the same semantics wrt themm->mmap_lockas doesfilemap_fault. keep that in mind bestie, they are not the same vibe.
π SEE ALSO π
the Kernel file ./mm/gup.c says hi π β go check out:
try_grab_folio(9), unpin_user_page(9), unpin_folio(9), folio_add_pin(9), unpin_user_pages_dirty_lock(9), unpin_user_page_range_dirty_lock(9), unpin_user_pages(9), unpin_user_folio(9), unpin_folios(9), try_grab_folio_fast(9), follow_page_mask(9), __get_user_pages(9), populate_vma_page_range(9), fault_in_writeable(9), fault_in_subpage_writeable(9), fault_in_readable(9), get_dump_page(9), get_user_pages_remote(9), get_user_pages(9), get_user_pages_fast_only(9), get_user_pages_fast(9), pin_user_pages_fast(9), pin_user_pages_remote(9), pin_user_pages(9), memfd_pin_folios(9), folio_add_pins(9) β that's the whole squad, go say hi π«Ά
and that's the page!! π this lil gem lives in ./mm and it's dated October 2026 β slay, iconic, no notes, bye bestie πβ¨
π¦ 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