folio_split_unmapped(9)
β¨ folio_split_unmapped π
okay so bestie, welcome to the folio_split_unmapped(9) page from the Kernel API Manual β yes, that one, the one that lives in the kernel docs and that you're gonna read at 2am. let's get into it π«Ά
πΈ NAME πΈ
folio_split_unmapped β split a large anon folio that is already unmapped. that's it. that's the vibe. no cap β¨
π SYNOPSIS π
int folio_split_unmapped (struct folio *folio , unsigned int new_order
);
literally the whole signature right there, look at her go π
π¦ ARGUMENTS π¦
folioβ the folio to split. this is the main character of the function, obviously πnew_orderβ the order of folios after split. i.e. what size we're coming out the other side with β¨
π DESCRIPTION π
okay so, real talk. this function is a helper for splitting folios that have already been unmapped. the use case? listen β the device or the CPU can straight up refuse to migrate THP pages in the middle of migration, and it's because of allocation issues on either side π fr fr, not their fault.
ngl, there are rules about locking and you should absolutely respect them:
anon_vma_lockis not required to be held πmmap_read_lockormmap_write_lockshould be heldfoliois expected to be locked by the caller- device-private and non device-private folios are supported, along with folios that are in the swapcache π
folioshould also be unmapped and isolated from LRU (if applicable)
lowkey important: this function doesn't do the whole glow-up for you. read the next bit carefully π
Upon return, bestie:
- the folio is not remapped
- split folios are not added to LRU
free_folio_and_swap_cacheis not called- and the new folios remain locked π
so yeah, it splits, but it leaves the rest of the chores to you. iconic behaviour honestly π
π RETURN π
0on success β slay π-EAGAINif the folio cannot be split (e.g., due to insufficient reference count or extra pins) β not slay, but like, it happens π
π§ SEE ALSO π§
Kernel file ./mm/huge_memory.c and friends, iykyk:
vmf_insert_pfn_pmd(9)vmf_insert_pfn_pud(9)vmf_insert_folio_pud(9)touch_pmd(9)zap_huge_pmd(9)__split_unmapped_folio(9)folio_check_splittable(9)__folio_split(9)folio_split(9)min_order_for_split(9)
k that's the page bestie πΈ this one's from the ./mm source tree, dated October 2026, and it's about as unfiltered as folio_split_unmapped(9) gets. go forth and split responsibly, mwah π
π¦ 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