cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 1/3] mm/memcg: set memcg after css verified and got reference
Date: Fri, 25 Feb 2022 00:34:35 +0000	[thread overview]
Message-ID: <20220225003437.12620-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20220225003437.12620-1-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Instead of reset memcg when css is either not verified or not got
reference, we can set it after these process.

No functional change, just simplified the code a little.

Signed-off-by: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 mm/memcontrol.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 36e9f38c919d..9464fe2aa329 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1040,15 +1040,10 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
 		 * is provided by the caller, so we know it's alive
 		 * and kicking, and don't take an extra reference.
 		 */
-		memcg = mem_cgroup_from_css(css);
-
-		if (css == &root->css)
-			break;
-
-		if (css_tryget(css))
+		if (css == &root->css || css_tryget(css)) {
+			memcg = mem_cgroup_from_css(css);
 			break;
-
-		memcg = NULL;
+		}
 	}
 
 	if (reclaim) {
-- 
2.33.1


  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
     [not found] ` <20220225003437.12620-1-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-02-25  0:34   ` Wei Yang [this message]
     [not found]     ` <20220225003437.12620-2-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-29 18:44       ` [PATCH 1/3] mm/memcg: set memcg after css verified and got reference Johannes Weiner
2022-02-25  0:34   ` [PATCH 2/3] mm/memcg: set pos to prev unconditionally Wei Yang
     [not found]     ` <20220225003437.12620-3-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-29 18:48       ` Johannes Weiner
     [not found]         ` <YkNUZYrSHPjJ1XOb-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2022-03-30  0:47           ` Wei Yang
2022-03-30 12:08             ` Johannes Weiner
     [not found]               ` <YkRIUbEGHVIbVRNO-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2022-03-30 14:22                 ` Wei Yang
2022-02-25  0:34   ` [PATCH 3/3] mm/memcg: move generation assignment and comparison together Wei Yang
     [not found]     ` <20220225003437.12620-4-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-03-30 15:57       ` Johannes Weiner
     [not found]         ` <YkR902CHgavwleet-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
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-2-richard.weiyang@gmail.com \
    --to=richard.weiyang-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).