linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhiguo Jiang <justinjiang@vivo.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Matthew Wilcox <willy@infradead.org>,
	opensource.kernel@vivo.com, Zhiguo Jiang <justinjiang@vivo.com>
Subject: [PATCH] mm:vmscan: fix shrink sc->nr.immediate counter issue
Date: Thu, 30 Nov 2023 10:45:28 +0800	[thread overview]
Message-ID: <20231130024528.2178-1-justinjiang@vivo.com> (raw)

It can't be guaranteed for the PGDAT_WRITEBACK flag that there is only
one type of page marked for immediate reclaim on evictable LRUs in the
following shrink processes of the same kswapd shrink recycling. So for
the siuation that if there are only a small number of pages or even only
one page marked for immediate reclaim on evictable LRUs, and at the same
time there are a large number of pages unmarked for immediate reclaim on
evictable LRUs, kswapd is also throttled, which will increase kswapd
shrink consumption.

It can be fixed to throttle kswapd shrink when sc->nr.immediate is equal
to sc->nr.file_taken. And when there are both pages marked and unmarked
for immediate reclaim on evictable LRUs at the same time, kswapd will be
not throttled, and kswapd will first reclaim pages unmarked for immediate
reclaim on evictable LRUs quickly.

Signed-off-by: Zhiguo Jiang <justinjiang@vivo.com>
---
 mm/vmscan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 mm/vmscan.c

diff --git a/mm/vmscan.c b/mm/vmscan.c
index d8c3338fee0f..af2b6906171a
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5919,13 +5919,13 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 			set_bit(PGDAT_DIRTY, &pgdat->flags);
 
 		/*
-		 * If kswapd scans pages marked for immediate
+		 * If kswapd scans massive pages marked for immediate
 		 * reclaim and under writeback (nr_immediate), it
 		 * implies that pages are cycling through the LRU
 		 * faster than they are written so forcibly stall
 		 * until some pages complete writeback.
 		 */
-		if (sc->nr.immediate)
+		if (sc->nr.immediate && sc->nr.immediate == sc->nr.file_taken)
 			reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK);
 	}
 
-- 
2.39.0



                 reply	other threads:[~2023-11-30  2:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130024528.2178-1-justinjiang@vivo.com \
    --to=justinjiang@vivo.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=opensource.kernel@vivo.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox