All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 2/3] mm/memcg: set pos explicitly for reclaim and !reclaim
Date: Wed, 30 Mar 2022 23:47:18 +0000	[thread overview]
Message-ID: <20220330234719.18340-3-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220330234719.18340-1-richard.weiyang@gmail.com>

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.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>

---
v2: split into two explicit part as suggested by Johannes
---
 mm/memcontrol.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

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)
-- 
2.33.1



WARNING: multiple messages have this Message-ID (diff)
From: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
	mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	Wei Yang
	<richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [Patch v2 2/3] mm/memcg: set pos explicitly for reclaim and !reclaim
Date: Wed, 30 Mar 2022 23:47:18 +0000	[thread overview]
Message-ID: <20220330234719.18340-3-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220330234719.18340-1-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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.

Signed-off-by: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
v2: split into two explicit part as suggested by Johannes
---
 mm/memcontrol.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

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)
-- 
2.33.1


  parent reply	other threads:[~2022-03-30 23:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 23:47 [Patch v2 0/3] mm/memcg: some cleanup for mem_cgroup_iter() Wei Yang
2022-03-30 23:47 ` Wei Yang
2022-03-30 23:47 ` [Patch v2 1/3] mm/memcg: set memcg after css verified and got reference Wei Yang
2022-03-30 23:47   ` Wei Yang
2022-03-31  0:20   ` Roman Gushchin
2022-03-31  0:20     ` Roman Gushchin
2022-03-30 23:47 ` Wei Yang [this message]
2022-03-30 23:47   ` [Patch v2 2/3] mm/memcg: set pos explicitly for reclaim and !reclaim Wei Yang
2022-03-31  0:21   ` Roman Gushchin
2022-03-31  0:21     ` Roman Gushchin
2022-03-31 15:03   ` Johannes Weiner
2022-03-31 15:03     ` Johannes Weiner
2022-03-30 23:47 ` [Patch v2 3/3] mm/memcg: move generation assignment and comparison together Wei Yang
2022-03-30 23:47   ` Wei Yang
2022-03-31  0:28   ` Roman Gushchin
2022-03-31  0:28     ` Roman Gushchin

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=20220330234719.18340-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.