All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd
@ 2022-09-14  2:33 Hongchen Zhang
  2022-09-14 22:51 ` Andrew Morton
  0 siblings, 1 reply; 17+ messages in thread
From: Hongchen Zhang @ 2022-09-14  2:33 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Hongchen Zhang

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


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

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

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  2:33 [PATCH] mm/vmscan: don't scan adjust too much if current is not kswapd Hongchen Zhang
2022-09-14 22:51 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.