Index: linux-2.6.16-rc1-mm3/mm/page_alloc.c =================================================================== --- linux-2.6.16-rc1-mm3.orig/mm/page_alloc.c 2006-01-26 18:33:51.000000000 -0800 +++ linux-2.6.16-rc1-mm3/mm/page_alloc.c 2006-01-26 18:39:22.000000000 -0800 @@ -549,7 +549,7 @@ static int prep_new_page(struct page *pa * Do the hard work of removing an element from the buddy allocator. * Call me with the zone->lock already held. */ -static struct page *__rmqueue(struct zone *zone, unsigned int order) +static struct page *__rmqueue(struct zone *zone, unsigned int order, int last) { struct free_area * area; unsigned int current_order; @@ -560,7 +560,9 @@ static struct page *__rmqueue(struct zon if (list_empty(&area->free_list)) continue; - page = list_entry(area->free_list.next, struct page, lru); + page = list_entry( + last ? area->free_list.prev : area->free_list.next, + struct page, lru); list_del(&page->lru); rmv_page_order(page); area->nr_free--; @@ -578,13 +580,13 @@ static struct page *__rmqueue(struct zon * Returns the number of new pages which were placed at *list. */ static int rmqueue_bulk(struct zone *zone, unsigned int order, - unsigned long count, struct list_head *list) + unsigned long count, struct list_head *list, int last) { int i; spin_lock(&zone->lock); for (i = 0; i < count; ++i) { - struct page *page = __rmqueue(zone, order); + struct page *page = __rmqueue(zone, order, last); if (unlikely(page == NULL)) break; list_add_tail(&page->lru, list); @@ -790,6 +792,7 @@ static struct page *buffered_rmqueue(str unsigned long flags; struct page *page; int cold = !!(gfp_flags & __GFP_COLD); + int zero = !!(gfp_flags & __GFP_ZERO); int cpu; again: @@ -801,7 +804,7 @@ again: local_irq_save(flags); if (!pcp->count) { pcp->count += rmqueue_bulk(zone, 0, - pcp->batch, &pcp->list); + pcp->batch, &pcp->list, zero); if (unlikely(!pcp->count)) goto failed; } @@ -810,7 +813,7 @@ again: pcp->count--; } else { spin_lock_irqsave(&zone->lock, flags); - page = __rmqueue(zone, order); + page = __rmqueue(zone, order, zero); spin_unlock(&zone->lock); if (!page) goto failed;