Skip to content

Commit 3a9bb7b

Browse files
yangyang20220519akpm00
authored andcommitted
mm/page_io: count submission time as thrashing delay for delayacct
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. Without this patch, swap thrashing through frontswap or some block device supporting rw_page operation isn't measured correctly. This patch is based on "delayacct: support re-entrance detection of thrashing accounting". [1] commit aae466b ("mm/swap: implement workingset detection for anonymous LRU") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yang Yang <[email protected]> Signed-off-by: CGEL ZTE <[email protected]> Reviewed-by: Ran Xiaokai <[email protected]> Reviewed-by: wangyong <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent aa1cf99 commit 3a9bb7b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mm/page_io.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,21 @@ int swap_readpage(struct page *page, bool synchronous,
452452
struct swap_info_struct *sis = page_swap_info(page);
453453
bool workingset = PageWorkingset(page);
454454
unsigned long pflags;
455+
bool in_thrashing;
455456

456457
VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page);
457458
VM_BUG_ON_PAGE(!PageLocked(page), page);
458459
VM_BUG_ON_PAGE(PageUptodate(page), page);
459460

460461
/*
461-
* Count submission time as memory stall. When the device is congested,
462-
* or the submitting cgroup IO-throttled, submission can be a
463-
* significant part of overall IO time.
462+
* Count submission time as memory stall and delay. When the device
463+
* is congested, or the submitting cgroup IO-throttled, submission
464+
* can be a significant part of overall IO time.
464465
*/
465-
if (workingset)
466+
if (workingset) {
467+
delayacct_thrashing_start(&in_thrashing);
466468
psi_memstall_enter(&pflags);
469+
}
467470
delayacct_swapin_start();
468471

469472
if (frontswap_load(page) == 0) {
@@ -512,8 +515,10 @@ int swap_readpage(struct page *page, bool synchronous,
512515
bio_put(bio);
513516

514517
out:
515-
if (workingset)
518+
if (workingset) {
519+
delayacct_thrashing_end(&in_thrashing);
516520
psi_memstall_leave(&pflags);
521+
}
517522
delayacct_swapin_end();
518523
return ret;
519524
}

0 commit comments

Comments
 (0)