mm: make defensive checks around PFN values registered for memory usage
authorMel Gorman <mel@csn.ul.ie>
Thu, 24 Jul 2008 04:26:52 +0000 (21:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Jul 2008 17:47:13 +0000 (10:47 -0700)
There are a number of different views to how much memory is currently active.
There is the arch-independent zone-sizing view, the bootmem allocator and
memory models view.

Architectures register this information at different times and is not
necessarily in sync particularly with respect to some SPARSEMEM limitations.

This patch introduces mminit_validate_memmodel_limits() which is able to
validate and correct PFN ranges with respect to the memory model.  It is only
SPARSEMEM that currently validates itself.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/bootmem.c
mm/internal.h
mm/page_alloc.c
mm/sparse.c

index 8d9f60e..9f4bbc5 100644 (file)
@@ -91,6 +91,7 @@ static unsigned long __init init_bootmem_core(pg_data_t *pgdat,
        bootmem_data_t *bdata = pgdat->bdata;
        unsigned long mapsize;
 
+       mminit_validate_memmodel_limits(&start, &end);
        bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
        bdata->node_boot_start = PFN_PHYS(start);
        bdata->node_low_pfn = end;
index 7a4a288..5d17f3e 100644 (file)
@@ -98,4 +98,16 @@ static inline void mminit_verify_page_links(struct page *page,
 {
 }
 #endif /* CONFIG_DEBUG_MEMORY_INIT */
+
+/* mminit_validate_memmodel_limits is independent of CONFIG_DEBUG_MEMORY_INIT */
+#if defined(CONFIG_SPARSEMEM)
+extern void mminit_validate_memmodel_limits(unsigned long *start_pfn,
+                               unsigned long *end_pfn);
+#else
+static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
+                               unsigned long *end_pfn)
+{
+}
+#endif /* CONFIG_SPARSEMEM */
+
 #endif
index acab6ad..0adb66e 100644 (file)
@@ -3536,6 +3536,8 @@ void __init add_active_range(unsigned int nid, unsigned long start_pfn,
                        nid, start_pfn, end_pfn,
                        nr_nodemap_entries, MAX_ACTIVE_REGIONS);
 
+       mminit_validate_memmodel_limits(&start_pfn, &end_pfn);
+
        /* Merge with existing active regions if possible */
        for (i = 0; i < nr_nodemap_entries; i++) {
                if (early_node_map[i].nid != nid)
diff --cc mm/sparse.c
Simple merge