pin_user_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 from start to pin. Like, how many pages we're grabbing, starting from start 🌈
  • 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 least nr_pages long, 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_TOUCH is not set
  • FOLL_PIN is 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