__folio_split(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __folio_split β€” the Kernel API Manual girlie is here to explain it ✨

okay so bestie, this is __folio_split(9) from the Kernel API Manual, and it's literally the function that splits a folio at @split_at down to a @new_order folio. icon behavior. let's get into it 🫢


🌸 SYNOPSIS 🌸

int __folio_split (struct folio *folio , unsigned int new_order , struct
page *split_at , struct page *lock_at , struct list_head *list , enum
split_type split_type );

πŸŽ€ ARGUMENTS πŸŽ€

  • folio β€” the folio you're splitting, bestie. that's the main character πŸ’…
  • new_order β€” the order of the new folio (yes it's an unsigned int, no we're not debating it)
  • split_at β€” a page within the new folio πŸ“
  • lock_at β€” a page within folio that gets left locked for the caller πŸ”’
  • list β€” after-split folios get put on it, but only if it's non-NULL 🧺
  • split_type β€” tells it whether to do a uniform split or not (not uniform = the non-uniform split) 🌈

✨ DESCRIPTION ✨

So it calls __split_unmapped_folio to actually perform the uniform and non-uniform split. it's also the one in charge of checking whether the split is even supported or not, and of preparing the folio for __split_unmapped_folio. basically it's the responsible friend of the group chat 🫑

After splitting, the after-split folio containing lock_at stays locked, and all the others get unlocked. and that looks like:

  1. for uniform split, lock_at points to one of folio's subpages πŸ‘‘
  2. for buddy allocator like (non-uniform) split, lock_at points to folio itself πŸ’€

πŸ”₯ RETURN πŸ”₯

  • 0 β€” successful, slay πŸ’–
  • <0 β€” failed 😭 (and if -ENOMEM is returned, the folio might be split but not to new_order β€” so the caller needs to check, no cap, do not skip this)
⚠️ fr fr: that -ENOMEM case is giving "partial success but make it stressful" β€” the caller has to check. don't just assume.

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./mm/huge_memory.c β€” plus these icons:


aaaand that's the page πŸ’œ it lives in ./mm and the version/date stamp on this one is October 2026 β€” so future-core of it, honestly. mwah, go split some folios responsibly πŸ‘‘πŸŽ€

πŸ“¦ where this page comes from