From: Wei Yang <richard.weiyang@gmail.com>
To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com,
akpm@linux-foundation.org
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH 3/3] mm/memcg: move generation assignment and comparison together
Date: Fri, 25 Feb 2022 00:34:37 +0000 [thread overview]
Message-ID: <20220225003437.12620-4-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220225003437.12620-1-richard.weiyang@gmail.com>
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.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/memcontrol.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 03399146168f..17da93c2f94e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -996,7 +996,14 @@ 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 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) {
@@ -1056,8 +1063,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
if (!memcg)
iter->generation++;
- else if (!prev)
- reclaim->generation = iter->generation;
}
out_unlock:
--
2.33.1
next prev parent reply other threads:[~2022-02-25 0:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 0:34 [PATCH 0/3] mm/memcg: some cleanup for mem_cgroup_iter() Wei Yang
2022-02-25 0:34 ` [PATCH 1/3] mm/memcg: set memcg after css verified and got reference Wei Yang
2022-03-29 18:44 ` Johannes Weiner
2022-02-25 0:34 ` [PATCH 2/3] mm/memcg: set pos to prev unconditionally Wei Yang
2022-03-29 18:48 ` Johannes Weiner
2022-03-30 0:47 ` Wei Yang
2022-03-30 12:08 ` Johannes Weiner
2022-03-30 14:22 ` Wei Yang
2022-02-25 0:34 ` Wei Yang [this message]
2022-03-30 15:57 ` [PATCH 3/3] mm/memcg: move generation assignment and comparison together Johannes Weiner
2022-03-30 23:04 ` Wei Yang
2022-02-25 8:13 ` [PATCH 0/3] mm/memcg: some cleanup for mem_cgroup_iter() Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220225003437.12620-4-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox