[PATCH] mm: vmscan: fix the kcompactd order wakeuped by kswapd

From: Zhiguo Jiang
Date: Fri Sep 22 2023 - 00:15:19 EST


When kswapd enters sleep, the situation of reclaim_order <
alloc_order < pgdat->kswapd_order is possible, so the kcompactd
order wakeuped by kswapd should take the max value of reclaim_order,
alloc_order and pgdat->kswapd_order.

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

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 48c092cc6088..95883bbe2d29
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -6955,6 +6955,7 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
* succeed.
*/
if (prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx)) {
+ int kcompactd_order;
/*
* Compaction records what page blocks it recently failed to
* isolate pages from and skips them in the future scanning.
@@ -6967,7 +6968,8 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o
* We have freed the memory, now we should compact it to make
* allocation of the requested order possible.
*/
- wakeup_kcompactd(pgdat, alloc_order, highest_zoneidx);
+ kcompactd_order = max(alloc_order, pgdat->kswapd_order);
+ wakeup_kcompactd(pgdat, kcompactd_order, highest_zoneidx);

remaining = schedule_timeout(HZ/10);

--
2.39.0