__swap_cache_add_folio(9)
β¨ __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
entrytofolio->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:
swap_cache_get_folio(9)swap_cache_has_folio(9)swap_cache_get_shadow(9)__swap_cache_add_check(9)__swap_cache_del_folio(9)swap_cache_del_folio(9)__swap_cache_replace_folio(9)swap_cache_alloc_folio(9)swap_update_readahead(9)swapin_sync(9)swap_cluster_readahead(9)swap_vma_readahead(9)swapin_readahead(9)
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
- 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