On Wed, Mar 30, 2022 at 12:47:50AM +0000, Wei Yang wrote: > Something like this? > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index eed9916cdce5..5d433b79ba47 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1005,9 +1005,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) { > @@ -1033,6 +1030,8 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, > */ > (void)cmpxchg(&iter->position, pos, NULL); > } > + } else if (prev) { > + pos = prev; > } > > if (pos) Yep!