filemap: make the accounting of thrashing more consistent

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 aae466b005 ("mm/swap: implement workingset detection for anonymous LRU")

Link: https://lkml.kernel.org/r/20220805033838.1714674-1-yang.yang29@zte.com.cn
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>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Yang Yang <yang.yang29@zte.com.cn>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Yang Yang 2022-08-05 03:38:39 +00:00 committed by Andrew Morton
parent 5154e60796
commit f347c9d269
2 changed files with 5 additions and 15 deletions

View File

@ -13,7 +13,7 @@ a) waiting for a CPU (while being runnable)
b) completion of synchronous block I/O initiated by the task b) completion of synchronous block I/O initiated by the task
c) swapping in pages c) swapping in pages
d) memory reclaim d) memory reclaim
e) thrashing page cache e) thrashing
f) direct compact f) direct compact
g) write-protect copy g) write-protect copy

View File

@ -1221,15 +1221,11 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
struct wait_page_queue wait_page; struct wait_page_queue wait_page;
wait_queue_entry_t *wait = &wait_page.wait; wait_queue_entry_t *wait = &wait_page.wait;
bool thrashing = false; bool thrashing = false;
bool delayacct = false;
unsigned long pflags; unsigned long pflags;
if (bit_nr == PG_locked && if (bit_nr == PG_locked &&
!folio_test_uptodate(folio) && folio_test_workingset(folio)) { !folio_test_uptodate(folio) && folio_test_workingset(folio)) {
if (!folio_test_swapbacked(folio)) {
delayacct_thrashing_start(); delayacct_thrashing_start();
delayacct = true;
}
psi_memstall_enter(&pflags); psi_memstall_enter(&pflags);
thrashing = true; thrashing = true;
} }
@ -1329,7 +1325,6 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
finish_wait(q, wait); finish_wait(q, wait);
if (thrashing) { if (thrashing) {
if (delayacct)
delayacct_thrashing_end(); delayacct_thrashing_end();
psi_memstall_leave(&pflags); 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; struct wait_page_queue wait_page;
wait_queue_entry_t *wait = &wait_page.wait; wait_queue_entry_t *wait = &wait_page.wait;
bool thrashing = false; bool thrashing = false;
bool delayacct = false;
unsigned long pflags; unsigned long pflags;
wait_queue_head_t *q; wait_queue_head_t *q;
struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); struct folio *folio = page_folio(pfn_swap_entry_to_page(entry));
q = folio_waitqueue(folio); q = folio_waitqueue(folio);
if (!folio_test_uptodate(folio) && folio_test_workingset(folio)) { if (!folio_test_uptodate(folio) && folio_test_workingset(folio)) {
if (!folio_test_swapbacked(folio)) {
delayacct_thrashing_start(); delayacct_thrashing_start();
delayacct = true;
}
psi_memstall_enter(&pflags); psi_memstall_enter(&pflags);
thrashing = true; thrashing = true;
} }
@ -1435,7 +1426,6 @@ void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep,
finish_wait(q, wait); finish_wait(q, wait);
if (thrashing) { if (thrashing) {
if (delayacct)
delayacct_thrashing_end(); delayacct_thrashing_end();
psi_memstall_leave(&pflags); psi_memstall_leave(&pflags);
} }