pin_user_pages(9)
π pin_user_pages β bestie's guide to the kernel API manual, section 9, no cap π«Ά
Okay so picture this: you're in the Kernel API Manual (that's the 9 section, iykyk) and you need to pin user pages in memory so other devices can use them. That's literally the whole vibe of pin_user_pages. Let's get into it β¨
π NAME π
pin_user_pages β pin user pages in memory for use by other devices π
πΈ SYNOPSIS πΈ
long pin_user_pages (unsigned long start , unsigned long nr_pages ,
unsigned int gup_flags , struct page **pages );
π¦ ARGUMENTS π¦
startβ the starting user address. Where the whole thing kicks off, bestie πnr_pagesβ number of pages fromstartto pin. Like, how many pages we're grabbing, starting fromstartπgup_flagsβ flags that modify the lookup behaviour. These little guys change how the whole search goes down βpagesβ the array that receives pointers to the pages pinned. Heads up though: it should be at leastnr_pageslong, so don't be out here under-sizing it π
π DESCRIPTION π
Okay so this one is nearly the same as get_user_pages, except (and this is the iconic part, lowkey the whole personality of the function):
FOLL_TOUCHis not setFOLL_PINis set
And what does FOLL_PIN mean for you, queen? It means those pages must be released via unpin_user_page. No cap, that's not optional β that's the whole release path π
If you want the full lore, please see Documentation/core-api/pin_user_pages.rst for details. The docs ate, fr fr π
Also, super important detail: note that if a zero_page is amongst the returned pages, it will not have pins in it, and unpin_user_page*() will not remove pins from it. So don't come for that page expecting pins that were never there π«Ά
π₯ SEE ALSO π₯
Kernel file ./mm/gup.c, plus the whole friend group: 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), 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), memfd_pin_folios(9), folio_add_pins(9)
And that's the whole page, bestie! π Shoutout to the ./mm source and the October 2026 date β that's the version stamp, slay β¨ Go pin some pages responsibly, and remember: unpin them or it's giving leak π
π
π¦ 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