mm: memcontrol: change ug->dummy_page only if memcg changed
authorMuchun Song <songmuchun@bytedance.com>
Fri, 30 Apr 2021 05:56:48 +0000 (22:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 30 Apr 2021 18:20:38 +0000 (11:20 -0700)
Just like assignment to ug->memcg, we only need to update ug->dummy_page
if memcg changed.  So move it to there.  This is a very small
optimization.

Link: https://lkml.kernel.org/r/20210319163821.20704-5-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index 0f77608e89ca40ded29cdb4f3dd9075828a9c198..85fd2d86d23f79e72e29fa7d5e5d854ced33f928 100644 (file)
@@ -6843,6 +6843,7 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug)
                        uncharge_gather_clear(ug);
                }
                ug->memcg = page_memcg(page);
+               ug->dummy_page = page;
 
                /* pairs with css_put in uncharge_batch */
                css_get(&ug->memcg->css);
@@ -6856,7 +6857,6 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug)
        else
                ug->pgpgout++;
 
-       ug->dummy_page = page;
        page->memcg_data = 0;
        css_put(&ug->memcg->css);
 }