try_grab_folio_fast(9)
π try_grab_folio_fast β from the Kernel API Manual, bestie π
okay so picture this: you're deep in the kernel, the fast path is right there, and you need to grab or pin a folio. that's the whole vibe of this page. welcome to try_grab_folio_fast(9), it's giving "low-level memory management but make it fashion" β¨
β¨ NAME β¨
try_grab_folio_fast β Attempt to get or pin a folio in fast path. that's it, that's the girl π
πΈ SYNOPSIS πΈ
struct folio * try_grab_folio_fast (struct page *page , int refs ,
unsigned int flags );
like, look at her signature. iconic. no cap.
π¦ ARGUMENTS π¦
pageβ pointer to page to be grabbed. yes bestie, this is the page we're snatching up π«Άrefsβ the value to (effectively) add to the folio's refcount. emphasis on effectively, the math is doing something, we'll get to itflagsβ gup flags: these are theFOLL_*flag values. those ones, iykyk π₯
π DESCRIPTION π
so first things first, vocabulary check π β "grab" names in this file mean, "look at flags to decide whether to use FOLL_PIN or FOLL_GET behavior, when incrementing the folio's refcount." that's the whole definition, periodt.
important bestie β EitherFOLL_PINorFOLL_GET(or neither) must be set, but not both at the same time. (and yeah, that's true throughout theget_user_pages*()andpin_user_pages*()APIs. it's a whole family rule, fr fr.)
now the cases, because there ARE cases and you're gonna want to know them π
FOLL_GET: folio's refcount will be incremented byrefs.FOLL_PINon large folios: folio's refcount will be incremented byrefs, and its pincount will be incremented byrefs. two for the price of one, ate πFOLL_PINon single-page folios: folio's refcount will be incremented byrefs * GUP_PIN_COUNTING_BIAS. the bias is doing heavy lifting here, don't ask her to explain
It uses add ref unless zero to elevate the folio refcount β and it must be called in fast path only. not the slow path, not the vibes path, the fast path. main character energy only π
β RETURN β
- the folio containing
page(with refcount appropriately incremented) β that's success, slay π NULLβ that's failure, we don't love her but we respect her π
and one more thing: if neither FOLL_GET nor FOLL_PIN was set, that's considered failure, and furthermore, a likely bug in the caller, so a warning is also emitted. so likeβ¦ you get a NULL AND you get yelled at. the kernel is literally your bestie who tells you the truth π
π§ 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)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)pin_user_pages(9)memfd_pin_folios(9)folio_add_pins(9)
anyway that's the page!! came from ./mm, dated October 2026, and honestly?? obsessed. go pin a folio responsibly, 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