replace_page_cache_folio(9)
π 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 theoldandnewfolios 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 π
- Kernel file
./mm/filemap.c filemap_remove_folio(9)filemap_fdatawrite_range(9)filemap_flush_range(9)filemap_flush(9)filemap_range_has_page(9)filemap_fdatawait_range(9)filemap_fdatawait_range_keep_errors(9)file_fdatawait_range(9)filemap_fdatawait_keep_errors(9)filemap_write_and_wait_range(9)file_check_and_advance_wb_err(9)file_write_and_wait_range(9)softleaf_entry_wait_on_locked(9)folio_put_wait_locked(9)folio_unlock(9)folio_end_read(9)folio_end_private_2(9)folio_wait_private_2(9)folio_wait_private_2_killable(9)folio_end_writeback_no_dropbehind(9)folio_end_writeback(9)__folio_lock(9)page_cache_next_miss(9)page_cache_prev_miss(9)__filemap_get_folio_mpol(9)find_get_entries(9)find_lock_entries(9)filemap_get_folios(9)filemap_get_folios_contig(9)filemap_get_folios_tag(9)filemap_get_folios_dirty(9)filemap_read(9)generic_file_read_iter(9)filemap_splice_read(9)mapping_seek_hole_data(9)filemap_fault(9)read_cache_folio(9)mapping_read_folio_gfp(9)read_cache_page_gfp(9)__generic_file_write_iter(9)generic_file_write_iter(9)filemap_release_folio(9)filemap_invalidate_inode(9)filemap_cachestat(9)
β¨ 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
- 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