summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Yang <richard.weiyang@gmail.com>2022-04-28 23:15:58 -0700
committerakpm <akpm@linux-foundation.org>2022-04-28 23:15:58 -0700
commit89d8330ccf2ad4c0744e1d1b77ffe2deb1641e54 (patch)
tree40823f5f2da18f6b43be84be16afcb88e7c7e843
parent41555dadbff8d2558d868110e47c24b747aad224 (diff)
mm/memcg: set pos explicitly for reclaim and !reclaim
During mem_cgroup_iter, there are two ways to get iteration position: reclaim vs non-reclaim mode. Let's do it explicitly for reclaim vs non-reclaim mode. Link: https://lkml.kernel.org/r/20220330234719.18340-3-richard.weiyang@gmail.com Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/memcontrol.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f06b5c249ecb..1b76d5698900 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1013,9 +1013,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
if (!root)
root = root_mem_cgroup;
- if (prev && !reclaim)
- pos = prev;
-
rcu_read_lock();
if (reclaim) {
@@ -1041,6 +1038,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
*/
(void)cmpxchg(&iter->position, pos, NULL);
}
+ } else if (prev) {
+ pos = prev;
}
if (pos)