folio_dup_swap(9)
π folio_dup_swap(9)
okay so this is a page straight out of the Kernel API Manual, bestie β it's called folio_dup_swap(9) and honestly? it's giving "small helper, big responsibility." let's get into it β¨
πΈ NAME
folio_dup_swap β bump up the swap count on the swap entries of a folio. that's the whole vibe. no cap π
π SYNOPSIS
int folio_dup_swap (struct folio *folio , struct page *page );
like, yes, it returns an int, and yes, it takes exactly those two things. copy it exactly, bestie, don't get creative π«Ά
π¦ ARGUMENTS
folioβ the folio that has swap entries bounded to it. this is the main character of the whole operation πpageβ if this isn'tNULL, then we only increase the swap count of this specific page. if it isNULL, we're doing the whole folio. iykyk β¨
π DESCRIPTION
okay so here's the tea π β this one typically gets called when the folio is unmapped and its swap entry is stepping in to take its place.
swap entries allocated to a folio start out with count == 0 and they're pinned by the swap cache. and here's the sneaky part: that swap cache pin doesn't increase the swap count. nope. it just sits there.
so this helper comes in and sets the initial count == 1, then keeps increasing the count as the folio gets unmapped and swap entries that reference the slots are generated to replace the folio. that's literally the entire job. slay π
π₯ CONTEXT
the caller must make sure the folio is locked and in the swap cache. this isn't optional, bestie β it's the price of admission π
π NOTE
the caller also has to ensure there is no raced call to swap_put_entries_direct on its swap entry before this helper returns β otherwise the swap count may underflow. and that is a bad time. like, genuinely. π
please take this seriously fr fr π
π§ SEE ALSO
kernel file ./mm/swapfile.c, plus the whole friend group:
swap_put_entries_cluster(9)swap_dup_entries_cluster(9)folio_alloc_swap(9)folio_put_swap(9)swap_entry_swapped(9)folio_free_swap(9)swap_put_entries_direct(9)swap_alloc_hibernation_slot(9)swap_free_hibernation_slot(9)pin_hibernation_swap_type(9)unpin_hibernation_swap_type(9)find_hibernation_swap_type(9)
and that's the whole page, bestie!! this lil icon was brought to you by ./mm, dated October 2026, and it's folio_dup_swap(9) forever and always πππ¦β¨
π¦ 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