folio_put_swap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… folio_put_swap β€” the kernel API manual, bestie edition πŸŽ€

okay so real talk: we're in the Kernel API Manual today and the main character is folio_put_swap(9). pull up a chair, this one's short but she's important ✨


🌸 NAME 🌸

folio_put_swap β€” decreases the swap count of swap entries of a folio. that's it, that's the vibe. lowkey does exactly what it says on the tin πŸ’–


✨ SYNOPSIS ✨

void folio_put_swap (struct folio *folio , struct page *page );

no return value, she just does the thing and dips 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • folio β€” the folio with swap entries bounded. and like, pay attention here: it must be in the swap cache and locked. no exceptions, bestie, it's giving non-negotiable πŸ’…
  • page β€” if it's not NULL, then you're only decreasing the swap count of this page. if it is NULL, well… you know what you signed up for 😌

πŸ”₯ DESCRIPTION πŸ”₯

so here's the tea: this function will not free the swap slots, even if the swap count drops all the way to zero. why? because they're still pinned by the swap cache, periodt. 😭

if you do want them freed, the user may call folio_free_swap to free them. that's the move. iykyk 🧚


πŸ‘‘ CONTEXT πŸ‘‘

the caller must ensure the folio is locked and in the swap cache. fr fr, do not skip this one, it's literally the whole assignment πŸ’€


🌈 SEE ALSO 🌈

the kernel file ./mm/swapfile.c and her whole friend group:


⭐ reminder bestie: locked + in the swap cache, or this whole thing is a no-go πŸ“

and that's the page!! mwah πŸ’– this lil icon lives under ./mm and was dated October 2026 β€” go off, ./mm, we stan a whole directory. πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from