__split_unmapped_folio(9)
π NAME π
okay so bestie, welcome to the __split_unmapped_folio(9) page from the Kernel API Manual β this one is all about splitting an unmapped @folio into lower order folios. there are two ways to do it: uniform split or non-uniform split. slay, letβs get into it π
β¨ SYNOPSIS β¨
int __split_unmapped_folio (struct folio *folio , int new_order , struct page *split_at , struct xa_state *xas , struct address_space *mapping , enum split_type split_type );
π ARGUMENTS π
folioβ the to-be-split folio. literally the main character about to get split into lower-order pieces.new_orderβ the smallest order of the after split folios. this is because buddy allocator like split generates folios with orders fromfolio's order - 1 tonew_order.split_atβ in buddy allocator like split, the folio containingsplit_atwill be split until its order becomesnew_order.xasβ anxa_statepointing tofolio->mapping->i_pages, and it is locked by the caller. no cap, caller holds the lock.mappingβfolio->mapping. thatβs it, thatβs the argument.split_typeβ tells you if the split is uniform or not (buddy allocator like split). itβs the vibe check for which split path weβre on.
π¦ DESCRIPTION π¦
okay, so there are two modes, and they are giving very different energy:
- uniform split β the given folio gets split into multiple
new_ordersmall folios, where all the small folios have the same order. this is done whensplit_typeisSPLIT_TYPE_UNIFORM. clean, even, iconic. - buddy allocator like (non-uniform) split β the given folio is split into half, and one of the halves (the one containing the given page) is split into half until the given folioβs order becomes
new_order. this is done whensplit_typeisSPLIT_TYPE_NON_UNIFORM. itβs giving repeated half-splits, iykyk.
π the high level flow for these two methods π
- uniform split β
xasis split with no expectation of failure, and a single__split_folio_to_orderis called to split the folio intonew_orderalong with stats update. one call, no drama, no failure arc. - non-uniform split β
folio_order - new_ordercalls to__split_folio_to_orderare expected to be made in aforloop to split the folio to one lower order at a time. the folio containingsplit_atis split in each iteration.xasis split into half in each iteration and can fail. a failedxassplit leaves split folios as is without merging them back. so yeah, failure is possible and the split folios do not get a merge-back redemption arc π.
after splitting, the callerβs folio reference will be transferred to the folio containing split_at. the caller needs to unlock and/or free after-split folios if necessary. so do not forget the cleanup steps, bestie β thatβs the real main character energy π«Ά
πΈ RETURN πΈ
0β successful.<0β failed. and if-ENOMEMis returned, the folio might be split but not tonew_order, so the caller needs to check. no assuming, fr fr.
π SEE ALSO π
Kernel file ./mm/huge_memory.c is in the mix, along with:
vmf_insert_pfn_pmd(9)vmf_insert_pfn_pud(9)vmf_insert_folio_pud(9)touch_pmd(9)zap_huge_pmd(9)folio_check_splittable(9)__folio_split(9)folio_split_unmapped(9)folio_split(9)min_order_for_split(9)
mwah π this page comes from the ./mm source/version corner, dated October 2026, and itβs the __split_unmapped_folio(9) girlie signing off. periodt πβ¨
π¦ 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