The patch titled Subject: mm/memcg: move generation assignment and comparison together has been added to the -mm tree. Its filename is mm-memcg-move-generation-assignment-and-comparison-together.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-move-generation-assignment-and-comparison-together.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-move-generation-assignment-and-comparison-together.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: Wei Yang <richard.weiyang@xxxxxxxxx> Subject: mm/memcg: move generation assignment and comparison together For each round-trip, we assign generation on first invocation and compare it on subsequent invocations. Let's move them together to make it more self-explaining. Also this reduces a check on prev. Link: https://lkml.kernel.org/r/20220225003437.12620-4-richard.weiyang@xxxxxxxxx Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Roman Gushchin <roman.gushchin@xxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/mm/memcontrol.c~mm-memcg-move-generation-assignment-and-comparison-together +++ a/mm/memcontrol.c @@ -1045,7 +1045,14 @@ struct mem_cgroup *mem_cgroup_iter(struc mz = root->nodeinfo[reclaim->pgdat->node_id]; iter = &mz->iter; - if (prev && reclaim->generation != iter->generation) + /* + * On first invocation, assign iter->generation to + * reclaim->generation. + * On subsequent invocations, make sure no one else jump in. + */ + if (!prev) + reclaim->generation = iter->generation; + else if (reclaim->generation != iter->generation) goto out_unlock; while (1) { @@ -1105,8 +1112,6 @@ struct mem_cgroup *mem_cgroup_iter(struc if (!memcg) iter->generation++; - else if (!prev) - reclaim->generation = iter->generation; } out_unlock: _ Patches currently in -mm which might be from richard.weiyang@xxxxxxxxx are mm-memcg-mem_cgroup_per_node-is-already-set-to-0-on-allocation.patch mm-memcg-retrieve-parent-memcg-from-cssparent.patch mm-memcg-set-memcg-after-css-verified-and-got-reference.patch mm-memcg-set-pos-to-prev-unconditionally.patch mm-memcg-move-generation-assignment-and-comparison-together.patch mm-page_alloc-add-same-penalty-is-enough-to-get-round-robin-order.patch mm-page_alloc-add-penalty-to-local_node.patch memcg-do-not-tweak-node-in-alloc_mem_cgroup_per_node_info.patch