From: "Seth, Rohit" <rohit.seth@intel.com>

When a request is made to replenish the per_cpu_pages list, we start by
trying to allocate a order (== fls(pcp->batch) page allocation.  This
higher order allocation (if succeeds) gives a better chance for better
cache colring as compared to current random order 0 page allocations.

As a fall back for the cases when the highest requested order allocation is
not possible, we go lower down in order till the requested count of pages
is allocated OR we have reached the requested order in rmqueue_bulk.

Signed-off-by: Rohit Seth <rohit.seth@intel.com>
Cc: <linux-mm@kvack.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 mm/page_alloc.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff -puN mm/page_alloc.c~mm-try-to-allocate-higher-order-pages-in-rmqueue_bulk mm/page_alloc.c
--- devel/mm/page_alloc.c~mm-try-to-allocate-higher-order-pages-in-rmqueue_bulk	2005-09-12 00:19:55.000000000 -0700
+++ devel-akpm/mm/page_alloc.c	2005-09-12 00:21:07.000000000 -0700
@@ -506,14 +506,24 @@ static int rmqueue_bulk(struct zone *zon
 	int i;
 	int allocated = 0;
 	struct page *page;
+	unsigned long norder = fls(count);
 	
 	spin_lock_irqsave(&zone->lock, flags);
-	for (i = 0; i < count; ++i) {
-		page = __rmqueue(zone, order);
-		if (page == NULL)
-			break;
-		allocated++;
-		list_add_tail(&page->lru, list);
+
+	/*
+	 * We will try with a bigger contiguous chunk first. If that fails then
+	 * we will fall back to lower orders till we hit the requested order
+	 * OR get the required number of pages.
+ 	 */
+
+	while ((allocated < count) && (norder-- >= order)) {
+		page = __rmqueue(zone, norder);
+		if (page != NULL) {
+			allocated += (1 << norder);
+			for (i = 0; i < (1 << norder); i++)
+				list_add_tail(&page[i].lru, list);
+			norder++;
+		}
 	}
 	spin_unlock_irqrestore(&zone->lock, flags);
 	return allocated;
_