]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/i386/mm/discontig.c
[PATCH] sparsemem base: teach discontig about sparse ranges
[linux-2.6-omap-h63xx.git] / arch / i386 / mm / discontig.c
index dcc71f969b01089a0b09969f014588de606ff61c..088ca4722183a6339e8d1a65ea0837be5d8e3488 100644 (file)
@@ -216,6 +216,7 @@ static unsigned long calculate_numa_remap_pages(void)
 {
        int nid;
        unsigned long size, reserve_pages = 0;
+       unsigned long pfn;
 
        for_each_online_node(nid) {
                /*
@@ -234,6 +235,19 @@ static unsigned long calculate_numa_remap_pages(void)
                size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES;
                /* now the roundup is correct, convert to PAGE_SIZE pages */
                size = size * PTRS_PER_PTE;
+
+               /*
+                * Validate the region we are allocating only contains valid
+                * pages.
+                */
+               for (pfn = node_end_pfn[nid] - size;
+                    pfn < node_end_pfn[nid]; pfn++)
+                       if (!page_is_ram(pfn))
+                               break;
+
+               if (pfn != node_end_pfn[nid])
+                       size = 0;
+
                printk("Reserving %ld pages of KVA for lmem_map of node %d\n",
                                size, nid);
                node_remap_size[nid] = size;