linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/2] mm/page_io: count submission time as thrashing delay for delayacct
@ 2022-08-15  7:28 cgel.zte
  2022-09-14 14:49 ` Joonsoo Kim
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-08-15  7:28 UTC (permalink / raw)
  To: akpm, iamjoonsoo.kim
  Cc: linux-mm, linux-kernel, Yang Yang, CGEL ZTE, Ran Xiaokai, wangyong

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

Once upon a time, we only support accounting thrashing of page cache.
Then Joonsoo introduced workingset detection for anonymous pages and
we gained the ability to account thrashing of them[1].

Likes PSI, we count submission time as thrashing delay because when
the device is congested, or the submitting cgroup IO-throttled,
submission can be a significant part of overall IO time.

This patch is based on "delayacct: support re-entrance detection of
thrashing accounting".

[1] commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU")

Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Signed-off-by: CGEL ZTE <cgel.zte@gmail.com>
Reviewed-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
Reviewed-by: wangyong <wang.yong12@zte.com.cn>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
Change for v2:
 - use bool in_thrashing instead of unsigned long dflags
---
 mm/page_io.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 68318134dc92..653a2adcfdd9 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -453,18 +453,21 @@ int swap_readpage(struct page *page, bool synchronous,
 	struct swap_info_struct *sis = page_swap_info(page);
 	bool workingset = PageWorkingset(page);
 	unsigned long pflags;
+	bool in_thrashing;
 
 	VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page);
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
 	VM_BUG_ON_PAGE(PageUptodate(page), page);
 
 	/*
-	 * Count submission time as memory stall. When the device is congested,
-	 * or the submitting cgroup IO-throttled, submission can be a
-	 * significant part of overall IO time.
+	 * Count submission time as memory stall and delay. When the device
+	 * is congested, or the submitting cgroup IO-throttled, submission
+	 * can be a significant part of overall IO time.
 	 */
-	if (workingset)
+	if (workingset) {
+		delayacct_thrashing_start(&in_thrashing);
 		psi_memstall_enter(&pflags);
+	}
 	delayacct_swapin_start();
 
 	if (frontswap_load(page) == 0) {
@@ -513,8 +516,10 @@ int swap_readpage(struct page *page, bool synchronous,
 	bio_put(bio);
 
 out:
-	if (workingset)
+	if (workingset) {
+		delayacct_thrashing_end(&in_thrashing);
 		psi_memstall_leave(&pflags);
+	}
 	delayacct_swapin_end();
 	return ret;
 }
-- 
2.25.1



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

* Re: [PATCH v2 2/2] mm/page_io: count submission time as thrashing delay for delayacct
  2022-08-15  7:28 [PATCH v2 2/2] mm/page_io: count submission time as thrashing delay for delayacct cgel.zte
@ 2022-09-14 14:49 ` Joonsoo Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Joonsoo Kim @ 2022-09-14 14:49 UTC (permalink / raw)
  To: cgel.zte
  Cc: akpm, iamjoonsoo.kim, linux-mm, linux-kernel, Yang Yang,
	Ran Xiaokai, wangyong

2022년 8월 15일 (월) 오후 4:33, <cgel.zte@gmail.com>님이 작성:
>
> From: Yang Yang <yang.yang29@zte.com.cn>
>
> Once upon a time, we only support accounting thrashing of page cache.
> Then Joonsoo introduced workingset detection for anonymous pages and
> we gained the ability to account thrashing of them[1].
>
> Likes PSI, we count submission time as thrashing delay because when
> the device is congested, or the submitting cgroup IO-throttled,
> submission can be a significant part of overall IO time.

It's not the main purpose of this patch. Without this patch,
swap thrashing through frontswap or some block device supporting rw_page
operation isn't measured correctly. I think that description change is
required. Please refer to commit 937790699be9c8100e
(mm/page_io.c: annotate refault stalls from swap_readpage).

No objection on the code side.

Thanks.


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

end of thread, other threads:[~2022-09-14 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15  7:28 [PATCH v2 2/2] mm/page_io: count submission time as thrashing delay for delayacct cgel.zte
2022-09-14 14:49 ` Joonsoo Kim

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