
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

Fixed up merge problem with Nick's large order freeing patch.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/page_alloc.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 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-11-12 16:52:02.000000000 -0800
+++ memhotplug-dave/mm/page_alloc.c	2004-11-12 16:52:02.000000000 -0800
@@ -348,6 +348,17 @@ free_pages_bulk(struct zone *zone, int c
 	return ret;
 }
 
+static inline void extract_pages(struct page *page, struct zone *zone,
+		unsigned int current_order, unsigned int order,
+		struct free_area *area)
+{
+	list_del(&page->lru);
+	/* this is guarded by zone->lock */
+	rmv_page_order(page);
+	zone->free_pages -= 1UL << order;
+	area->nr_free--;
+}
+
 void __free_pages_ok(struct page *page, unsigned int order)
 {
 	LIST_HEAD(list);
@@ -460,10 +471,7 @@ static struct page *__rmqueue(struct zon
 			continue;
 
 		page = list_entry(area->free_list.next, struct page, lru);
-		list_del(&page->lru);
-		rmv_page_order(page);
-		area->nr_free--;
-		zone->free_pages -= 1UL << order;
+		extract_pages(page, zone, current_order, order, area);
 		return expand(zone, page, order, current_order, area);
 	}
 
_
