page_cache_prev_miss(9)
π page_cache_prev_miss β Kernel API Manual π
okay bestie, welcome to the Kernel API Manual entry for page_cache_prev_miss and trust me, this one is lowkey iconic once you get the vibe β¨
πΈ NAME πΈ
page_cache_prev_miss β find the previous gap in the page cache, fr fr π«Ά
β¨ SYNOPSIS β¨
pgoff_t page_cache_prev_miss (struct address_space *mapping , pgoff_t
index , unsigned long max_scan );
that's the whole signature, no cap π
π¦ ARGUMENTS π¦
mappingβ the mapping. yeah, that's literally it, it's the mapping bestie πindexβ the index. we love a self-explanatory name πmax_scanβ the maximum range to search, so like, how far back we're willing to go looking π₯
π DESCRIPTION π
so the way this works: it searches the range [max(index - max_scan + 1, 0), index] looking for the gap with the highest index. that's the whole mission, periodt π
okay but here's the caveat and it's kind of a big one π β you may call this function under the rcu_read_lock. however, that does not atomically search a snapshot of the cache at a single point in time. it's giving "vibes, not guarantees" ngl.
for example (and this is the example from the docs, I'm not making it up): if a gap is created at index 10, and then subsequently a gap is created at index 5, page_cache_prev_miss covering both indices may return 5 if called under the rcu_read_lock. so yeah, the answer can be the older/lower one depending on timing π that's just how it is under RCU.
β RETURN β
- the index of the gap if found π
- otherwise an index outside the range specified β and in that case,
index - return >= max_scanwill betrue. handy check, iykyk π§ - and in the rare case of wrap-around,
ULONG_MAXwill be returned π that's the special one, don't forget it
π SEE ALSO π
Kernel file ./mm/filemap.c, plus the whole friend group π
:
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)replace_page_cache_folio(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)__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)
and that's the page bestie π«Ά source location is ./mm, dated October 2026, filed under page_cache_prev_miss(9) β go forth and find those gaps, you absolute main character πβ¨π
π¦ 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