__swap_cache_add_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __swap_cache_add_folio(9) ✨

okay so this is a page from the Kernel API Manual, and bestie, it's a short one but it matters β€” we're talking about putting a folio into the swap cache, no cap πŸ’…


🌸 NAME 🌸

__swap_cache_add_folio β€” add a folio to the swap cache and update stats. that's it. that's the vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

void __swap_cache_add_folio (struct swap_cluster_info *ci , struct folio
*folio , swp_entry_t entry );

literally just three args and no return value, she's a void, she does the thing and dips πŸ’β€β™€οΈ


πŸ’– ARGUMENTS πŸ’–

  • ci β€” the locked swap cluster. yes, locked, we'll get to that in a sec, don't come in here unlocked πŸ™ˆ
  • folio β€” the folio to be added. the main character of this whole operation tbh πŸ‘‘
  • entry β€” the swap entry corresponding to the folio. it's giving "the folio's home address" 🏠

🌈 DESCRIPTION 🌈

so this function unconditionally adds a folio to the swap cache. note the word unconditionally β€” she does not check, she does not ask, she does not verify. you, the caller, are the one who must ensure all slots are usable and have no conflicts. that's your job, bestie, not hers 🫢

what she actually does:

  • assigns entry to folio->swap
  • increases the folio refcount by the number of pages
  • updates swap cache stats

three little steps, very demure, very mindful ✨

⚠️ fr fr though β€” "unconditionally" means no guardrails. if you call this with bad slots or conflicts, that's on you. this is not a function that checks your homework for you. πŸ’€

πŸ”₯ CONTEXT πŸ”₯

the caller must ensure the folio is locked and lock the cluster that holds the entries. two locks minimum, no shortcuts. this is the "put on your seatbelt before you drive" part of the page πŸš—πŸ’¨


🧚 SEE ALSO 🧚

all found in the kernel file ./mm/swap_state.c β€” here's the whole squad:


and that's the whole page, short and slay πŸŽ€ this lovely little number lives in ./mm and is dated October 2026 β€” go forth, lock your clusters, and remember: unconditional means unconditional πŸ’œπŸ¦‹

πŸ“¦ where this page comes from