Message ID | 20220225003437.12620-2-richard.weiyang@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/memcg: some cleanup for mem_cgroup_iter() | expand |
On Fri, Feb 25, 2022 at 12:34:35AM +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> This looks better indeed. Acked-by: Johannes Weiner <hannes@cmpxchg.org>
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) {
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> --- mm/memcontrol.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)