diff options
author | Wei Yang <richard.weiyang@gmail.com> | 2022-04-28 23:15:59 -0700 |
---|---|---|
committer | akpm <akpm@linux-foundation.org> | 2022-04-28 23:15:59 -0700 |
commit | a9320aae68a1cd3f41b9846e24504b09ffc3311e (patch) | |
tree | edde95609f76f436d12ab4e23b469789e83bb39f /mm | |
parent | 89d8330ccf2ad4c0744e1d1b77ffe2deb1641e54 (diff) | |
download | linux-rpi-a9320aae68a1cd3f41b9846e24504b09ffc3311e.tar.gz linux-rpi-a9320aae68a1cd3f41b9846e24504b09ffc3311e.tar.bz2 linux-rpi-a9320aae68a1cd3f41b9846e24504b09ffc3311e.zip |
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
reduce a check on prev.
[hannes@cmpxchg.org: better comment to explain reclaim model]
Link: https://lkml.kernel.org/r/20220330234719.18340-4-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1b76d5698900..1ae0a2afe476 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1021,7 +1021,13 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, mz = root->nodeinfo[reclaim->pgdat->node_id]; iter = &mz->iter; - if (prev && reclaim->generation != iter->generation) + /* + * On start, join the current reclaim iteration cycle. + * Exit when a concurrent walker completes it. + */ + if (!prev) + reclaim->generation = iter->generation; + else if (reclaim->generation != iter->generation) goto out_unlock; while (1) { @@ -1083,8 +1089,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, if (!memcg) iter->generation++; - else if (!prev) - reclaim->generation = iter->generation; } out_unlock: |