]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] memory hotplug prep: fixup bad_range()
authorDave Hansen <haveblue@us.ibm.com>
Sun, 30 Oct 2005 01:16:52 +0000 (18:16 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 30 Oct 2005 04:40:44 +0000 (21:40 -0700)
When doing memory hotplug operations, the size of existing zones can obviously
change.  This means that zone->zone_{start_pfn,spanned_pages} can change.

There are currently no locks that protect these structure members.  However,
they are rarely accessed at runtime.  Outside of swsusp, the only place that I
can find is bad_range().

So, split bad_range() up into two pieces: one that needs to be locked and
anther that doesn't.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/page_alloc.c

index 9a2fa8110afc96f374c94b8763dc4a97a2df5274..a51ef94eec33970e41f64d4b327d7e4686f70f15 100644 (file)
@@ -78,21 +78,37 @@ int min_free_kbytes = 1024;
 unsigned long __initdata nr_kernel_pages;
 unsigned long __initdata nr_all_pages;
 
-/*
- * Temporary debugging check for pages not lying within a given zone.
- */
-static int bad_range(struct zone *zone, struct page *page)
+static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
 {
        if (page_to_pfn(page) >= zone->zone_start_pfn + zone->spanned_pages)
                return 1;
        if (page_to_pfn(page) < zone->zone_start_pfn)
                return 1;
+
+       return 0;
+}
+
+static int page_is_consistent(struct zone *zone, struct page *page)
+{
 #ifdef CONFIG_HOLES_IN_ZONE
        if (!pfn_valid(page_to_pfn(page)))
-               return 1;
+               return 0;
 #endif
        if (zone != page_zone(page))
+               return 0;
+
+       return 1;
+}
+/*
+ * Temporary debugging check for pages not lying within a given zone.
+ */
+static int bad_range(struct zone *zone, struct page *page)
+{
+       if (page_outside_zone_boundaries(zone, page))
                return 1;
+       if (!page_is_consistent(zone, page))
+               return 1;
+
        return 0;
 }