[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240130091755.21363-1-gehao@kylinos.cn>
Date: Tue, 30 Jan 2024 17:17:55 +0800
From: Hao Ge <gehao@...inos.cn>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Hao Ge <gehao@...inos.cn>
Subject: [PATCH] mm/vmscan: Change the calculation of the number of can reclaim anon pages in zone_reclaimable_pages
The spaces of swap devices that can be set by the user
are unpredictable values, so we take the minimum value between
the anonymous page in the specified zone and the spaces of swap devices.
Signed-off-by: Hao Ge <gehao@...inos.cn>
---
mm/vmscan.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4f9c854ce6cc..2deae4232b83 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -341,14 +341,21 @@ static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg,
unsigned long zone_reclaimable_pages(struct zone *zone)
{
unsigned long nr;
-
+ unsigned long can_reclaim_anon = 0;
nr = zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_FILE) +
zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_FILE);
- if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL))
- nr += zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) +
+ if (can_reclaim_anon_pages(NULL, zone_to_nid(zone), NULL)) {
+ can_reclaim_anon = zone_page_state_snapshot(zone, NR_ZONE_INACTIVE_ANON) +
zone_page_state_snapshot(zone, NR_ZONE_ACTIVE_ANON);
-
- return nr;
+ /*
+ * The spaces of swap devices that can be set by the user are unpredictable values,
+ * so we take the minimum value between the anonymous page in the specified zone and
+ * the spaces of swap devices
+ */
+ if (!can_demote(zone_to_nid(zone), NULL))
+ can_reclaim_anon = min_t(unsigned long, can_reclaim_anon, get_nr_swap_pages());
+ }
+ return nr + can_reclaim_anon;
}
/**
--
2.25.1
Powered by blists - more mailing lists