linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hongchen Zhang <zhanghongchen@loongson.cn>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Hongchen Zhang <zhanghongchen@loongson.cn>
Subject: [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd
Date: Wed, 14 Sep 2022 10:33:18 +0800	[thread overview]
Message-ID: <20220914023318.549118-1-zhanghongchen@loongson.cn> (raw)

when a process falls into page fault and there is not enough free
memory,it will do direct reclaim. At the same time,it is holding
mmap_lock.So in case of multi-thread,it should exit from page fault
ASAP.
When reclaim memory,we do scan adjust between anon and file lru which
may cost too much time and trigger hung task for other thread.So for a
process which is not kswapd,it should just do a little scan adjust.

Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
---
 mm/vmscan.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index b2b1431352dc..07fb58db812b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3042,11 +3042,17 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
 		nr[lru] = targets[lru] * (100 - percentage) / 100;
 		nr[lru] -= min(nr[lru], nr_scanned);
 
+		if (!current_is_kswapd())
+			nr[lru] = min(nr[lru], nr_to_reclaim);
+
 		lru += LRU_ACTIVE;
 		nr_scanned = targets[lru] - nr[lru];
 		nr[lru] = targets[lru] * (100 - percentage) / 100;
 		nr[lru] -= min(nr[lru], nr_scanned);
 
+		if (!current_is_kswapd())
+			nr[lru] = min(nr[lru], nr_to_reclaim);
+
 		scan_adjusted = true;
 	}
 	blk_finish_plug(&plug);
-- 
2.34.1



             reply	other threads:[~2022-09-14  2:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  2:33 Hongchen Zhang [this message]
2022-09-14 22:51 ` [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd Andrew Morton
2022-09-14 23:02   ` Matthew Wilcox
2022-09-15  1:19   ` Hongchen Zhang
2022-09-15  7:28     ` Matthew Wilcox
2022-09-15  8:02       ` Hongchen Zhang
2022-09-15  9:00         ` Matthew Wilcox
2022-09-15  9:30           ` Hongchen Zhang
2022-09-16  0:57           ` Hongchen Zhang
2022-09-16  8:40             ` Matthew Wilcox
2022-09-16 10:19               ` Hongchen Zhang
2022-09-19 23:32                 ` Yosry Ahmed
2022-09-20  5:53                   ` Hongchen Zhang
2022-09-20  2:23                 ` Hongchen Zhang
2022-09-21  9:13                   ` Mel Gorman
2022-09-21 10:14                     ` Hongchen Zhang
2022-09-15 13:38         ` Feng Tang

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=20220914023318.549118-1-zhanghongchen@loongson.cn \
    --to=zhanghongchen@loongson.cn \
    --cc=akpm@linux-foundation.org \
    --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).