v1 2026-10-03

xswap 按实际后端计费 · v1

拆分 swap memcg 计费,使 zswap 支持的 xswap 仅在实际取得后端槽时计入 swap.current,修正 swap.max=0 无法回收。

原始补丁链接

子 Patch(6)

1/6
mm, swap: split the swap memcg charge helpers
From: Nhat Pham nphamcs@gmail.com Split __mem_cgroup_try_charge_swap() into separate get, charge, record, uncharge and put helpers, and factor mem_cgroup_may_zswap() out of obj_cgroup_may_zswap().
2/6
mm, swap: do not charge zswap-backed xswap entries
From: Nhat Pham nphamcs@gmail.com An xswap entry occupies no physical swap space: its data lives in zswap until a backend is taken. It was nevertheless charged against memcg->swap at allocation, a
3/6
mm, swap: charge an xswap entry when it gets physical backing
From: Nhat Pham nphamcs@gmail.com An xswap entry is recorded but not charged at allocation. Charge memcg->swap when the entry takes a physical backend slot, in xswap_backend_alloc(), and uncharge
4/6
mm, swap: don't gate xswap on the physical swap free count
From: Nhat Pham nphamcs@gmail.com An xswap entry is charged only when it gets physical backing, so a zswap-capable memcg can keep swapping out through xswap even when its physical swap margin is ze
5/6
mm, swap: do not retake the cluster lock when uncharging an xswap slot
xswap_release_slot_backend() runs with ci->lock held. Its callers free the slots of a cluster they have locked. It called xswap_backend_uncharge() to give the swap charge back, and that takes the same
6/6
mm, swap: drop a refused xswap backend run directly
On a refused charge, xswap_backend_alloc() gave the physical run back with __xswap_backend_unlink(), which finds the run through the reverse mapping. That mapping is not installed yet at this point, s