maple_tree: separate ma_state node from status
[linux-2.6-microblaze.git] / mm / memblock.c
index fd492e5..4a62f77 100644 (file)
@@ -424,7 +424,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
         * of memory that aren't suitable for allocation
         */
        if (!memblock_can_resize)
-               return -1;
+               panic("memblock: cannot resize %s array\n", type->name);
 
        /* Calculate new doubled size */
        old_size = type->max * sizeof(struct memblock_region);
@@ -734,6 +734,40 @@ int __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)
        return memblock_add_range(&memblock.memory, base, size, MAX_NUMNODES, 0);
 }
 
+/**
+ * memblock_validate_numa_coverage - check if amount of memory with
+ * no node ID assigned is less than a threshold
+ * @threshold_bytes: maximal number of pages that can have unassigned node
+ * ID (in bytes).
+ *
+ * A buggy firmware may report memory that does not belong to any node.
+ * Check if amount of such memory is below @threshold_bytes.
+ *
+ * Return: true on success, false on failure.
+ */
+bool __init_memblock memblock_validate_numa_coverage(unsigned long threshold_bytes)
+{
+       unsigned long nr_pages = 0;
+       unsigned long start_pfn, end_pfn, mem_size_mb;
+       int nid, i;
+
+       /* calculate lose page */
+       for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) {
+               if (nid == NUMA_NO_NODE)
+                       nr_pages += end_pfn - start_pfn;
+       }
+
+       if ((nr_pages << PAGE_SHIFT) >= threshold_bytes) {
+               mem_size_mb = memblock_phys_mem_size() >> 20;
+               pr_err("NUMA: no nodes coverage for %luMB of %luMB RAM\n",
+                      (nr_pages << PAGE_SHIFT) >> 20, mem_size_mb);
+               return false;
+       }
+
+       return true;
+}
+
+
 /**
  * memblock_isolate_range - isolate given range into disjoint memblocks
  * @type: memblock type to isolate range for