Message ID | 20220330234719.18340-2-richard.weiyang@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/memcg: some cleanup for mem_cgroup_iter() | expand |
On Wed, Mar 30, 2022 at 11:47:17PM +0000, Wei Yang wrote: > 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@gmail.com> > Acked-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev> Nice cleanup! > --- > mm/memcontrol.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index dc193e83794d..eed9916cdce5 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1057,15 +1057,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 > >
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index dc193e83794d..eed9916cdce5 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1057,15 +1057,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) {