linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
@ 2008-07-07 18:44 Chandru
  2008-07-08  1:36 ` Stephen Rothwell
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

kexec-tools adds  crash, rtas, and tce memory regions as linux,usable-memory 
properties in device-tree.  Following changes are made in the kernel to 
recognize these special properties in case of 
ibm,dynamic-reconfiguration-memory node of device-tree.

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c 
linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
--- linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c	2008-07-06 
04:23:22.000000000 +0530
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom.c	2008-07-07 17:23:58.000000000 
+0530
@@ -884,9 +884,10 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-	cell_t *dm, *ls;
+	cell_t *dm, *ls, *endp, *usm;
 	unsigned long l, n, flags;
 	u64 base, size, lmb_size;
+	char buf[32], t[8];
 
 	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
 	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
@@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
 			if ((base + size) > 0x80000000ul)
 				size = 0x80000000ul - base;
 		}
-		lmb_add(base, size);
+		strcpy(buf, "linux,usable-memory");
+		sprintf(t, "%d", (int)n);
+		strcat(buf, t);
+		usm = (cell_t *)of_get_flat_dt_prop(node,
+						 (const char *)buf, &l);
+		if (usm != NULL) {
+			endp = usm + (l / sizeof(cell_t));
+			while ((endp - usm) >= (dt_root_addr_cells +
+						 dt_root_size_cells)) {
+				base = dt_mem_next_cell(dt_root_addr_cells,
+								 &usm);
+				size = dt_mem_next_cell(dt_root_size_cells,
+								 &usm);
+				if (size == 0)
+					continue;
+				if (iommu_is_off) {
+					if ((base + size) > 0x80000000ul)
+						size = 0x80000000ul - base;
+				}
+				lmb_add(base, size);
+			}
+
+			/* Continue with next lmb entry */
+			continue;
+		} else {
+			lmb_add(base, size);
+		}
 	}
 	lmb_dump_all();
 	return 0;
diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c 
linux-2.6.26-rc9/arch/powerpc/mm/numa.c
--- linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c	2008-07-06 04:23:22.000000000 
+0530
+++ linux-2.6.26-rc9/arch/powerpc/mm/numa.c	2008-07-07 17:50:35.000000000 
+0530
@@ -349,18 +349,33 @@ static unsigned long __init numa_enforce
 	return lmb_end_of_DRAM() - start;
 }
 
+static void set_nodeinfo(int nid, unsigned long start, unsigned long size)
+{
+	fake_numa_create_new_node(((start + size) >> PAGE_SHIFT),
+					&nid);
+	node_set_online(nid);
+
+	size = numa_enforce_memory_limit(start, size);
+	if (!size)
+		return;
+	add_active_range(nid, start >> PAGE_SHIFT,
+			(start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
+	return;
+}
+
 /*
  * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
  * node.  This assumes n_mem_{addr,size}_cells have been set.
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const unsigned int *lm, *dm, *aa;
+	const unsigned int *lm, *dm, *aa, *usm;
 	unsigned int ls, ld, la;
 	unsigned int n, aam, aalen;
 	unsigned long lmb_size, size, start;
 	int nid, default_nid = 0;
-	unsigned int ai, flags;
+	unsigned int ai, flags, len, ranges;
+	char buf[32], t[8];
 
 	lm = of_get_property(memory, "ibm,lmb-size", &ls);
 	dm = of_get_property(memory, "ibm,dynamic-memory", &ld);
@@ -396,16 +411,27 @@ static void __init parse_drconf_memory(s
 				nid = default_nid;
 		}
 
-		fake_numa_create_new_node(((start + lmb_size) >> PAGE_SHIFT),
-						&nid);
-		node_set_online(nid);
+		strcpy(buf, "linux,usable-memory");
+		sprintf(t, "%d", (int)n);
+		strcat(buf, t);
+		usm = of_get_property(memory, (const char *)buf, &len);
+		if (usm != NULL) {
+			ranges = (len >> 2) / (n_mem_addr_cells +
+						 n_mem_size_cells);
+
+dr_new_range:		start = read_n_cells(n_mem_addr_cells, &usm);
+			size = read_n_cells(n_mem_size_cells, &usm);
+			if (size == 0)
+				continue;
 
-		size = numa_enforce_memory_limit(start, lmb_size);
-		if (!size)
-			continue;
+			set_nodeinfo(nid, start, size);
+			if (--ranges)
+				goto dr_new_range;
 
-		add_active_range(nid, start >> PAGE_SHIFT,
-				 (start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
+			continue;
+		} else {
+			set_nodeinfo(nid, start, lmb_size);
+		}
 	}
 }
 

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

* Re: [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
  2008-07-07 18:44 [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Chandru
@ 2008-07-08  1:36 ` Stephen Rothwell
  2008-07-08 10:58   ` Chandru
  2008-07-08  1:56 ` Michael Neuling
  2008-07-10 22:27 ` [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Nathan Fontenot
  2 siblings, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2008-07-08  1:36 UTC (permalink / raw)
  To: Chandru; +Cc: linuxppc-dev, kexec

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

Hi Chandru,

On Tue, 8 Jul 2008 00:14:24 +0530 Chandru <chandru@in.ibm.com> wrote:
>
> @@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
>  			if ((base + size) > 0x80000000ul)
>  				size = 0x80000000ul - base;
>  		}
> -		lmb_add(base, size);
> +		strcpy(buf, "linux,usable-memory");
> +		sprintf(t, "%d", (int)n);
> +		strcat(buf, t);

Why don't you use
		snprintf(buf, sizeof(buf), "linux,usable-memory%ld", n);
instead?

> +		usm = (cell_t *)of_get_flat_dt_prop(node,
> +						 (const char *)buf, &l);
		      ^^^^^^^^^^		 ^^^^^^^^^^^^^^
unnecessary casts.

>  static void __init parse_drconf_memory(struct device_node *memory)
>  {

> +		strcpy(buf, "linux,usable-memory");
> +		sprintf(t, "%d", (int)n);
> +		strcat(buf, t);

See snprint comment above.

> +		usm = of_get_property(memory, (const char *)buf, &len);
                                              ^^^^^^^^^^^^^^
unnecessary cast.

> +		if (usm != NULL) {
> +			ranges = (len >> 2) / (n_mem_addr_cells +
                                 ^^^^^^^^^^
len / sizeof(u32) ?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* (no subject)
  2008-07-07 18:44 [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Chandru
  2008-07-08  1:36 ` Stephen Rothwell
