linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: cgel.zte@gmail.com
To: akpm@linux-foundation.org, yang.shi@linux.alibaba.com,
	ying.huang@intel.com
Cc: dave.hansen@linux.intel.com, yang.yang29@zte.com.cn,
	saravanand@fb.com, minchan@kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Ran Xiaokai <ran.xiaokai@zte.com.cn>
Subject: [PATCH] mm/vmstat: add event for ksm swapping in copy
Date: Wed, 12 Jan 2022 11:51:11 +0000	[thread overview]
Message-ID: <20220112115110.669160-1-yang.yang29@zte.com.cn> (raw)

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>
---
 include/linux/vm_event_item.h | 3 +++
 mm/ksm.c                      | 1 +
 mm/vmstat.c                   | 3 +++
 3 files changed, 7 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..b6b382fde3d4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2595,6 +2595,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
 		SetPageDirty(new_page);
 		__SetPageUptodate(new_page);
 		__SetPageLocked(new_page);
+		count_vm_event(KSM_SWPIN_COPY);
 	}
 
 	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



             reply	other threads:[~2022-01-12 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 11:51 cgel.zte [this message]
2022-01-12 15:58 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220112115110.669160-1-yang.yang29@zte.com.cn \
    --to=cgel.zte@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=saravanand@fb.com \
    --cc=yang.shi@linux.alibaba.com \
    --cc=yang.yang29@zte.com.cn \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox