Skip to contentSkip to conversation

mm: add per-order mTHP swpin counters

PATCH Applied Barry Song 2 participants 4 messages Oct 30, 2024 – Oct 31, 2024

Subsystems (5)

v2 of 3 Applied 1/1 Latest is v3 →

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v2 1/1 mm: add per-order mTHP swpin counters

From: Barry Song <[email protected]>

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

Cc Chris Li <[email protected]>
Cc Yosry Ahmed <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Kairui Song <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Kanchana P Sridhar <[email protected]>
Cc Usama Arif <[email protected]>

---
-v2:
* collect Baolin's reviewed-by and David's acked-by, thanks!
* add some examples for the interface in the changelog, Per Huang, Ying. thanks!
* add a blank line in doc which was missed in v1.

 Documentation/admin-guide/mm/transhuge.rst | 4 ++++
 include/linux/huge_mm.h                    | 1 +
 mm/huge_memory.c                           | 3 +++
 mm/page_io.c                               | 3 +++
 4 files changed, 11 insertions(+)
Documentation/admin-guide/mm/transhuge.rst +4 -0
index 2a171ed5206e..5caa3fb2feb1 100644
@@ -534,6 +534,10 @@ 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
 	swap device in one piece without splitting.
include/linux/huge_mm.h +1 -0
index c59e5aa9b081..b94c2e8ee918 100644
@@ -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,
mm/huge_memory.c +3 -0
index b26c6503e993..f92068864469 100644
@@ -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
mm/page_io.c +3 -0
index c69fab5060a1..5d9b6e6cf96c 100644
@@ -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);
Signature · 1 line
2.39.3 (Apple Git-146)
#1 lore raw
Quoted 7 lines · Barry Song

From: Barry Song <[email protected]>

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

This looks strange, why isn't it

/sys/kernel/mm/transparent_hugepage/hugepages-<size>/stats/swpin

?

Quoted 5 lines

For example,
cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin 12809
cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin 4763

You miss "$"?

$ cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin
12809
$ cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin
4763
Quoted 99 lines
Cc Chris Li <[email protected]>
Cc Yosry Ahmed <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Kairui Song <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Kanchana P Sridhar <[email protected]>
Cc Usama Arif <[email protected]>

---
-v2:
* collect Baolin's reviewed-by and David's acked-by, thanks!
* add some examples for the interface in the changelog, Per Huang, Ying. thanks!
* add a blank line in doc which was missed in v1.

 Documentation/admin-guide/mm/transhuge.rst | 4 ++++
 include/linux/huge_mm.h                    | 1 +
 mm/huge_memory.c                           | 3 +++
 mm/page_io.c                               | 3 +++
 4 files changed, 11 insertions(+)
Documentation/admin-guide/mm/transhuge.rst +4 -0
index 2a171ed5206e..5caa3fb2feb1 100644
@@ -534,6 +534,10 @@ 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
 	swap device in one piece without splitting.
include/linux/huge_mm.h +1 -0
index c59e5aa9b081..b94c2e8ee918 100644
@@ -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,
mm/huge_memory.c +3 -0
index b26c6503e993..f92068864469 100644
@@ -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
mm/page_io.c +2 -0
index c69fab5060a1..5d9b6e6cf96c 100644
@@ -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);

mm/page_io.c static void swap_read_folio_bdev_async(struct folio *folio, · line 597

Quoted 7 lines
mm/page_io.c +1 -0
@@ -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);

--
Best Regards,
Huang, Ying

author
#2 lore raw
Quoted 11 lines · Ying
Quoted 7 lines · Barry Song

From: Barry Song <[email protected]>

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

Quoted 5 lines

This looks strange, why isn't it

/sys/kernel/mm/transparent_hugepage/hugepages-<size>/stats/swpin

?

I might be mistaken, but I want to highlight the path and new interface separately, as I’ve done in ec33687c67493 ("mm: add per-order mTHP anon_fault_alloc and anon_fault_fallback counters"):

If you prefer it on the same line, I’m completely fine with sending v3 to make the change.

Quoted 8 lines
Quoted 6 lines

For example,
cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin 12809
cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin 4763

You miss "$"?

Yes.

Quoted 116 lines
$ cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin
12809
$ cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin
4763
Quoted 99 lines
Cc Chris Li <[email protected]>
Cc Yosry Ahmed <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Kairui Song <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Kanchana P Sridhar <[email protected]>
Cc Usama Arif <[email protected]>

---
-v2:
* collect Baolin's reviewed-by and David's acked-by, thanks!
* add some examples for the interface in the changelog, Per Huang, Ying. thanks!
* add a blank line in doc which was missed in v1.

 Documentation/admin-guide/mm/transhuge.rst | 4 ++++
 include/linux/huge_mm.h                    | 1 +
 mm/huge_memory.c                           | 3 +++
 mm/page_io.c                               | 3 +++
 4 files changed, 11 insertions(+)
Documentation/admin-guide/mm/transhuge.rst +4 -0
index 2a171ed5206e..5caa3fb2feb1 100644
@@ -534,6 +534,10 @@ 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
      swap device in one piece without splitting.
include/linux/huge_mm.h +1 -0
index c59e5aa9b081..b94c2e8ee918 100644
@@ -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,
mm/huge_memory.c +3 -0
index b26c6503e993..f92068864469 100644
@@ -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
mm/page_io.c +2 -0
index c69fab5060a1..5d9b6e6cf96c 100644
@@ -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);

mm/page_io.c static void swap_read_folio_bdev_async(struct folio *folio, · line 597

Quoted 7 lines
mm/page_io.c +1 -0
@@ -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);

--
Best Regards,
Huang, Ying

#3 lore raw
Quoted 16 lines · Barry Song
Quoted 15 lines · Ying
Quoted 7 lines · Barry Song

From: Barry Song <[email protected]>

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

This looks strange, why isn't it

/sys/kernel/mm/transparent_hugepage/hugepages-<size>/stats/swpin

Quoted 8 lines
Quoted 1 line

?

I might be mistaken, but I want to highlight the path and new interface separately, as I’ve done in ec33687c67493 ("mm: add per-order mTHP anon_fault_alloc and anon_fault_fallback counters"):

If you prefer it on the same line, I’m completely fine with sending v3 to make the change.

I am fine to highlight the new interface. May be something like

In /sys/kernel/mm/transparent_hugepage/hugepages-<size>/stats, 'swpin' is added for ...

However, I have no strong opinion here. If everyone except me feels confusing, that should be fine.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

For example,
cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin 12809
cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin 4763

Quoted 117 lines
Quoted 1 line

You miss "$"?

Yes.

Quoted 113 lines
$ cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/swpin
12809
$ cat /sys/kernel/mm/transparent_hugepage/hugepages-32kB/stats/swpin
4763
Quoted 106 lines
Cc Chris Li <[email protected]>
Cc Yosry Ahmed <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Kairui Song <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Kanchana P Sridhar <[email protected]>
Cc Usama Arif <[email protected]>

---
-v2:
* collect Baolin's reviewed-by and David's acked-by, thanks!
* add some examples for the interface in the changelog, Per Huang, Ying. thanks!
* add a blank line in doc which was missed in v1.

 Documentation/admin-guide/mm/transhuge.rst | 4 ++++
 include/linux/huge_mm.h                    | 1 +
 mm/huge_memory.c                           | 3 +++
 mm/page_io.c                               | 3 +++
 4 files changed, 11 insertions(+)
Documentation/admin-guide/mm/transhuge.rst +4 -0
index 2a171ed5206e..5caa3fb2feb1 100644
@@ -534,6 +534,10 @@ 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
      swap device in one piece without splitting.
include/linux/huge_mm.h +1 -0
index c59e5aa9b081..b94c2e8ee918 100644
@@ -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,
mm/huge_memory.c +3 -0
index b26c6503e993..f92068864469 100644
@@ -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
mm/page_io.c +3 -0
index c69fab5060a1..5d9b6e6cf96c 100644
@@ -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);

--
Best Regards,
Huang, Ying