[PATCH 2/3] Refactor zone_reclaim

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Balbir Singh
Date: Tuesday, November 30, 2010 - 3:15 am

Refactor zone_reclaim, move reusable functionality outside
of zone_reclaim. Make zone_reclaim_unmapped_pages modular

Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
---
 mm/vmscan.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 325443a..0ac444f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2719,6 +2719,27 @@ static long zone_pagecache_reclaimable(struct zone *zone)
 }
 
 /*
+ * Helper function to reclaim unmapped pages, we might add something
+ * similar to this for slab cache as well. Currently this function
+ * is shared with __zone_reclaim()
+ */
+static inline void
+zone_reclaim_unmapped_pages(struct zone *zone, struct scan_control *sc,
+				unsigned long nr_pages)
+{
+	int priority;
+	/*
+	 * Free memory by calling shrink zone with increasing
+	 * priorities until we have enough memory freed.
+	 */
+	priority = ZONE_RECLAIM_PRIORITY;
+	do {
+		shrink_zone(priority, zone, sc);
+		priority--;
+	} while (priority >= 0 && sc->nr_reclaimed < nr_pages);
+}
+
+/*
  * Try to free up some pages from this zone through reclaim.
  */
 static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
@@ -2727,7 +2748,6 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
 	const unsigned long nr_pages = 1 << order;
 	struct task_struct *p = current;
 	struct reclaim_state reclaim_state;
-	int priority;
 	struct scan_control sc = {
 		.may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
 		.may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
@@ -2751,17 +2771,8 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
 	reclaim_state.reclaimed_slab = 0;
 	p->reclaim_state = &reclaim_state;
 
-	if (zone_pagecache_reclaimable(zone) > zone->min_unmapped_pages) {
-		/*
-		 * Free memory by calling shrink zone with increasing
-		 * priorities until we have enough memory freed.
-		 */
-		priority = ZONE_RECLAIM_PRIORITY;
-		do {
-			shrink_zone(priority, zone, &sc);
-			priority--;
-		} while (priority >= 0 && sc.nr_reclaimed < nr_pages);
-	}
+	if (zone_pagecache_reclaimable(zone) > zone->min_unmapped_pages)
+		zone_reclaim_unmapped_pages(zone, &sc, nr_pages);
 
 	nr_slab_pages0 = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
 	if (nr_slab_pages0 > zone->min_slab_pages) {

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] Series short description, Balbir Singh, (Tue Nov 30, 3:14 am)
[PATCH 1/3] Move zone_reclaim() outside of CONFIG_NUMA, Balbir Singh, (Tue Nov 30, 3:15 am)
[PATCH 2/3] Refactor zone_reclaim, Balbir Singh, (Tue Nov 30, 3:15 am)
[PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Tue Nov 30, 3:16 am)
Re: [PATCH 1/3] Move zone_reclaim() outside of CONFIG_NUMA, Christoph Lameter, (Tue Nov 30, 12:18 pm)
Re: [PATCH 2/3] Refactor zone_reclaim, Christoph Lameter, (Tue Nov 30, 12:19 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Christoph Lameter, (Tue Nov 30, 12:21 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Andrew Morton, (Tue Nov 30, 3:25 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, KOSAKI Motohiro, (Tue Nov 30, 5:14 pm)
Re: [PATCH 2/3] Refactor zone_reclaim, KAMEZAWA Hiroyuki, (Tue Nov 30, 6:23 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, KAMEZAWA Hiroyuki, (Tue Nov 30, 6:32 pm)
Re: [PATCH 2/3] Refactor zone_reclaim, Balbir Singh, (Tue Nov 30, 10:22 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Tue Nov 30, 10:22 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Tue Nov 30, 10:22 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Tue Nov 30, 10:22 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, KAMEZAWA Hiroyuki, (Tue Nov 30, 10:35 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Tue Nov 30, 11:40 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, KAMEZAWA Hiroyuki, (Wed Dec 1, 12:24 am)
Re: [PATCH 2/3] Refactor zone_reclaim, Minchan Kim, (Wed Dec 1, 12:54 am)
Re: [PATCH 3/3] Provide control over unmapped pages, Minchan Kim, (Wed Dec 1, 1:18 am)
Re: [PATCH 2/3] Refactor zone_reclaim, KAMEZAWA Hiroyuki, (Wed Dec 1, 1:59 am)
Re: [PATCH 3/3] Provide control over unmapped pages, Christoph Lameter, (Wed Dec 1, 8:01 am)
Re: [PATCH 3/3] Provide control over unmapped pages, KOSAKI Motohiro, (Wed Dec 1, 6:22 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, KAMEZAWA Hiroyuki, (Wed Dec 1, 7:50 pm)
Re: [PATCH 3/3] Provide control over unmapped pages, Balbir Singh, (Thu Dec 2, 12:01 am)