
From: Bradley Christiansen <bradc1@us.ibm.com>

This patch abstracts the actual act of marking pages used, in the
page allocator.  It needs to be broken out so that another function,
walking the free lists by physical address may also remove pages.

Uses extract_pages() in rmqueue().  An additional user will be in the
next patch
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/page_alloc.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff -puN mm/page_alloc.c~K0-removal-extract_pages mm/page_alloc.c
--- memhotplug/mm/page_alloc.c~K0-removal-extract_pages	2004-09-27 10:32:33.000000000 -0700
+++ memhotplug-dave/mm/page_alloc.c	2004-09-27 10:32:33.000000000 -0700
@@ -274,6 +274,23 @@ free_pages_bulk(struct zone *zone, int c
 	return ret;
 }
 
+#define MARK_USED(index, order, area) \
+	__change_bit((index) >> (1+(order)), (area)->map)
+
+static inline unsigned long extract_pages(struct page *page, struct zone *zone,
+		unsigned int current_order, unsigned int order,
+		struct free_area *area)
+{
+	unsigned long index;
+
+	list_del(&page->lru);
+	index = page_to_pfn(page) - zone->zone_start_pfn;
+	if (current_order != MAX_ORDER-1)
+		MARK_USED(index, current_order, area);
+	zone->free_pages -= 1UL << order;
+	return index;
+}
+
 void __free_pages_ok(struct page *page, unsigned int order)
 {
 	LIST_HEAD(list);
@@ -289,9 +306,6 @@ void __free_pages_ok(struct page *page, 
 	free_pages_bulk(page_zone(page), 1, &list, order);
 }
 
-#define MARK_USED(index, order, area) \
-	__change_bit((index) >> (1+(order)), (area)->map)
-
 /*
  * The order of subdivision here is critical for the IO subsystem.
  * Please do not alter this order without good reasons and regression
@@ -380,11 +394,7 @@ static struct page *__rmqueue(struct zon
 			continue;
 
 		page = list_entry(area->free_list.next, struct page, lru);
-		list_del(&page->lru);
-		index = page_to_lpfn(page) - zone->zone_start_pfn;
-		if (current_order != MAX_ORDER-1)
-			MARK_USED(index, current_order, area);
-		zone->free_pages -= 1UL << order;
+		index = extract_pages(page, zone, current_order, order, area);
 		return expand(zone, page, index, order, current_order, area);
 	}
 
_
