]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: add per-order mTHP swpin counters
authorBarry Song <v-songbaohua@oppo.com>
Sat, 26 Oct 2024 08:24:23 +0000 (21:24 +1300)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:29 +0000 (21:29 -0700)
This helps profile the sizes of folios being swapped in. Currently,
only mTHP swap-out is being counted.
The new interface can be found at:
/sys/kernel/mm/transparent_hugepage/hugepages-<size>/stats
         swpin
For example,
cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin
12809
cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin
4763

Link: https://lkml.kernel.org/r/20241026082423.26298-1-21cnbao@gmail.com
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Yosry Ahmed <yosryahmed@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Kairui Song <kasong@tencent.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/admin-guide/mm/transhuge.rst
include/linux/huge_mm.h
mm/huge_memory.c
mm/page_io.c

index 2a171ed5206e749959a09c42e95f3135d3ebc5c1..203ba7aaf5fc05100b5dd7855d4e61128e66e226 100644 (file)
@@ -533,6 +533,9 @@ anon_fault_fallback_charge
 zswpout
        is incremented every time a huge page is swapped out to zswap in one
        piece without splitting.
+swpin
+       is incremented every time a huge page is swapped in from a non-zswap
+       swap device in one piece.
 
 swpout
        is incremented every time a huge page is swapped out to a non-zswap
index c59e5aa9b081fe3b6cf5da3b17cf1fa3cfbe905f..b94c2e8ee91885de2586dcf44952ad53756fd3ee 100644 (file)
@@ -120,6 +120,7 @@ enum mthp_stat_item {
        MTHP_STAT_ANON_FAULT_FALLBACK,
        MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE,
        MTHP_STAT_ZSWPOUT,
+       MTHP_STAT_SWPIN,
        MTHP_STAT_SWPOUT,
        MTHP_STAT_SWPOUT_FALLBACK,
        MTHP_STAT_SHMEM_ALLOC,
index b26c6503e993495db632c09c196f897685c004ae..f92068864469270dec0196a8d6018c817a5671fd 100644 (file)
@@ -616,6 +616,7 @@ DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC);
 DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK);
 DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE);
 DEFINE_MTHP_STAT_ATTR(zswpout, MTHP_STAT_ZSWPOUT);
+DEFINE_MTHP_STAT_ATTR(swpin, MTHP_STAT_SWPIN);
 DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT);
 DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK);
 #ifdef CONFIG_SHMEM
@@ -635,6 +636,7 @@ static struct attribute *anon_stats_attrs[] = {
        &anon_fault_fallback_charge_attr.attr,
 #ifndef CONFIG_SHMEM
        &zswpout_attr.attr,
+       &swpin_attr.attr,
        &swpout_attr.attr,
        &swpout_fallback_attr.attr,
 #endif
@@ -666,6 +668,7 @@ static struct attribute_group file_stats_attr_grp = {
 static struct attribute *any_stats_attrs[] = {
 #ifdef CONFIG_SHMEM
        &zswpout_attr.attr,
+       &swpin_attr.attr,
        &swpout_attr.attr,
        &swpout_fallback_attr.attr,
 #endif
index c69fab5060a1d13c5a8e2d624731e231abe267b5..5d9b6e6cf96c858eb79fdd15544d3c66e866e889 100644 (file)
@@ -487,6 +487,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
                for (p = 0; p < sio->pages; p++) {
                        struct folio *folio = page_folio(sio->bvec[p].bv_page);
 
+                       count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN);
                        count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
                        folio_mark_uptodate(folio);
                        folio_unlock(folio);
@@ -573,6 +574,7 @@ static void swap_read_folio_bdev_sync(struct folio *folio,
         * attempt to access it in the page fault retry time check.
         */
        get_task_struct(current);
+       count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN);
        count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
        count_vm_events(PSWPIN, folio_nr_pages(folio));
        submit_bio_wait(&bio);
@@ -589,6 +591,7 @@ static void swap_read_folio_bdev_async(struct folio *folio,
        bio->bi_iter.bi_sector = swap_folio_sector(folio);
        bio->bi_end_io = end_swap_bio_read;
        bio_add_folio_nofail(bio, folio, folio_size(folio), 0);
+       count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN);
        count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
        count_vm_events(PSWPIN, folio_nr_pages(folio));
        submit_bio(bio);