folio_try_s...non_rmap_pmd(9)
π 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
0if marking the mapped pages possibly shared succeeded β - returns
-EBUSYotherwise π
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:
folio_dup_file_rmap_ptes(9)folio_dup_file_rmap_pmd(9)folio_try_dup_anon_rmap_ptes(9)folio_try_dup_anon_rmap_pmd(9)folio_try_share_anon_rmap_pte(9)page_vma_mapped_walk_restart(9)
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
- 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