Skip to contentSkip to conversation

Fix show_mem panic

PATCH In review John Marvin 2 participants 2 messages Mar 12, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix show_mem panic

The following patch fixes the 2.6 showMem (sysrq) panic.

John

arch/ia64/mm/contig.c +2 -0
@@ -46,6 +46,8 @@
 	printk("Free swap:       %6dkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
 	i = max_mapnr;
 	while (i-- > 0) {
+		if (!pfn_valid(i))
+			continue;
 		total++;
 		if (PageReserved(mem_map+i))
 			reserved++;
arch/ia64/mm/discontig.c +2 -0
@@ -377,6 +377,8 @@
 	for_each_pgdat(pgdat) {
 		printk("Node ID: %d\n", pgdat->node_id);
 		for(i = 0; i < pgdat->node_spanned_pages; i++) {
+			if (!ia64_pfn_valid(pgdat->node_start_pfn+i))
+				continue;
 			if (PageReserved(pgdat->node_mem_map+i))
 				reserved++;
 			else if (PageSwapCache(pgdat->node_mem_map+i))
arch/ia64/mm/init.c +3 -1
@@ -455,8 +455,10 @@
 ia64_pfn_valid (unsigned long pfn)
 {
 	char byte;
+	struct page *page = pfn_to_page(pfn);
 
-	return __get_user(byte, (char *) pfn_to_page(pfn)) = 0;
+	return     (__get_user(byte, (char *) page) = 0)
+		&& (__get_user(byte, (char *) (page + 1) - 1) = 0);
 }
 EXPORT_SYMBOL(ia64_pfn_valid);
 
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · John Marvin
  John> ia64_pfn_valid (unsigned long pfn)
  John> {
  John> char byte;
  John> +	struct page *page = pfn_to_page(pfn);
 
  John> -	return __get_user(byte, (char *) pfn_to_page(pfn)) = 0;
  John> +	return     (__get_user(byte, (char *) page) = 0)
  John> +		&& (__get_user(byte, (char *) (page + 1) - 1) = 0);
  John> }

Would it make sense to do only the first __get_user() _unless_ the "struct page" crosses a page?

	--david