]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/page_alloc.c
[PATCH] Page Migration: Make do_swap_page redo the fault
[karo-tx-linux.git] / mm / page_alloc.c
index 813b4ec1298a23ee10e0d091305bd8520ba6fad0..fd631c2536a5e67de95331d93afbf6853ceee6fe 100644 (file)
@@ -286,22 +286,27 @@ __find_combined_index(unsigned long page_idx, unsigned int order)
  * we can do coalesce a page and its buddy if
  * (a) the buddy is not in a hole &&
  * (b) the buddy is in the buddy system &&
- * (c) a page and its buddy have the same order.
+ * (c) a page and its buddy have the same order &&
+ * (d) a page and its buddy are in the same zone.
  *
  * For recording whether a page is in the buddy system, we use PG_buddy.
  * Setting, clearing, and testing PG_buddy is serialized by zone->lock.
  *
  * For recording page's order, we use page_private(page).
  */
-static inline int page_is_buddy(struct page *page, int order)
+static inline int page_is_buddy(struct page *page, struct page *buddy,
+                                                               int order)
 {
 #ifdef CONFIG_HOLES_IN_ZONE
-       if (!pfn_valid(page_to_pfn(page)))
+       if (!pfn_valid(page_to_pfn(buddy)))
                return 0;
 #endif
 
-       if (PageBuddy(page) && page_order(page) == order) {
-               BUG_ON(page_count(page) != 0);
+       if (page_zone_id(page) != page_zone_id(buddy))
+               return 0;
+
+       if (PageBuddy(buddy) && page_order(buddy) == order) {
+               BUG_ON(page_count(buddy) != 0);
                return 1;
        }
        return 0;
@@ -352,7 +357,7 @@ static inline void __free_one_page(struct page *page,
                struct page *buddy;
 
                buddy = __page_find_buddy(page, page_idx, order);
-               if (!page_is_buddy(buddy, order))
+               if (!page_is_buddy(page, buddy, order))
                        break;          /* Move the buddy up one level. */
 
                list_del(&buddy->lru);
@@ -951,7 +956,7 @@ restart:
                goto got_pg;
 
        do {
-               if (cpuset_zone_allowed(*z, gfp_mask))
+               if (cpuset_zone_allowed(*z, gfp_mask|__GFP_HARDWALL))
                        wakeup_kswapd(*z, order);
        } while (*(++z));
 
@@ -970,7 +975,8 @@ restart:
                alloc_flags |= ALLOC_HARDER;
        if (gfp_mask & __GFP_HIGH)
                alloc_flags |= ALLOC_HIGH;
-       alloc_flags |= ALLOC_CPUSET;
+       if (wait)
+               alloc_flags |= ALLOC_CPUSET;
 
        /*
         * Go through the zonelist again. Let __GFP_HIGH and allocations
@@ -2124,14 +2130,22 @@ static void __init alloc_node_mem_map(struct pglist_data *pgdat)
 #ifdef CONFIG_FLAT_NODE_MEM_MAP
        /* ia64 gets its own node_mem_map, before this, without bootmem */
        if (!pgdat->node_mem_map) {
-               unsigned long size;
+               unsigned long size, start, end;
                struct page *map;
 
-               size = (pgdat->node_spanned_pages + 1) * sizeof(struct page);
+               /*
+                * The zone's endpoints aren't required to be MAX_ORDER
+                * aligned but the node_mem_map endpoints must be in order
+                * for the buddy allocator to function correctly.
+                */
+               start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES - 1);
+               end = pgdat->node_start_pfn + pgdat->node_spanned_pages;
+               end = ALIGN(end, MAX_ORDER_NR_PAGES);
+               size =  (end - start) * sizeof(struct page);
                map = alloc_remap(pgdat->node_id, size);
                if (!map)
                        map = alloc_bootmem_node(pgdat, size);
-               pgdat->node_mem_map = map;
+               pgdat->node_mem_map = map + (pgdat->node_start_pfn - start);
        }
 #ifdef CONFIG_FLATMEM
        /*