swap with cgroup
Notes on how cgroup mm triggers swap on a user-defined
This notes assume you have adequate knowledge on overall linux mm code.
There are several cgroup callbacks at
mm/memory.c. Those functions are called to check if cgroup can honor this page allocation.
Okay, now at
mm/memcontrol.c, the checking and swap code path:
page_counter_try_charge(): check if we hit
try_to_free_mem_cgroup_pages(): callback to
mm/vmscan.cto shrink the list (Bingo!)
Of course there are still tons of LRU related code at
mm/memcontrol.c that I don’t understand yet. But I think they are mostly hooks/helpers for vmscan.c. Be careful about shirnk node code now, it has many hooks for cgroup, and I hope you can understand why they are there by now. It’s super complex. Although I’ve implemented swap twice, there are still many tricks I don’t get yet.
Created: Dec 3, 2018
Last Updated: Dec 4, 2018