mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
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>
This commit is contained in:
parent
89d8330ccf
commit
a9320aae68
1 changed files with 7 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue