linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/vmstat: add event for ksm swapping in copy
@ 2022-01-13  2:38 cgel.zte
  0 siblings, 0 replies; only message in thread
From: cgel.zte @ 2022-01-13  2:38 UTC (permalink / raw)
  To: akpm, yang.shi, ying.huang
  Cc: yang.yang29, dave.hansen, minchan, saravanand, linux-kernel,
	linux-mm, Ran Xiaokai

From: Yang Yang <yang.yang29@zte.com.cn>

When faults in from swap what used to be a KSM page and that page
had been swapped in before, system has to make a copy, and leaves
remerging the pages to a later pass of ksmd.

That is not good for performace, we'd better to reduce this kind
of copy. There are some ways to reduce it, for example lessen
swappiness or madvise(, , MADV_MERGEABLE) range. So add this
event to support doing this tuning. Just like this patch:
"mm, THP, swap: add THP swapping out fallback counting".

Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Reviewed-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
v2:
- fix compile error when CONFIG_SWAP is not set
---
 include/linux/vm_event_item.h | 3 +++
 mm/ksm.c                      | 3 +++
 mm/vmstat.c                   | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 7b2363388bfa..16a0a4fd000b 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -129,6 +129,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 #ifdef CONFIG_SWAP
 		SWAP_RA,
 		SWAP_RA_HIT,
+#ifdef CONFIG_KSM
+		KSM_SWPIN_COPY,
+#endif
 #endif
 #ifdef CONFIG_X86
 		DIRECT_MAP_LEVEL2_SPLIT,
diff --git a/mm/ksm.c b/mm/ksm.c
index c20bd4d9a0d9..4a7f8614e57d 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2595,6 +2595,9 @@ struct page *ksm_might_need_to_copy(struct page *page,
 		SetPageDirty(new_page);
 		__SetPageUptodate(new_page);
 		__SetPageLocked(new_page);
+#ifdef CONFIG_SWAP
+		count_vm_event(KSM_SWPIN_COPY);
+#endif
 	}
 
 	return new_page;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 4057372745d0..d2b9f27eb1c4 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1385,6 +1385,9 @@ const char * const vmstat_text[] = {
 #ifdef CONFIG_SWAP
 	"swap_ra",
 	"swap_ra_hit",
+#ifdef CONFIG_KSM
+	"ksm_swpin_copy",
+#endif
 #endif
 #ifdef CONFIG_X86
 	"direct_map_level2_splits",
-- 
2.25.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-13  2:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13  2:38 [PATCH v2] mm/vmstat: add event for ksm swapping in copy cgel.zte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox