]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/memcg: minor cleanup for mc_handle_present_pte()
authorMiaohe Lin <linmiaohe@huawei.com>
Mon, 17 Jul 2023 11:36:44 +0000 (19:36 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:37 +0000 (10:12 -0700)
When pagetable lock is held, the page will always be page_mapped().  So
remove unneeded page_mapped() check.  Also the page can't be freed from
under us in this case.  So use get_page() to get extra page reference to
simplify the code.  No functional change intended.

Link: https://lkml.kernel.org/r/20230717113644.3026478-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index 93e3cc581b51d28ea51554a4055ba30860a95d26..51772df1abc52252ece4ce73d646c5a32b5cb788 100644 (file)
@@ -5639,7 +5639,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
 {
        struct page *page = vm_normal_page(vma, addr, ptent);
 
-       if (!page || !page_mapped(page))
+       if (!page)
                return NULL;
        if (PageAnon(page)) {
                if (!(mc.flags & MOVE_ANON))
@@ -5648,8 +5648,7 @@ static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
                if (!(mc.flags & MOVE_FILE))
                        return NULL;
        }
-       if (!get_page_unless_zero(page))
-               return NULL;
+       get_page(page);
 
        return page;
 }