@ 2008-07-08  1:56 ` Michael Neuling
  2008-07-10 22:27 ` [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Nathan Fontenot
  2 siblings, 0 replies; 11+ messages in thread
From: Michael Neuling @ 2008-07-08  1:56 UTC (permalink / raw)
  To: Chandru; +Cc: linuxppc-dev, kexec



> [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump 

Please change the name of the individual patches 

BTW this patch doesn't apply against the powerpc-next tree.  Please use
that tree, not Linus tree.

In message <200807080014.24910.chandru@in.ibm.com> you wrote:
> kexec-tools adds  crash, rtas, and tce memory regions as linux,usable-memory 
> properties in device-tree.  Following changes are made in the kernel to 
> recognize these special properties in case of 
> ibm,dynamic-reconfiguration-memory node of device-tree.
> 
> Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
> ---
> 
> diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c 
> linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
> --- linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c	2008-07-06 
> 04:23:22.000000000 +0530
> +++ linux-2.6.26-rc9/arch/powerpc/kernel/prom.c	2008-07-07 17:23:58.000
000000 
> +0530
> @@ -884,9 +884,10 @@ static u64 __init dt_mem_next_cell(int s
>   */
>  static int __init early_init_dt_scan_drconf_memory(unsigned long node)
>  {
> -	cell_t *dm, *ls;
> +	cell_t *dm, *ls, *endp, *usm;
>  	unsigned long l, n, flags;
>  	u64 base, size, lmb_size;
> +	char buf[32], t[8];
>  
>  	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
>  	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
> @@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
>  			if ((base + size) > 0x80000000ul)
>  				size = 0x80000000ul - base;
>  		}

Please document what you are trying to achieve here

> -		lmb_add(base, size);
> +		strcpy(buf, "linux,usable-memory");
> +		sprintf(t, "%d", (int)n);
> +		strcat(buf, t);

sprintf(buf, "linux,usable-memory%d", (int)n);
??

> +		usm = (cell_t *)of_get_flat_dt_prop(node,
> +						 (const char *)buf, &l);
> +		if (usm != NULL) {
> +			endp = usm + (l / sizeof(cell_t));
> +			while ((endp - usm) >= (dt_root_addr_cells +
> +						 dt_root_size_cells)) {
> +				base = dt_mem_next_cell(dt_root_addr_cells,
> +								 &usm);
> +				size = dt_mem_next_cell(dt_root_size_cells,
> +								 &usm);
> +				if (size == 0)
> +					continue;
> +				if (iommu_is_off) {
> +					if ((base + size) > 0x80000000ul)
> +						size = 0x80000000ul - base;

There is similar code to this above.  Can this be merged?  Why
0x80000000ul anyway?

> +				}
> +				lmb_add(base, size);
> +			}
> +
> +			/* Continue with next lmb entry */
> +			continue;

Is this "continue" needed?  

Also, this comment is useless.  We know what a continue does :-)

> +		} else {
> +			lmb_add(base, size);
> +		}
>  	}
>  	lmb_dump_all();
>  	return 0;
> diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c 
> linux-2.6.26-rc9/arch/powerpc/mm/numa.c
> --- linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c	2008-07-06 04:23:22.000
000000 
> +0530
> +++ linux-2.6.26-rc9/arch/powerpc/mm/numa.c	2008-07-07 17:50:35.000000000 
> +0530
> @@ -349,18 +349,33 @@ static unsigned long __init numa_enforce
>  	return lmb_end_of_DRAM() - start;
>  }
>  
> +static void set_nodeinfo(int nid, unsigned long start, unsigned long size)
> +{
> +	fake_numa_create_new_node(((start + size) >> PAGE_SHIFT),
> +					&nid);
> +	node_set_online(nid);
> +
> +	size = numa_enforce_memory_limit(start, size);
> +	if (!size)
> +		return;
> +	add_active_range(nid, start >> PAGE_SHIFT,
> +			(start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
> +	return;
> +}
> +
>  /*
>   * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
>   * node.  This assumes n_mem_{addr,size}_cells have been set.
>   */
>  static void __init parse_drconf_memory(struct device_node *memory)
>  {
> -	const unsigned int *lm, *dm, *aa;
> +	const unsigned int *lm, *dm, *aa, *usm;
>  	unsigned int ls, ld, la;
>  	unsigned int n, aam, aalen;
>  	unsigned long lmb_size, size, start;
>  	int nid, default_nid = 0;
> -	unsigned int ai, flags;
> +	unsigned int ai, flags, len, ranges;
> +	char buf[32], t[8];
>  
>  	lm = of_get_property(memory, "ibm,lmb-size", &ls);
>  	dm = of_get_property(memory, "ibm,dynamic-memory", &ld);
> @@ -396,16 +411,27 @@ static void __init parse_drconf_memory(s
>  				nid = default_nid;
>  		}
>  
> -		fake_numa_create_new_node(((start + lmb_size) >> PAGE_SHIFT),
> -						&nid);
> -		node_set_online(nid);
> +		strcpy(buf, "linux,usable-memory");
> +		sprintf(t, "%d", (int)n);
> +		strcat(buf, t);

Again, we can do this in a single sprintf, like above...

> +		usm = of_get_property(memory, (const char *)buf, &len);
> +		if (usm != NULL) {
> +			ranges = (len >> 2) / (n_mem_addr_cells +
> +						 n_mem_size_cells);
> +
> +dr_new_range:		start = read_n_cells(n_mem_addr_cells, &usm);
> +			size = read_n_cells(n_mem_size_cells, &usm);
> +			if (size == 0)
> +				continue;
>  
> -		size = numa_enforce_memory_limit(start, lmb_size);
> -		if (!size)
> -			continue;
> +			set_nodeinfo(nid, start, size);
> +			if (--ranges)
> +				goto dr_new_range;

Can you please use a while or for loop rather than a goto.  

>  
> -		add_active_range(nid, start >> PAGE_SHIFT,
> -				 (start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
> +			continue;
> +		} else {
> +			set_nodeinfo(nid, start, lmb_size);
> +		}
>  	}
>  }
>  
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 

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

* Re: [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
  2008-07-08  1:36 ` Stephen Rothwell
@ 2008-07-08 10:58   ` Chandru
  0 siblings, 0 replies; 11+ messages in thread
From: Chandru @ 2008-07-08 10:58 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev, kexec

Thanks for the review comments. I will change to 'snprintf' at all the places  
and remove the unnecessary casts.

On Tuesday 08 July 2008 07:06:46 Stephen Rothwell wrote:
> Hi Chandru,
>
> On Tue, 8 Jul 2008 00:14:24 +0530 Chandru <chandru@in.ibm.com> wrote:
> > +		if (usm != NULL) {
> > +			ranges = (len >> 2) / (n_mem_addr_cells +
>
>                                  ^^^^^^^^^^
> len / sizeof(u32) ?

ranges is made to count the number of linux,usable-memory properties in the 
device tree.  It's acting as a counter here.  So the expression in the patch 
is fine. 

Thanks,
Chandru

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

* Re: [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
  2008-07-07 18:44 [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Chandru
  2008-07-08  1:36 ` Stephen Rothwell
  2008-07-08  1:56 ` Michael Neuling
@ 2008-07-10 22:27 ` Nathan Fontenot
  2008-07-11 11:09   ` Chandru
  2 siblings, 1 reply; 11+ messages in thread
From: Nathan Fontenot @ 2008-07-10 22:27 UTC (permalink / raw)
  To: Chandru; +Cc: linuxppc-dev, kexec

Hello Chandru,

>  static int __init early_init_dt_scan_drconf_memory(unsigned long node)
>  {
> -	cell_t *dm, *ls;
> +	cell_t *dm, *ls, *endp, *usm;
>  	unsigned long l, n, flags;
>  	u64 base, size, lmb_size;
> +	char buf[32], t[8];
>  
>  	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
>  	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
> @@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
>  			if ((base + size) > 0x80000000ul)
>  				size = 0x80000000ul - base;
>  		}
> -		lmb_add(base, size);
> +		strcpy(buf, "linux,usable-memory");
> +		sprintf(t, "%d", (int)n);
> +		strcat(buf, t);
> +		usm = (cell_t *)of_get_flat_dt_prop(node,
> +						 (const char *)buf, &l);
> +		if (usm != NULL) {
> +			endp = usm + (l / sizeof(cell_t));
> +			while ((endp - usm) >= (dt_root_addr_cells +
> +						 dt_root_size_cells)) {
> +				base = dt_mem_next_cell(dt_root_addr_cells,
> +								 &usm);
> +				size = dt_mem_next_cell(dt_root_size_cells,
> +								 &usm);
> +				if (size == 0)
> +					continue;
> +				if (iommu_is_off) {
> +					if ((base + size) > 0x80000000ul)
> +						size = 0x80000000ul - base;
> +				}
> +				lmb_add(base, size);
> +			}
> +
> +			/* Continue with next lmb entry */
> +			continue;
> +		} else {
> +			lmb_add(base, size);
> +		}
>  	}

I am still digging through the kexec tools but I don't think you want
the processing of the linux,usable-memory property inside of the
for (; n!= 0; --n) loop.  This should be moved up so that it looks for
the linux,usable-memory property and parses it, then if it is not found
look for the ibm,dynamic-reconfiguration-memory property and parse it.

There is no need to look for the linux-usable-memory property every time
a piece of the ibm,dynamic-reconfiguration-memory property is parsed.

-Nathan

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

* Re: [PATCH 1/4] kdump : add support for ibm,  dynamic-reconfiguration-memory for kexec/kdump
  2008-07-10 22:27 ` [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Nathan Fontenot
@ 2008-07-11 11:09   ` Chandru
  2008-07-11 13:49     ` [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory Chandru
  0 siblings, 1 reply; 11+ messages in thread
From: Chandru @ 2008-07-11 11:09 UTC (permalink / raw)
  To: Nathan Fontenot; +Cc: linuxppc-dev, kexec

On Friday 11 July 2008 03:57:53 Nathan Fontenot wrote:
> Hello Chandru,
>
> >  static int __init early_init_dt_scan_drconf_memory(unsigned long node)
> >  {
> > -	cell_t *dm, *ls;
> > +	cell_t *dm, *ls, *endp, *usm;
> >  	unsigned long l, n, flags;
> >  	u64 base, size, lmb_size;
> > +	char buf[32], t[8];
> >
> >  	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
> >  	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
> > @@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
> >  			if ((base + size) > 0x80000000ul)
> >  				size = 0x80000000ul - base;
> >  		}
> > -		lmb_add(base, size);
> > +		strcpy(buf, "linux,usable-memory");
> > +		sprintf(t, "%d", (int)n);
> > +		strcat(buf, t);
> > +		usm = (cell_t *)of_get_flat_dt_prop(node,
> > +						 (const char *)buf, &l);
> > +		if (usm != NULL) {
> > +			endp = usm + (l / sizeof(cell_t));
> > +			while ((endp - usm) >= (dt_root_addr_cells +
> > +						 dt_root_size_cells)) {
> > +				base = dt_mem_next_cell(dt_root_addr_cells,
> > +								 &usm);
> > +				size = dt_mem_next_cell(dt_root_size_cells,
> > +								 &usm);
> > +				if (size == 0)
> > +					continue;
> > +				if (iommu_is_off) {
> > +					if ((base + size) > 0x80000000ul)
> > +						size = 0x80000000ul - base;
> > +				}
> > +				lmb_add(base, size);
> > +			}
> > +
> > +			/* Continue with next lmb entry */
> > +			continue;
> > +		} else {
> > +			lmb_add(base, size);
> > +		}
> >  	}
>
> I am still digging through the kexec tools but I don't think you want
> the processing of the linux,usable-memory property inside of the
> for (; n!= 0; --n) loop.  This should be moved up so that it looks for
> the linux,usable-memory property and parses it, then if it is not found
> look for the ibm,dynamic-reconfiguration-memory property and parse it.
>
> There is no need to look for the linux-usable-memory property every time
> a piece of the ibm,dynamic-reconfiguration-memory property is parsed.
>
> -Nathan

Hello Nathan,

Thanks for the review. kexec-tools adds a 'linux,usable-memory' property for 
each memory range listed in the device tree.  If the regions are not 
crashkernel or rtas or tce regions, then it sets base and size to zero but 
still adds them as linux,usable-memory property.  If we look at the code 
above, in a kdump kernel we don't add an lmb through lmb_add() if the regions 
are not one of the mentioned above.  We check for (size == 0) and continue 
with next lmb if it is so.  We still have the complete device tree which 
kexec-tools passes in as the buffer that we are scanning here and 
linux,usable-memory  properties aid in making kdump kernel to see only those 
memory regions that it is suppose to use.  I just worked on another version 
of this patch based on comments from Michael Neuling and Stephen Rothwell. I 
will post it shortly.


Thanks,
Chandru

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

* [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory
  2008-07-11 11:09   ` Chandru
@ 2008-07-11 13:49     ` Chandru
  2008-07-22  9:01       ` Chandru
  0 siblings, 1 reply; 11+ messages in thread
From: Chandru @ 2008-07-11 13:49 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stephen Rothwell, Michael Neuling, kexec

Scan for linux,usable-memory properties in case of dynamic reconfiguration 
memory. Support for kexec/kdump. 

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

Patch applies on linux-next tree (patch-v2.6.26-rc9-next-20080711.gz)

 arch/powerpc/kernel/prom.c |   40 +++++++++++++++++++++++------
 arch/powerpc/mm/numa.c     |   48 ++++++++++++++++++++++++-----------
 2 files changed, 65 insertions(+), 23 deletions(-)

diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c 
linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
--- linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c	2008-07-11 
14:44:55.000000000 +0530
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom.c	2008-07-11 14:58:26.000000000 
+0530
@@ -888,9 +888,10 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-	cell_t *dm, *ls;
-	unsigned long l, n, flags;
+	cell_t *dm, *ls, *usm;
+	unsigned long l, n, flags, ranges;
 	u64 base, size, lmb_size;
+	char buf[32];
 
 	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
 	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
@@ -914,14 +915,37 @@ static int __init early_init_dt_scan_drc
 		   or if the block is not assigned to this partition (0x8) */
 		if ((flags & 0x80) || !(flags & 0x8))
 			continue;
-		size = lmb_size;
-		if (iommu_is_off) {
+		if (iommu_is_off)
 			if (base >= 0x80000000ul)
 				continue;
-			if ((base + size) > 0x80000000ul)
-				size = 0x80000000ul - base;
-		}
-		lmb_add(base, size);
+		size = lmb_size;
+
+		/*
+		 * Append 'n' to 'linux,usable-memory' to get special
+		 * properties passed in by tools like kexec-tools. Relevant
+		 * only if this is a kexec/kdump kernel.
+		 */
+		sprintf(buf, "linux,usable-memory%d", (int)n);
+		usm = of_get_flat_dt_prop(node, buf, &l);
+		ranges = 1;
+		if (usm != NULL)
+			ranges = (l >> 2)/(dt_root_addr_cells
+						+ dt_root_size_cells);
+		do {
+			if (usm != NULL) {
+				base = dt_mem_next_cell(dt_root_addr_cells,
+							 &usm);
+				size = dt_mem_next_cell(dt_root_size_cells,
+							 &usm);
+				if (size == 0)
+					break;
+			}
+			if (iommu_is_off)
+				if ((base + size) > 0x80000000ul)
+					size = 0x80000000ul - base;
+
+			lmb_add(base, size);
+		} while (--ranges);
 	}
 	lmb_dump_all();
 	return 0;
diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c 
linux-2.6.26-rc9/arch/powerpc/mm/numa.c
--- linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c	2008-07-11 14:44:55.000000000 
+0530
+++ linux-2.6.26-rc9/arch/powerpc/mm/numa.c	2008-07-11 15:01:56.000000000 
+0530
@@ -493,11 +493,13 @@ static unsigned long __init numa_enforce
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm;
-	unsigned int n, rc;
-	unsigned long lmb_size, size;
+	const u32 *dm, *usm;
+	unsigned int n, rc, len, ranges;
+	unsigned long lmb_size, size, sz;
 	int nid;
 	struct assoc_arrays aa;
+	char buf[32];
+	u64 base;
 
 	n = of_get_drconf_memory(memory, &dm);
 	if (!n)
@@ -524,19 +526,35 @@ static void __init parse_drconf_memory(s
 
 		nid = of_drconf_to_nid_single(&drmem, &aa);
 
-		fake_numa_create_new_node(
-				((drmem.base_addr + lmb_size) >> PAGE_SHIFT),
-					   &nid);
-
-		node_set_online(nid);
-
-		size = numa_enforce_memory_limit(drmem.base_addr, lmb_size);
-		if (!size)
-			continue;
+		/*
+		 * Append 'n' to 'linux,usable-memory' to get special
+		 * properties passed in by tools like kexec-tools. Relevant
+		 * only if this is a kexec/kdump kernel.
+		 */
+		sprintf(buf, "linux,usable-memory%d", (int)n);
+		usm = of_get_property(memory, buf, &len);
+		ranges = 1;
+		if (usm != NULL)
+			ranges = (len >> 2) /
+					 (n_mem_addr_cells + n_mem_size_cells);
+
+		base = drmem.base_addr;
+		size = lmb_size;
+		do {
+			if (usm != NULL) {
+				base = read_n_cells(n_mem_addr_cells, &usm);
+				size = read_n_cells(n_mem_size_cells, &usm);
+			}
 
-		add_active_range(nid, drmem.base_addr >> PAGE_SHIFT,
-				 (drmem.base_addr >> PAGE_SHIFT)
-				 + (size >> PAGE_SHIFT));
+			fake_numa_create_new_node(((base + size) >> PAGE_SHIFT),
+							 &nid);
+			node_set_online(nid);
+			sz = numa_enforce_memory_limit(base, size);
+			if (sz)
+				add_active_range(nid, base >> PAGE_SHIFT,
+						 (base >> PAGE_SHIFT)
+						+ (sz >> PAGE_SHIFT));
+		} while (--ranges);
 	}
 }
 

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

* Re: [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory
  2008-07-11 13:49     ` [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory Chandru
@ 2008-07-22  9:01       ` Chandru
  2008-07-22  9:12         ` Benjamin Herrenschmidt
  2008-07-22  9:16         ` Paul Mackerras
  0 siblings, 2 replies; 11+ messages in thread
From: Chandru @ 2008-07-22  9:01 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, Michael Neuling, Stephen Rothwell

Scan for linux,usable-memory properties in case of dynamic reconfiguration 
memory . Support for kexec/kdump.

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

Patch applies on powerpc tree. Patch was reviewed by Nathan Fontenot, Stephen 
Rothwell, Michael Neuling.  

 arch/powerpc/kernel/prom.c |   40 +++++++++++++++++++++++------
 arch/powerpc/mm/numa.c     |   48 ++++++++++++++++++++++++-----------
 2 files changed, 65 insertions(+), 23 deletions(-)

diff -Naurp powerpc-orig/arch/powerpc/kernel/prom.c 
powerpc/arch/powerpc/kernel/prom.c
--- powerpc-orig/arch/powerpc/kernel/prom.c	2008-07-22 14:11:53.000000000 
+0530
+++ powerpc/arch/powerpc/kernel/prom.c	2008-07-22 14:12:17.000000000 +0530
@@ -888,9 +888,10 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-	cell_t *dm, *ls;
-	unsigned long l, n, flags;
+	cell_t *dm, *ls, *usm;
+	unsigned long l, n, flags, ranges;
 	u64 base, size, lmb_size;
+	char buf[32];
 
 	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
 	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
@@ -914,14 +915,37 @@ static int __init early_init_dt_scan_drc
 		   or if the block is not assigned to this partition (0x8) */
 		if ((flags & 0x80) || !(flags & 0x8))
 			continue;
-		size = lmb_size;
-		if (iommu_is_off) {
+		if (iommu_is_off)
 			if (base >= 0x80000000ul)
 				continue;
-			if ((base + size) > 0x80000000ul)
-				size = 0x80000000ul - base;
-		}
-		lmb_add(base, size);
+		size = lmb_size;
+
+		/*
+		 * Append 'n' to 'linux,usable-memory' to get special
+		 * properties passed in by tools like kexec-tools. Relevant
+		 * only if this is a kexec/kdump kernel.
+		 */
+		sprintf(buf, "linux,usable-memory%d", (int)n);
+		usm = of_get_flat_dt_prop(node, buf, &l);
+		ranges = 1;
+		if (usm != NULL)
+			ranges = (l >> 2)/(dt_root_addr_cells
+						+ dt_root_size_cells);
+		do {
+			if (usm != NULL) {
+				base = dt_mem_next_cell(dt_root_addr_cells,
+							 &usm);
+				size = dt_mem_next_cell(dt_root_size_cells,
+							 &usm);
+				if (size == 0)
+					break;
+			}
+			if (iommu_is_off)
+				if ((base + size) > 0x80000000ul)
+					size = 0x80000000ul - base;
+
+			lmb_add(base, size);
+		} while (--ranges);
 	}
 	lmb_dump_all();
 	return 0;
diff -Naurp powerpc-orig/arch/powerpc/mm/numa.c powerpc/arch/powerpc/mm/numa.c
--- powerpc-orig/arch/powerpc/mm/numa.c	2008-07-22 14:11:53.000000000 +0530
+++ powerpc/arch/powerpc/mm/numa.c	2008-07-22 14:12:17.000000000 +0530
@@ -493,11 +493,13 @@ static unsigned long __init numa_enforce
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const u32 *dm;
-	unsigned int n, rc;
-	unsigned long lmb_size, size;
+	const u32 *dm, *usm;
+	unsigned int n, rc, len, ranges;
+	unsigned long lmb_size, size, sz;
 	int nid;
 	struct assoc_arrays aa;
+	char buf[32];
+	u64 base;
 
 	n = of_get_drconf_memory(memory, &dm);
 	if (!n)
@@ -524,19 +526,35 @@ static void __init parse_drconf_memory(s
 
 		nid = of_drconf_to_nid_single(&drmem, &aa);
 
-		fake_numa_create_new_node(
-				((drmem.base_addr + lmb_size) >> PAGE_SHIFT),
-					   &nid);
-
-		node_set_online(nid);
-
-		size = numa_enforce_memory_limit(drmem.base_addr, lmb_size);
-		if (!size)
-			continue;
+		/*
+		 * Append 'n' to 'linux,usable-memory' to get special
+		 * properties passed in by tools like kexec-tools. Relevant
+		 * only if this is a kexec/kdump kernel.
+		 */
+		sprintf(buf, "linux,usable-memory%d", (int)n);
+		usm = of_get_property(memory, buf, &len);
+		ranges = 1;
+		if (usm != NULL)
+			ranges = (len >> 2) /
+					 (n_mem_addr_cells + n_mem_size_cells);
+
+		base = drmem.base_addr;
+		size = lmb_size;
+		do {
+			if (usm != NULL) {
+				base = read_n_cells(n_mem_addr_cells, &usm);
+				size = read_n_cells(n_mem_size_cells, &usm);
+			}
 
-		add_active_range(nid, drmem.base_addr >> PAGE_SHIFT,
-				 (drmem.base_addr >> PAGE_SHIFT)
-				 + (size >> PAGE_SHIFT));
+			fake_numa_create_new_node(((base + size) >> PAGE_SHIFT),
+							 &nid);
+			node_set_online(nid);
+			sz = numa_enforce_memory_limit(base, size);
+			if (sz)
+				add_active_range(nid, base >> PAGE_SHIFT,
+						 (base >> PAGE_SHIFT)
+						+ (sz >> PAGE_SHIFT));
+		} while (--ranges);
 	}
 }

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

* Re: [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory
  2008-07-22  9:01       ` Chandru
@ 2008-07-22  9:12         ` Benjamin Herrenschmidt
  2008-07-22  9:16         ` Paul Mackerras
  1 sibling, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2008-07-22  9:12 UTC (permalink / raw)
  To: Chandru; +Cc: linuxppc-dev, Michael Neuling, Stephen Rothwell

On Tue, 2008-07-22 at 14:31 +0530, Chandru wrote:
> Scan for linux,usable-memory properties in case of dynamic reconfiguration 
> memory . Support for kexec/kdump.
> 
> Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
> ---
> 
> Patch applies on powerpc tree. Patch was reviewed by Nathan Fontenot, Stephen 
> Rothwell, Michael Neuling.  

Any reason why there's no acks there then ? I don't have an objection to
the patch per-se and I was planning to review it this week too, but if
you had positive reviews and you addressed whatever comments the people
had, there should be Acked-by: lines in your patch (ie, don't invent
them, only put them there if you actually got that from the reviewers).

Cheers,
Ben.

>  arch/powerpc/kernel/prom.c |   40 +++++++++++++++++++++++------
>  arch/powerpc/mm/numa.c     |   48 ++++++++++++++++++++++++-----------
>  2 files changed, 65 insertions(+), 23 deletions(-)
> 
> diff -Naurp powerpc-orig/arch/powerpc/kernel/prom.c 
> powerpc/arch/powerpc/kernel/prom.c
> --- powerpc-orig/arch/powerpc/kernel/prom.c	2008-07-22 14:11:53.000000000 
> +0530
> +++ powerpc/arch/powerpc/kernel/prom.c	2008-07-22 14:12:17.000000000 +0530
> @@ -888,9 +888,10 @@ static u64 __init dt_mem_next_cell(int s
>   */
>  static int __init early_init_dt_scan_drconf_memory(unsigned long node)
>  {
> -	cell_t *dm, *ls;
> -	unsigned long l, n, flags;
> +	cell_t *dm, *ls, *usm;
> +	unsigned long l, n, flags, ranges;
>  	u64 base, size, lmb_size;
> +	char buf[32];
>  
>  	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
>  	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
> @@ -914,14 +915,37 @@ static int __init early_init_dt_scan_drc
>  		   or if the block is not assigned to this partition (0x8) */
>  		if ((flags & 0x80) || !(flags & 0x8))
>  			continue;
> -		size = lmb_size;
> -		if (iommu_is_off) {
> +		if (iommu_is_off)
>  			if (base >= 0x80000000ul)
>  				continue;
> -			if ((base + size) > 0x80000000ul)
> -				size = 0x80000000ul - base;
> -		}
> -		lmb_add(base, size);
> +		size = lmb_size;
> +
> +		/*
> +		 * Append 'n' to 'linux,usable-memory' to get special
> +		 * properties passed in by tools like kexec-tools. Relevant
> +		 * only if this is a kexec/kdump kernel.
> +		 */
> +		sprintf(buf, "linux,usable-memory%d", (int)n);
> +		usm = of_get_flat_dt_prop(node, buf, &l);
> +		ranges = 1;
> +		if (usm != NULL)
> +			ranges = (l >> 2)/(dt_root_addr_cells
> +						+ dt_root_size_cells);
> +		do {
> +			if (usm != NULL) {
> +				base = dt_mem_next_cell(dt_root_addr_cells,
> +							 &usm);
> +				size = dt_mem_next_cell(dt_root_size_cells,
> +							 &usm);
> +				if (size == 0)
> +					break;
> +			}
> +			if (iommu_is_off)
> +				if ((base + size) > 0x80000000ul)
> +					size = 0x80000000ul - base;
> +
> +			lmb_add(base, size);
> +		} while (--ranges);
>  	}
>  	lmb_dump_all();
>  	return 0;
> diff -Naurp powerpc-orig/arch/powerpc/mm/numa.c powerpc/arch/powerpc/mm/numa.c
> --- powerpc-orig/arch/powerpc/mm/numa.c	2008-07-22 14:11:53.000000000 +0530
> +++ powerpc/arch/powerpc/mm/numa.c	2008-07-22 14:12:17.000000000 +0530
> @@ -493,11 +493,13 @@ static unsigned long __init numa_enforce
>   */
>  static void __init parse_drconf_memory(struct device_node *memory)
>  {
> -	const u32 *dm;
> -	unsigned int n, rc;
> -	unsigned long lmb_size, size;
> +	const u32 *dm, *usm;
> +	unsigned int n, rc, len, ranges;
> +	unsigned long lmb_size, size, sz;
>  	int nid;
>  	struct assoc_arrays aa;
> +	char buf[32];
> +	u64 base;
>  
>  	n = of_get_drconf_memory(memory, &dm);
>  	if (!n)
> @@ -524,19 +526,35 @@ static void __init parse_drconf_memory(s
>  
>  		nid = of_drconf_to_nid_single(&drmem, &aa);
>  
> -		fake_numa_create_new_node(
> -				((drmem.base_addr + lmb_size) >> PAGE_SHIFT),
> -					   &nid);
> -
> -		node_set_online(nid);
> -
> -		size = numa_enforce_memory_limit(drmem.base_addr, lmb_size);
> -		if (!size)
> -			continue;
> +		/*
> +		 * Append 'n' to 'linux,usable-memory' to get special
> +		 * properties passed in by tools like kexec-tools. Relevant
> +		 * only if this is a kexec/kdump kernel.
> +		 */
> +		sprintf(buf, "linux,usable-memory%d", (int)n);
> +		usm = of_get_property(memory, buf, &len);
> +		ranges = 1;
> +		if (usm != NULL)
> +			ranges = (len >> 2) /
> +					 (n_mem_addr_cells + n_mem_size_cells);
> +
> +		base = drmem.base_addr;
> +		size = lmb_size;
> +		do {
> +			if (usm != NULL) {
> +				base = read_n_cells(n_mem_addr_cells, &usm);
> +				size = read_n_cells(n_mem_size_cells, &usm);
> +			}
>  
> -		add_active_range(nid, drmem.base_addr >> PAGE_SHIFT,
> -				 (drmem.base_addr >> PAGE_SHIFT)
> -				 + (size >> PAGE_SHIFT));
> +			fake_numa_create_new_node(((base + size) >> PAGE_SHIFT),
> +							 &nid);
> +			node_set_online(nid);
> +			sz = numa_enforce_memory_limit(base, size);
> +			if (sz)
> +				add_active_range(nid, base >> PAGE_SHIFT,
> +						 (base >> PAGE_SHIFT)
> +						+ (sz >> PAGE_SHIFT));
> +		} while (--ranges);
>  	}
>  }

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

* Re: [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory
  2008-07-22  9:01       ` Chandru
  2008-07-22  9:12         ` Benjamin Herrenschmidt
@ 2008-07-22  9:16         ` Paul Mackerras
  2008-07-25 16:51           ` Chandru
  1 sibling, 1 reply; 11+ messages in thread
From: Paul Mackerras @ 2008-07-22  9:16 UTC (permalink / raw)
  To: Chandru; +Cc: Michael Neuling, Stephen Rothwell, linuxppc-dev

Chandru writes:

> Scan for linux,usable-memory properties in case of dynamic reconfiguration 
> memory . Support for kexec/kdump.
> 
> Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>

Could we *please* have a more comprehensive patch description that
that?  Something which will help people coming along in two (or five
or ten) years time to understand what problem exists in the code, how
this patch solves it, and why this approach was chosen over any
alternative approaches?

Thanks,
Paul.

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

* Re: [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory
  2008-07-22  9:16         ` Paul Mackerras
@ 2008-07-25 16:51           ` Chandru
  0 siblings, 0 replies; 11+ messages in thread
From: Chandru @ 2008-07-25 16:51 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Michael Neuling, Stephen Rothwell, linuxppc-dev

On Tuesday 22 July 2008 14:46:20 Paul Mackerras wrote:
> Chandru writes:
> 
> > Scan for linux,usable-memory properties in case of dynamic reconfiguration 
> > memory . Support for kexec/kdump.
> > 
> > Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
> 
> Could we *please* have a more comprehensive patch description that
> that?  Something which will help people coming along in two (or five
> or ten) years time to understand what problem exists in the code, how
> this patch solves it, and why this approach was chosen over any
> alternative approaches?
> 
> Thanks,
> Paul.
> 

Another alternate approach could be to create one 'linux,usable-drconf-memory' property and add all the usable memory regions into it, in a similar fashion to ibm,dynamic-memory property. For a given lmb in ibm,dynamic-memory , a corresponding usable-memory entry could be created which will contain 1 or more of (base,size) duple.  For each entry in this new 'linux,usable-drconf-memory' property, a counter within it will tell us how many (base,size) duple are available in it.  Some part of the current code may get duplicated. Let me go back and check if I can work on a patch for this approach .  

thx,
Chandru  

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

end of thread, other threads:[~2008-07-25 16:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-07 18:44 [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Chandru
2008-07-08  1:36 ` Stephen Rothwell
2008-07-08 10:58   ` Chandru
2008-07-08  1:56 ` Michael Neuling
2008-07-10 22:27 ` [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump Nathan Fontenot
2008-07-11 11:09   ` Chandru
2008-07-11 13:49     ` [PATCH 1/4][V2] powerpc : add support for linux, usable-memory properties for drconf memory Chandru
2008-07-22  9:01       ` Chandru
2008-07-22  9:12         ` Benjamin Herrenschmidt
2008-07-22  9:16         ` Paul Mackerras
2008-07-25 16:51           ` Chandru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).