Hello Joshua. On Mon, Aug 31, 2026 at 09:37:51AM -0700, Joshua Hahn wrote: > Before this series, each memcg had one stock shared by all its > page_counters (memory + memsw). Now that the memcg stock was folded > into the page_counter level, give memsw its own page_counter_stock > so that it can benefit from caching charges as well. > > Note that while the allocation is conditional on do_memsw_account(), > the freeing is not; the freer will only free non-NULL stocks. This > matters because do_memsw_account() could have changed in between the > allocation and the free. (Just a passerby comment, I have no remarks to the overhaul.) The change of do_memsw_account() is because of re-attaching the memory controller between v1 and v2 trees. That's not so common operation (but not ruled out), pre-condition for that is that there's only a single online memcg, namely the root memcg. So it needs treatment especially at memcg offlining (which is what drain_all_stock() (also) does). I don't know how expensive page_counter_drain_stock_async() is going to be [1] but the v1 parts here could could be guarded with !cgroup_on_dfl(memcg->css.cgroup). Regards, Michal [1] Now, I see in 5/7 that there's the counter->stock check which should be quick bailout on v2 (maybe quicker than the cgroup_on_dfl() I proposed above).