page_cache_prev_miss(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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_scan will be true. handy check, iykyk 🧚
  • and in the rare case of wrap-around, ULONG_MAX will be returned πŸ‘€ that's the special one, don't forget it

πŸ“ SEE ALSO πŸ“

Kernel file ./mm/filemap.c, plus the whole friend group πŸ’…:


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