replace_page_cache_folio(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– replace_page_cache_folio πŸ’–

okay bestie, welcome to the kernel API manual for replace_page_cache_folio(9) β€” she's a little function from the <pink>Kernel API Manual</pink>, and honestly? she's iconic for one specific reason that we'll get to. buckle up πŸŽ€


🌸 NAME 🌸

replace_page_cache_folio β€” swap out a pagecache folio for a shiny brand-new one, no cap ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

void replace_page_cache_folio (struct folio *old , struct folio *new );

that's it. that's the whole signature. two folios, one job πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • old β€” the folio getting replaced. she's being asked to step aside πŸ‘‹
  • new β€” the folio doing the replacing. she's the understudy and she's ABOUT to go on 🌟

⭐ DESCRIPTION ⭐

so like, what does she actually do? This function replaces a folio in the pagecache with a new one. periodt. 🫢

On success it acquires the pagecache reference for the new folio and drops it for the old folio β€” so the refcount handoff is handled for you, which is lowkey a serve πŸ’…

Both the old and new folios must be locked. fr fr. do not skip this. locked folios only, bestie πŸ”’

Also β€” and this is the part people forget β€” this function does not add the new folio to the LRU. The caller must do that. she does not do it for you, she is not your mom πŸ™ˆ

The remove + add is atomic. and the absolute main-character flex: this function cannot fail. no return value, no error path, no "whoops try again". it literally cannot miss. 😭πŸ”₯


🌈 SEE ALSO 🌈

okay this list is LONG but we do not skip a single one, every sibling gets their moment πŸ‘‘


✨ that's the whole page, bestie ✨ this one lives in ./mm, it's dated October 2026, and it's filed under replace_page_cache_folio(9). go forth and lock your folios πŸ’œπŸ¦‹πŸ’…

πŸ“¦ where this page comes from