linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] mm: detect bad zones
@ 2006-05-21  8:22 Nick Piggin
  2006-05-21  8:22 ` [patch 2/2] mm: handle unaligned zones Nick Piggin
  0 siblings, 1 reply; 23+ messages in thread
From: Nick Piggin @ 2006-05-21  8:22 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft, Mel Gorman, stable,
	Linux Memory Management

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Hi,

I think the previous few patches / patchsets to handle the unaligned zone
thing aren't exactly what we want (at least, for 2.6.16.stable and 2.6.17).

Firstly, we need to check for buddies outside the zone span, not just those
which are in a different zone.

Secondly, I think aligned zones should be an opt-in thing. Performance hit
is not huge, but potential stability hit is.

-- 
SUSE Labs, Novell Inc.

[-- Attachment #2: mm-detect-bad-zones.patch --]
[-- Type: text/plain, Size: 1982 bytes --]

panic when zones fail correct alignment and other checks.
The alternative could be random and/or undetected corruption later.

Signed-off-by: Nick Piggin <npiggin@suse.de>

Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c	2006-05-19 13:15:51.000000000 +1000
+++ linux-2.6/mm/page_alloc.c	2006-05-21 12:22:44.000000000 +1000
@@ -2041,6 +2041,47 @@ static __meminit void zone_pcp_init(stru
 			zone->name, zone->present_pages, batch);
 }
 
+static __meminit void zone_debug_checks(struct zone *zone)
+{
+	unsigned long pfn;
+	unsigned long start = zone->zone_start_pfn;
+	unsigned long end = start + zone->spanned_pages;
+	const unsigned long mask = ((1<<MAX_ORDER)-1);
+	
+	if (start & mask)
+		panic("zone start pfn (%lx) not MAX_ORDER aligned\n", start);
+
+	if (end & mask)
+		panic("zone end pfn (%lx) not MAX_ORDER aligned\n", end);
+
+	for (pfn = start; pfn < end; pfn++) {
+		struct page *page;
+		int order;
+
+#ifndef CONFIG_HOLES_IN_ZONE
+		if (!pfn_valid(pfn))
+			panic("zone pfn (%lx) not valid\n", pfn);
+#endif
+
+		page = pfn_to_page(pfn);
+		if (page_zone(page) != zone)
+			panic("zone page (pfn %lx) in wrong zone\n", pfn);
+
+		for (order = 0; order < MAX_ORDER-1; order++) {
+			struct page *buddy;
+			buddy = __page_find_buddy(page, pfn & mask, order);
+
+#ifndef CONFIG_HOLES_IN_ZONE
+			if (!pfn_valid(page_to_pfn(buddy)))
+				panic("pfn (%lx) buddy (order %d) not valid\n", pfn, order);
+#endif
+
+			if (page_zone(buddy) != zone)
+				panic("pfn (%lx) buddy (order %d) in wrong zone\n", pfn, order);
+		}
+	}
+}
+
 static __meminit void init_currently_empty_zone(struct zone *zone,
 		unsigned long zone_start_pfn, unsigned long size)
 {
@@ -2054,6 +2095,8 @@ static __meminit void init_currently_emp
 	memmap_init(size, pgdat->node_id, zone_idx(zone), zone_start_pfn);
 
 	zone_init_free_lists(pgdat, zone, zone->spanned_pages);
+
+	zone_debug_checks(zone);
 }
 
 /*

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2006-05-31 17:42 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-21  8:22 [patch 1/2] mm: detect bad zones Nick Piggin
2006-05-21  8:22 ` [patch 2/2] mm: handle unaligned zones Nick Piggin
2006-05-21  9:19   ` Andrew Morton
2006-05-21 10:31     ` Nick Piggin
2006-05-21 10:59       ` Andrew Morton
2006-05-21 11:44         ` Nick Piggin
2006-05-21 11:52           ` Nick Piggin
2006-05-22  9:24             ` Mel Gorman
2006-05-22  9:28               ` Mel Gorman
2006-05-22  9:06           ` Mel Gorman
2006-05-22  9:51             ` Nick Piggin
2006-05-21 11:53       ` Nick Piggin
2006-05-22  8:18   ` Andy Whitcroft
2006-05-22  9:37     ` Nick Piggin
2006-05-22  9:52     ` [PATCH 0/2] Zone boundary alignment fixes, default configuration Andy Whitcroft
2006-05-22  9:53       ` [PATCH 1/2] zone allow unaligned zone boundaries add configuration Andy Whitcroft
2006-05-22  9:53       ` [PATCH 2/2] x86 add zone alignment qualifier Andy Whitcroft
2006-05-25 11:19       ` [PATCH 0/2] Zone boundary alignment fixes, default configuration Andy Whitcroft
2006-05-31  0:13       ` [stable] " Chris Wright
2006-05-31 11:41         ` Nick Piggin
2006-05-31 12:08           ` Andy Whitcroft
2006-05-31 17:42             ` Greg KH
2006-05-31 17:16         ` Andy Whitcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox