The patch titled Subject: mm: memcontrol: reparent nr_deferred when memcg offline has been added to the -mm tree. Its filename is mm-memcontrol-reparent-nr_deferred-when-memcg-offline.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcontrol-reparent-nr_deferred-when-memcg-offline.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcontrol-reparent-nr_deferred-when-memcg-offline.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yang Shi <shy828301@xxxxxxxxx> Subject: mm: memcontrol: reparent nr_deferred when memcg offline Now shrinker's nr_deferred is per memcg for memcg aware shrinkers, add to parent's corresponding nr_deferred when memcg offline. Link: https://lkml.kernel.org/r/20210311190845.9708-13-shy828301@xxxxxxxxx Signed-off-by: Yang Shi <shy828301@xxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Acked-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> Acked-by: Roman Gushchin <guro@xxxxxx> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Dave Chinner <david@xxxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/memcontrol.h | 1 + mm/memcontrol.c | 1 + mm/vmscan.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) --- a/include/linux/memcontrol.h~mm-memcontrol-reparent-nr_deferred-when-memcg-offline +++ a/include/linux/memcontrol.h @@ -1537,6 +1537,7 @@ static inline bool mem_cgroup_under_sock int alloc_shrinker_info(struct mem_cgroup *memcg); void free_shrinker_info(struct mem_cgroup *memcg); void set_shrinker_bit(struct mem_cgroup *memcg, int nid, int shrinker_id); +void reparent_shrinker_deferred(struct mem_cgroup *memcg); #else #define mem_cgroup_sockets_enabled 0 static inline void mem_cgroup_sk_alloc(struct sock *sk) { }; --- a/mm/memcontrol.c~mm-memcontrol-reparent-nr_deferred-when-memcg-offline +++ a/mm/memcontrol.c @@ -5167,6 +5167,7 @@ static void mem_cgroup_css_offline(struc page_counter_set_low(&memcg->memory, 0); memcg_offline_kmem(memcg); + reparent_shrinker_deferred(memcg); wb_memcg_offline(memcg); drain_all_stock(memcg); --- a/mm/vmscan.c~mm-memcontrol-reparent-nr_deferred-when-memcg-offline +++ a/mm/vmscan.c @@ -397,6 +397,30 @@ static long add_nr_deferred_memcg(long n return atomic_long_add_return(nr, &info->nr_deferred[shrinker->id]); } +void reparent_shrinker_deferred(struct mem_cgroup *memcg) +{ + int i, nid; + long nr; + struct mem_cgroup *parent; + struct shrinker_info *child_info, *parent_info; + + parent = parent_mem_cgroup(memcg); + if (!parent) + parent = root_mem_cgroup; + + /* Prevent from concurrent shrinker_info expand */ + down_read(&shrinker_rwsem); + for_each_node(nid) { + child_info = shrinker_info_protected(memcg, nid); + parent_info = shrinker_info_protected(parent, nid); + for (i = 0; i < shrinker_nr_max; i++) { + nr = atomic_long_read(&child_info->nr_deferred[i]); + atomic_long_add(nr, &parent_info->nr_deferred[i]); + } + } + up_read(&shrinker_rwsem); +} + static bool cgroup_reclaim(struct scan_control *sc) { return sc->target_mem_cgroup; _ Patches currently in -mm which might be from shy828301@xxxxxxxxx are mm-vmscan-use-nid-from-shrink_control-for-tracepoint.patch mm-vmscan-consolidate-shrinker_maps-handling-code.patch mm-vmscan-use-shrinker_rwsem-to-protect-shrinker_maps-allocation.patch mm-vmscan-remove-memcg_shrinker_map_size.patch mm-vmscan-use-kvfree_rcu-instead-of-call_rcu.patch mm-memcontrol-rename-shrinker_map-to-shrinker_info.patch mm-vmscan-add-shrinker_info_protected-helper.patch mm-vmscan-use-a-new-flag-to-indicate-shrinker-is-registered.patch mm-vmscan-add-per-memcg-shrinker-nr_deferred.patch mm-vmscan-use-per-memcg-nr_deferred-of-shrinker.patch mm-vmscan-dont-need-allocate-shrinker-nr_deferred-for-memcg-aware-shrinkers.patch mm-memcontrol-reparent-nr_deferred-when-memcg-offline.patch mm-vmscan-shrink-deferred-objects-proportional-to-priority.patch