linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] psi: Treat ksm swapping in copy as memstall
@ 2022-01-16 15:21 cgel.zte
  2022-01-17 12:14 ` Johannes Weiner
  0 siblings, 1 reply; 11+ messages in thread
From: cgel.zte @ 2022-01-16 15:21 UTC (permalink / raw)
  To: akpm, hannes, sfr; +Cc: linux-mm, linux-kernel, Yang Yang

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. Obviously
this kind of copy is related to high memory pressure, so we treat
it as memstall. Although ksm page merging is not because of high
memory pressure.

Information of this new kind of stall will help psi to account
memory pressure more precise.

Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
---
 mm/ksm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/ksm.c b/mm/ksm.c
index 4a7f8614e57d..d4ec6773f9b8 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -39,6 +39,7 @@
 #include <linux/freezer.h>
 #include <linux/oom.h>
 #include <linux/numa.h>
+#include <linux/psi.h>
 
 #include <asm/tlbflush.h>
 #include "internal.h"
@@ -2569,6 +2570,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
 {
 	struct anon_vma *anon_vma = page_anon_vma(page);
 	struct page *new_page;
+	unsigned long pflags;
 
 	if (PageKsm(page)) {
 		if (page_stable_node(page) &&
@@ -2583,6 +2585,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
 	if (!PageUptodate(page))
 		return page;		/* let do_swap_page report the error */
 
+	psi_memstall_enter(&pflags);
 	new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
 	if (new_page &&
 	    mem_cgroup_charge(page_folio(new_page), vma->vm_mm, GFP_KERNEL)) {
@@ -2600,6 +2603,7 @@ struct page *ksm_might_need_to_copy(struct page *page,
 #endif
 	}
 
+	psi_memstall_leave(&pflags);
 	return new_page;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-10  6:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16 15:21 [PATCH] psi: Treat ksm swapping in copy as memstall cgel.zte
2022-01-17 12:14 ` Johannes Weiner
2022-01-19  6:13   ` CGEL
2022-01-19 12:58     ` Johannes Weiner
2022-01-21  9:51       ` CGEL
2022-01-28  1:29         ` Johannes Weiner
2022-01-28  2:31           ` CGEL
2022-02-08  3:22             ` Hugh Dickins
2022-02-08 13:09               ` CGEL
2022-02-09  5:55                 ` Hugh Dickins
2022-02-10  6:52                   ` CGEL

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).