v8
2026-11-06
memcg stock 迁移 · v8
v8将memcg内存stock迁入page_counter,并调整try_charge与memsw计费流程。
原始补丁链接
子 Patch(7)
1/7
mm/memcontrol: flatten try_charge_memcg control flow
Refactor try_charge_memcg by flattening the nested memsw/memory page_counter operations to separate the logic between the two. When page_counter_try_charge is made stock-aware, this flattening makes
2/7
mm/page_counter: introduce per-CPU stock
Introduce a copy of the seven-slot per-CPU stock representation from memcg in the page_counter layer. struct page_counter_stock_pcp preserves everything from struct memcg_stock_pcp, but adds a new bac
3/7
mm/page_counter: make page_counter_try_charge() stock-aware
Make page_counter_try_charge() consume stock transparently to callers while preserving the same semantics as try_charge_memcg’s greedy charge attempt, refill, and !allow_spinning special case. page_c
4/7
mm/memcontrol: check PF_MEMALLOC after trying the limits
PF_MEMALLOC charges are currently forced right after consume_stock(), before trying the limits, so that they skip memory.high and the high_work worker can’t queue itself from its own reclaim. A later
5/7
mm/memcontrol: move memory stock to page counters
Transition memcg to use the page_counter_stock for the memory page_counter instead of relying on a memcg-wide stock. One aspect that remains non-transparent to memcg is the uncharge path. This is int
6/7
mm/memcontrol: add stock to the memsw page counter
Attach legacy memsw page counters to their own seven-slot per-CPU stock. Charge, refill, drain, and hotplug handling now operate on the memory and memsw banks independently. Factor the common drain s
7/7
mm/memcontrol: restrict memory stock to leaf cgroups on v2
In the old memcg_stock world, non-leaf cgroups in cgroup v2 were never directly charged (except for reparented objcgs), since processes can only live in leaf cgroups. This meant that stocking was excl