linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Zhaoyang Huang <huangzhaoyang@gmail.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>, <ke.wang@unisoc.com>
Subject: [RFC PATCH] mm: set cache_trim_mode when inactive ratio is undesired
Date: Thu, 21 Jul 2022 15:06:48 +0800	[thread overview]
Message-ID: <1658387208-20065-1-git-send-email-zhaoyang.huang@unisoc.com> (raw)

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

Undesirable inactive file ratio could be observed under some scenarios(such as
large number of mapped file access) and hardly recover during a certain period
of time, which could be a result of tight criteria judgement of cache_trim_mode,
which demand both of none-thrashing and inactive_is_low simutaneously and lead
to the mode as SCAN_FRAC or SCAN_EQUAL when scanning lru.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/vmscan.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index f7d9a68..8e84fe6 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2663,6 +2663,23 @@ static bool inactive_is_low(struct lruvec *lruvec, enum lru_list inactive_lru)
 	return inactive * inactive_ratio < active;
 }
 
+static bool inactive_is_high(struct lruvec *lruvec, enum lru_list inactive_lru)
+{
+	enum lru_list active_lru = inactive_lru + LRU_ACTIVE;
+	unsigned long inactive, active;
+	unsigned long active_ratio = 2;
+	unsigned long gb;
+
+	inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru);
+	active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru);
+
+	gb = (inactive + active) >> (30 - PAGE_SHIFT);
+	if (gb)
+		active_ratio = 1;
+
+	return inactive > active_ratio * active;
+}
+
 enum scan_balance {
 	SCAN_EQUAL,
 	SCAN_FRACT,
@@ -3198,7 +3215,8 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 	 * anonymous pages.
 	 */
 	file = lruvec_page_state(target_lruvec, NR_INACTIVE_FILE);
-	if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE))
+	if (file >> sc->priority && (!(sc->may_deactivate & DEACTIVATE_FILE)
+		|| inactive_is_high(target_lruvec, LRU_INACTIVE_FILE)))
 		sc->cache_trim_mode = 1;
 	else
 		sc->cache_trim_mode = 0;
-- 
1.9.1


             reply	other threads:[~2022-07-21  7:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  7:06 zhaoyang.huang [this message]
2022-07-21 14:20 ` [RFC PATCH] mm: set cache_trim_mode when inactive ratio is undesired Matthew Wilcox

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=1658387208-20065-1-git-send-email-zhaoyang.huang@unisoc.com \
    --to=zhaoyang.huang@unisoc.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=huangzhaoyang@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=ke.wang@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).