mm/page_io: convert count_swpout_vm_event() to take in a folio
authorZhangPeng <zhangpeng362@huawei.com>
Fri, 21 Jul 2023 03:44:50 +0000 (11:44 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:46 +0000 (10:12 -0700)
Convert count_swpout_vm_event() to take in a folio. We can remove five
implicit calls to compound_head() by taking in a folio.

Link: https://lkml.kernel.org/r/20230721034451.16412-10-zhangpeng362@huawei.com
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_io.c

index 886addf..8b3845f 100644 (file)
@@ -205,13 +205,13 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
        return 0;
 }
 
-static inline void count_swpout_vm_event(struct page *page)
+static inline void count_swpout_vm_event(struct folio *folio)
 {
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-       if (unlikely(PageTransHuge(page)))
+       if (unlikely(folio_test_pmd_mappable(folio)))
                count_vm_event(THP_SWPOUT);
 #endif
-       count_vm_events(PSWPOUT, thp_nr_pages(page));
+       count_vm_events(PSWPOUT, folio_nr_pages(folio));
 }
 
 #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
@@ -280,7 +280,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret)
                }
        } else {
                for (p = 0; p < sio->pages; p++)
-                       count_swpout_vm_event(sio->bvec[p].bv_page);
+                       count_swpout_vm_event(page_folio(sio->bvec[p].bv_page));
        }
 
        for (p = 0; p < sio->pages; p++)
@@ -339,7 +339,7 @@ static void swap_writepage_bdev_sync(struct page *page,
        __bio_add_page(&bio, page, thp_size(page), 0);
 
        bio_associate_blkg_from_page(&bio, page);
-       count_swpout_vm_event(page);
+       count_swpout_vm_event(folio);
 
        folio_start_writeback(folio);
        folio_unlock(folio);
@@ -362,7 +362,7 @@ static void swap_writepage_bdev_async(struct page *page,
        __bio_add_page(bio, page, thp_size(page), 0);
 
        bio_associate_blkg_from_page(bio, page);
-       count_swpout_vm_event(page);
+       count_swpout_vm_event(folio);
        folio_start_writeback(folio);
        folio_unlock(folio);
        submit_bio(bio);