folio_try_s...non_rmap_pmd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… folio_try_share_anon_rmap_pmd β€” the Kernel API Manual, section 9 ✨

okay so bestie, welcome to page nine of the Kernel API Manual, and today's main character is folio_try_share_anon_rmap_pmd πŸŽ€ she's a little function with a big name and she has ONE job, but it's lowkey an important one, so let's get into it.


🌸 NAME 🌸

folio_try_share_anon_rmap_pmd β€” try marking an exclusive anonymous page range mapped by a PMD possibly shared to prepare for temporary unmapping πŸ’…

like, yes, that is the whole name, yes it's a mouthful, no we are not shortening it, periodt.


✨ SYNOPSIS ✨

int folio_try_share_anon_rmap_pmd (struct folio *folio , struct page
*page );

look at her go 🫢 returns an int, takes a struct folio *folio and a struct page *page, and honestly the int return is the whole plot twist here, iykyk.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • folio β€” the folio whose mapping we're sharing. she's the vibe, she's the subject of the whole operation πŸ’–
  • page β€” the first page whose mapping we're sharing. first one, not just any one, not the middle one β€” the first. πŸ™ˆ

πŸ”₯ DESCRIPTION πŸ”₯

okay so the page range of the folio is defined by [page, page + HPAGE_PMD_NR) β€” that's the window we're working with, and no, it is not negotiable ✨

the caller needs to hold the page table lock and has to have the page table entries cleared/invalidated. both. not one, not the other. both. this is not a drill 🚨

she's similar to folio_try_dup_anon_rmap_pmd, BUT β€” and this is the tea β˜• β€” she is not used during fork to duplicate a mapping. instead, she's used to prepare for temporarily unmapping parts of a folio (swap, migration) via folio_remove_rmap_pmd. so like, same energy, different purpose. got it? good πŸ’…

marking the mapped pages shared can only fail if the folio maybe pinned. and device private folios cannot get pinned, and consequently this function cannot fail. not "probably won't" β€” cannot. iconic honestly πŸ‘‘

so the return situation is:

  • returns 0 if marking the mapped pages possibly shared succeeded βœ…
  • returns -EBUSY otherwise 😭

that's it, that's the API. two outcomes, zero drama (unless it's -EBUSY, then a little drama).


πŸ’œ SEE ALSO πŸ’œ

kernel file ./include/linux/rmap.h and her whole friend group:

go read those too, bestie, you'll be so smart, I promise 🧚


reminder bestie: hold the page table lock, clear/invalidate those page table entries, and remember that -EBUSY is a real answer, not a personal attack πŸ’€

that's the page!! this one came from ./include/linux (the kernel file ./include/linux/rmap.h), dated October 2026, living in section 9 of the Kernel API Manual β€” mwah, slay, go read some more rmap functions, ily πŸ“πŸ’–βœ¨

πŸ“¦ where this page comes from