]> Git Repo - linux.git/commitdiff
memcg: use a folio in get_mctgt_type_thp
authorMatthew Wilcox (Oracle) <[email protected]>
Thu, 11 Jan 2024 18:12:19 +0000 (18:12 +0000)
committerAndrew Morton <[email protected]>
Thu, 22 Feb 2024 00:00:03 +0000 (16:00 -0800)
Replace five calls to compound_head() with one.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Reviewed-by: Roman Gushchin <[email protected]>
Reviewed-by: Muchun Song <[email protected]>
Acked-by: Shakeel Butt <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/memcontrol.c

index a5bc34d44dbd50d0076a25b6876d21385a058dcf..db92401257f7d00c4b862016cd7f7e49986f1f0e 100644 (file)
@@ -6194,6 +6194,7 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma,
                unsigned long addr, pmd_t pmd, union mc_target *target)
 {
        struct page *page = NULL;
+       struct folio *folio;
        enum mc_target_type ret = MC_TARGET_NONE;
 
        if (unlikely(is_swap_pmd(pmd))) {
@@ -6203,17 +6204,18 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma,
        }
        page = pmd_page(pmd);
        VM_BUG_ON_PAGE(!page || !PageHead(page), page);
+       folio = page_folio(page);
        if (!(mc.flags & MOVE_ANON))
                return ret;
-       if (page_memcg(page) == mc.from) {
+       if (folio_memcg(folio) == mc.from) {
                ret = MC_TARGET_PAGE;
                if (target) {
-                       get_page(page);
-                       if (!trylock_page(page)) {
-                               put_page(page);
+                       folio_get(folio);
+                       if (!folio_trylock(folio)) {
+                               folio_put(folio);
                                return MC_TARGET_NONE;
                        }
-                       target->folio = page_folio(page);
+                       target->folio = folio;
                }
        }
        return ret;
This page took 0.060797 seconds and 4 git commands to generate.