v1
2026-10-13
MGLRU memcg 轮转优化 · v1
MGLRU 回收在数万 memcg 时轮转耗时导致 RCU stall/soft lockup,系列优化 memcg 轮转避免停顿。
原始补丁链接
子 Patch(5)
1/5
include/linux/rculist_nulls: add hlist_nulls_add_behind_rcu()
Move some code from hlist_nulls_add_tail_rcu() to the new function hlist_nulls_add_behind_rcu() for callers that already know the last node of an hlist_nulls list, to allow constant-time appends. S
2/5
mm/vmscan: move code to lru_gen_{add,del}_memcg()
Preparation for the following patch that adds tail caching. For simplicity, hlist_nulls_del_init_rcu() is now always used, which is also valid during rotation, because the entry is immediately reinse
3/5
mm/mglru: cache the last memcg node, make tail insertion constant time
Rotating or onlining a memcg currently uses hlist_nulls_add_tail_rcu() which walks the destination bin to find its tail while holding memcg_lru.lock with interrupts disabled. With thousands of cgro
4/5
mm/mglru: avoid redundant rotations of young memcgs
Concurrent reclaimers can request promotion after another reclaimer has already moved a memcg into the young generation. Requeueing it into a random bin again adds list mutations without advancing th
5/5
mm/mglru: reschedule between memcg reclaim attempts
shrink_one() can return immediately for empty or protected memcgs, and try_to_shrink_lruvec() can break out before reaching its cond_resched(). A scan through many memcgs can repeatedly rotate entrie