[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230925035907.1723-1-justinjiang@vivo.com>
Date: Mon, 25 Sep 2023 11:59:07 +0800
From: Zhiguo Jiang <justinjiang@...o.com>
To: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com, Zhiguo Jiang <justinjiang@...o.com>
Subject: [PATCH] mm: vmscan: fix kswapd nr_to_reclaim repeated calculation
In kswapd recycling shrink, high watermark is fixed, meaning the
nr_to_reclaim value is fixed, so there is no need to repeatedly
calculate the nr_to_reclaim value during each iteraton.
Signed-off-by: Zhiguo Jiang <justinjiang@...o.com>
---
mm/vmscan.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
mode change 100644 => 100755 mm/vmscan.c
diff --git a/mm/vmscan.c b/mm/vmscan.c
index a4e44f1c97c1..1aab3549969e
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -6638,7 +6638,9 @@ static bool kswapd_shrink_node(pg_data_t *pgdat,
int z;
/* Reclaim a number of pages proportional to the number of zones */
- sc->nr_to_reclaim = 0;
+ if (sc->nr_to_reclaim > 0)
+ goto shrink;
+
for (z = 0; z <= sc->reclaim_idx; z++) {
zone = pgdat->node_zones + z;
if (!managed_zone(zone))
@@ -6647,6 +6649,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat,
sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX);
}
+shrink:
/*
* Historically care was taken to put equal pressure on all zones but
* now pressure is applied based on node LRU order.
@@ -6725,6 +6728,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx)
.gfp_mask = GFP_KERNEL,
.order = order,
.may_unmap = 1,
+ .nr_to_reclaim = 0,
};
set_task_reclaim_state(current, &sc.reclaim_state);
--
2.39.0
Powered by blists - more mailing lists