linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] filemap: Make the accounting of thrashing more consistent
@ 2022-08-05  3:38 cgel.zte
  2022-09-14 14:36 ` Joonsoo Kim
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-08-05  3:38 UTC (permalink / raw)
  To: akpm, bsingharora
  Cc: corbet, willy, yang.yang29, david, linux-doc, linux-kernel,
	linux-fsdevel, linux-mm, CGEL ZTE

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].

So let delayacct account both the thrashing of page cache and anonymous
pages, this could make the codes more consistent and simpler.

[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>
---
 Documentation/accounting/delay-accounting.rst |  2 +-
 mm/filemap.c                                  | 18 ++++--------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/Documentation/accounting/delay-accounting.rst b/Documentation/accounting/delay-accounting.rst
index 241d1a87f2cd..7103b62ba6d7 100644
--- a/Documentation/accounting/delay-accounting.rst
+++ b/Documentation/accounting/delay-accounting.rst
@@ -13,7 +13,7 @@ a) waiting for a CPU (while being runnable)
 b) completion of synchronous block I/O initiated by the task
 c) swapping in pages
 d) memory reclaim
-e) thrashing page cache
+e) thrashing
 f) direct compact
 g) write-protect copy
 
diff --git a/mm/filemap.c b/mm/filemap.c
index 15800334147b..cfe15e89b3c2 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1221,15 +1221,11 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
 	struct wait_page_queue wait_page;
 	wait_queue_entry_t *wait = &wait_page.wait;
 	bool thrashing = false;
-	bool delayacct = false;
 	unsigned long pflags;
 
 	if (bit_nr == PG_locked &&
 	    !folio_test_uptodate(folio) && folio_test_workingset(folio)) {
-		if (!folio_test_swapbacked(folio)) {
-			delayacct_thrashing_start();
-			delayacct = true;
-		}
+		delayacct_thrashing_start();
 		psi_memstall_enter(&pflags);
 		thrashing = true;
 	}
@@ -1329,8 +1325,7 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
 	finish_wait(q, wait);
 
 	if (thrashing) {
-		if (delayacct)
-			delayacct_thrashing_end();
+		delayacct_thrashing_end();
 		psi_memstall_leave(&pflags);
 	}
 
@@ -1378,17 +1373,13 @@ void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep,
 	struct wait_page_queue wait_page;
 	wait_queue_entry_t *wait = &wait_page.wait;
 	bool thrashing = false;
-	bool delayacct = false;
 	unsigned long pflags;
 	wait_queue_head_t *q;
 	struct folio *folio = page_folio(pfn_swap_entry_to_page(entry));
 
 	q = folio_waitqueue(folio);
 	if (!folio_test_uptodate(folio) && folio_test_workingset(folio)) {
-		if (!folio_test_swapbacked(folio)) {
-			delayacct_thrashing_start();
-			delayacct = true;
-		}
+		delayacct_thrashing_start();
 		psi_memstall_enter(&pflags);
 		thrashing = true;
 	}
@@ -1435,8 +1426,7 @@ void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep,
 	finish_wait(q, wait);
 
 	if (thrashing) {
-		if (delayacct)
-			delayacct_thrashing_end();
+		delayacct_thrashing_end();
 		psi_memstall_leave(&pflags);
 	}
 }
-- 
2.25.1


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

* Re: [PATCH] filemap: Make the accounting of thrashing more consistent
  2022-08-05  3:38 [PATCH] filemap: Make the accounting of thrashing more consistent cgel.zte
@ 2022-09-14 14:36 ` Joonsoo Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Joonsoo Kim @ 2022-09-14 14:36 UTC (permalink / raw)
  To: cgel.zte
  Cc: akpm, bsingharora, corbet, willy, yang.yang29, david, linux-doc,
	linux-kernel, linux-fsdevel, linux-mm

2022년 8월 5일 (금) 오후 12:39, <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].
>
> So let delayacct account both the thrashing of page cache and anonymous
> pages, this could make the codes more consistent and simpler.
>
> [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>

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05  3:38 [PATCH] filemap: Make the accounting of thrashing more consistent cgel.zte
2022-09-14 14:36 ` Joonsoo Kim

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).