lru_cache_drain_for_folio(9)
πΈ NAME β lru_cache_drain_for_folio(9) from the Kernel API Manual πΈ
okay bestie, this page is literally about lru_cache_drain_for_folio β and its whole thing is: drain LRU caches if the caches might hold folio references. π
β¨
β¨ SYNOPSIS β¨
void lru_cache_drain_for_folio (const struct folio *folio , unsigned int
extra_refs , enum lru_cache_drained *drained );
π«Ά ARGUMENTS π«Ά
folioβ the folio. π¦extra_refsβ extra folio references held by the caller. πdrainedβ drain status for batch folio processing. π
π DESCRIPTION π
okay so the mission is: drain LRU caches if the caches might hold folio references. π It starts with a local LRU cache drain, and then β if local draining was insufficient β it drains LRU caches on all CPUs. that's the escalation arc, no cap. π₯
Now the detection part: this function detects LRU cache references by comparing the folio refcount with the sum of the expected folio refcount + extra references held by the caller. π literally comparing refcounts, that's the vibe.
β οΈ and bestie, do not come forPG_lruhere: we cannot rely onPG_lruto reliably detect all LRU cache references. there are rare scenarios β concurrent folio(un)mapping)β where this function might miss detecting LRU cache references. π keep that in mind, fr fr.
If drained is not NULL, the function will avoid re-draining LRU caches when processing multiple folios in a row. π in that case, the variable drained points at must be initialized to LRU_CACHE_NOT_DRAINED before the first invocation by the caller. do not skip the setup, bestie β that's the whole point. π«Ά
π SEE ALSO π
Kernel file ./mm/folio.c:
folio_mark_accessed(9)folio_add_lru(9)folio_add_lru_vma(9)deactivate_file_folio(9)folio_mark_lazyfree(9)folios_put_refs(9)release_pages(9)folio_batch_remove_exceptionals(9)
π mwah! this cutie came from the source ./mm, dated October 2026, and it's literally the lru_cache_drain_for_folio(9) page. periodt. π
πΈ
π¦ 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