Re: [PATCH] crash: s390x: Auto-detect the correct MAX_PHYSMEM_BITS used in vmcore being analyzed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message -----
> Hi Dave,
> 
> On Thu, 2011-12-22 at 09:19 -0500, Dave Anderson wrote:
> > 
> > ----- Original Message -----
> > > 
> > > Unfortunately Mahesh is currently not online. We still have some time
> > > because Martin's kernel patch that introduces the change will go into
> > > Linux version 3.3.
> > > 
> > > So perhaps you make your crash release without this patch.
> > > 
> > > Michael
> > 
> > Tell you what -- I'm going to make a hybrid patch, using Mahesh's
> > more understandable-yet-longer function, but with your verify_pfn()
> > and STRUCT_SIZE_INIT("mem_section") movement, along with a default
> > setting of 42 and a non-fatal WARNING message if things fail.
> > I'll verify it on RHEL5 and RHEL6.
> > 
> > If you want to change it later, that will be fine, too.
> 
> Ok, I will have a look at your next crash release in the new year.
> 
> Thanks!
> 
> Michael
 
I've attached what I'm going with -- freshly tested on RHEL5 and RHEL6.
And interestingly enough -- even RHEL5 is still FLATMEM. 

Thanks guys,
  Dave

 
--- defs.h	15 Dec 2011 20:26:11 -0000	1.490
+++ defs.h	21 Dec 2011 15:50:00 -0000
@@ -2969,7 +2969,8 @@
 #define TIF_SIGPENDING (2)
 
 #define _SECTION_SIZE_BITS	28
-#define _MAX_PHYSMEM_BITS	42
+#define _MAX_PHYSMEM_BITS_OLD	42
+#define _MAX_PHYSMEM_BITS_NEW	46
 
 #endif  /* S390X */
 
--- kernel.c	17 Dec 2011 15:52:30 -0000	1.265
+++ kernel.c	22 Dec 2011 14:23:06 -0000
@@ -579,6 +579,8 @@
 		kt->flags |= ARCH_OPENVZ;
 	}
 
+	STRUCT_SIZE_INIT(mem_section, "mem_section");
+
 	BUG_bytes_init();
 	
 	kt->flags &= ~PRE_KERNEL_INIT;
--- memory.c	16 Nov 2011 21:08:16 -0000	1.261
+++ memory.c	22 Dec 2011 14:26:20 -0000
@@ -13601,7 +13601,7 @@
 	for (i = machdep->max_physmem_bits; i < machdep->bits; i++)
 		mask |= ((physaddr_t)1 << i);
 		
-	if (mask & BTOP(pfn))
+	if (mask & PTOB(pfn))
 		return FALSE;
 
 	return TRUE;
@@ -14203,7 +14203,6 @@
 
 	MEMBER_OFFSET_INIT(mem_section_section_mem_map, "mem_section",
 		"section_mem_map");
-	STRUCT_SIZE_INIT(mem_section, "mem_section");
 
 	if (!MAX_PHYSMEM_BITS())
 		error(FATAL, 
--- s390x.c	10 Nov 2011 14:37:15 -0000	1.57
+++ s390x.c	22 Dec 2011 14:39:46 -0000
@@ -114,6 +114,7 @@
 static struct line_number_hook s390x_line_number_hooks[];
 static int s390x_is_uvaddr(ulong, struct task_context *);
 static int s390x_get_kvaddr_ranges(struct vaddr_range *);
+static int set_s390x_max_physmem_bits(void);
 
 /*
  * Read a unsigned long value from address
@@ -150,6 +151,51 @@
 	}
 }
 
+/*
+ *  MAX_PHYSMEM_BITS is 42 on older kernels, and 46 on newer kernels.
+ */
+static int
+set_s390x_max_physmem_bits(void)
+{
+	int array_len, dimension;
+
+	machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_OLD;
+
+	if (!kernel_symbol_exists("mem_section"))
+		return TRUE;
+
+	if (!(array_len = get_array_length("mem_section", &dimension, 0)))
+		return FALSE;
+
+	/*
+	 * !CONFIG_SPARSEMEM_EXTREME
+	 */
+	if (dimension) {
+		machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_OLD;
+		if (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT()))
+			return TRUE;
+
+		machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_NEW;
+		if (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT()))
+			return TRUE;
+
+		return FALSE;
+	}
+
+	/*
+	 * CONFIG_SPARSEMEM_EXTREME
+	 */
+	machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_OLD;
+	if (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT_EXTREME()))
+		return TRUE;
+
+	machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_NEW;
+	if (array_len == (NR_MEM_SECTIONS() / _SECTIONS_PER_ROOT_EXTREME()))
+		return TRUE;
+
+	return FALSE;
+}
+
 static struct s390x_cpu *s390x_cpu_vec;
 static int s390x_cpu_cnt;
 /*
@@ -350,7 +396,8 @@
 		if (!machdep->hz)
 			machdep->hz = HZ;
 		machdep->section_size_bits = _SECTION_SIZE_BITS;
-		machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
+		if (!set_s390x_max_physmem_bits())
+			error(WARNING, "cannot determine MAX_PHYSMEM_BITS\n");
 		s390x_offsets_init();
 		break;
 
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux