folio_lruvec(9)
π folio_lruvec β the Kernel API Manual, bestie edition β¨
Okay so picture this: it's a folio_lruvec(9) moment, we're deep in the kernel, and you need the lruvec for a folio you're about to isolate or put back on an LRU. Let's get into it π«Ά
πΈ NAME πΈ
folio_lruvec β returns the lruvec, for when you're isolating or putting an LRU folio. That's the whole gig π
β¨ SYNOPSIS β¨
struct lruvec * folio_lruvec (struct folio *folio );
π ARGUMENTS π
folioβ Pointer to the folio. That's it. That's the argument. King behavior honestly π
π¦ DESCRIPTION π¦
So here's the vibe check. You call this with rcu_read_lock held, because that's what keeps the returned lruvec alive for as long as you're using it. No lock, no lifetime guarantee β that's the deal π€
But bestie, listen to me: holdingrcu_read_lockalone will NOT guarantee the stability of thefolio->lruvecassociation. If this races with cgroup deletion, the folio can get reparented to an ancestor. So likeβ¦ the pointer's alive, but it might not be pointing at your lruvec anymore. Messy π
Want both the lifetime and the stability of the binding? Use folio_lruvec_lock. Once a lruvec is locked, you can call folio_lruvec on other folios too, and their binding is stable β as long as the returned lruvec matches the one you've already got locked. Lowkey iconic for lock batching, fr fr π₯
π SEE ALSO π
Kernel file ./include/linux/memcontrol.h:
mem_cgroup_shrink_is_root(9)mem_cgroup_charge(9)mem_cgroup_uncharge(9)mem_cgroup_lruvec(9)parent_mem_cgroup(9)
That's the whole page, bestie β go forth and lock responsibly π§π
Sign-off szn: this little gem lives in ./include/linux, and it's dated October 2026 πβ
π¦ 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