follow_page_mask(9)
β¨ follow_page_mask(9) β¨
okay so bestie, this one's from the Kernel API Manual and it's literally the glow-up page for looking up page descriptors π
like, given a user-virtual address, it finds the struct page for you. no cap.
πΈ SYNOPSIS πΈ
struct page * follow_page_mask (struct vm_area_struct *vma , unsigned
long address , unsigned int flags , unsigned long *page_mask );
like yes, that's the whole signature, no shortcuts π
π¦ ARGUMENTS π¦
vmaβ thevm_area_structmapping address, aka where this whole thing lives πΊοΈaddressβ the virtual address you're looking up, the main character of the operation βflagsβ the flags that modify how the lookup behaves, lowkey the personality settings π§page_maskβ a pointer to the outputpage_mask, it's giving "I'll tell you when we're done" π€
π DESCRIPTION π
so flags can have FOLL_ flags set, and those are defined in <linux/mm.h> π« iykyk.
when you're getting an anonymous page and the caller has to trigger unsharing of a shared anonymous page first, -EMLINK is returned π the caller should trigger a fault with FAULT_FLAG_UNSHARE set. and ngl, note that unsharing is only relevant with FOLL_PIN and !FOLL_WRITE β that's the vibe check right there π«Ά
on output, page_mask is set according to the size of the page β¨
π RETURN π
it returns the mapped struct page *, or NULL if no mapping exists, or an error pointer if there's a mapping to something not represented by a page descriptor (see also vm_normal_page) π like it's literally doing the most to be helpful.
π SEE ALSO π
all the Kernel file ./mm/gup.c besties, in the order the page lists them, periodt:
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)__get_user_pages(9)fixup_user_fault(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)
π«Ά and that's the whole page, bestie β everything's here, nothing dropped, no details left on read.
okay and finally the sign-off: this lil beauty comes from ./mm, dated October 2026, and that's the tea πβ¨ slay, go read gup.c now π
π¦ 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