linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i386: nid_zone_sizes_init() update
@ 2005-10-05  8:35 Magnus Damm
  2005-10-05 15:10 ` Martin J. Bligh
  2005-10-05 16:12 ` Dave Hansen
  0 siblings, 2 replies; 5+ messages in thread
From: Magnus Damm @ 2005-10-05  8:35 UTC (permalink / raw)
  To: linux-mm; +Cc: Magnus Damm

Broken out nid_zone_sizes_init() change from i386 NUMA emulation code.

Signed-off-by: Magnus Damm <magnus@valinux.co.jp>
---

Applies on top of linux-2.6.14-rc2-git8-mhp1

--- from-0053/arch/i386/kernel/setup.c
+++ to-work/arch/i386/kernel/setup.c	2005-10-04 15:18:54.000000000 +0900
@@ -1215,31 +1215,24 @@ static inline unsigned long max_hardware
 {
 	return virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
 }
-static inline unsigned long  nid_size_pages(int nid)
-{
-	return node_end_pfn[nid] - node_start_pfn[nid];
-}
-static inline int nid_starts_in_highmem(int nid)
-{
-	return node_start_pfn[nid] >= max_low_pfn;
-}
 
 void __init nid_zone_sizes_init(int nid)
 {
 	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
-	unsigned long max_dma;
+	unsigned long max_dma = min(max_hardware_dma_pfn(), max_low_pfn);
 	unsigned long start = node_start_pfn[nid];
 	unsigned long end = node_end_pfn[nid];
 
 	if (node_has_online_mem(nid)){
-		if (nid_starts_in_highmem(nid)) {
-			zones_size[ZONE_HIGHMEM] = nid_size_pages(nid);
-		} else {
-			max_dma = min(max_hardware_dma_pfn(), max_low_pfn);
-			zones_size[ZONE_DMA] = max_dma;
-			zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
-			zones_size[ZONE_HIGHMEM] = end - max_low_pfn;
+		if (start < max_dma) {
+			zones_size[ZONE_DMA] = min(end, max_dma) - start;
+		}
+		if (start < max_low_pfn && max_dma < end) {
+			zones_size[ZONE_NORMAL] = min(end, max_low_pfn) - max(start, max_dma);
 		}
+		if (max_low_pfn <= end) {
+			zones_size[ZONE_HIGHMEM] = end - max(start, max_low_pfn);
+               }
 	}
 
 	free_area_init_node(nid, NODE_DATA(nid), zones_size, start,

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] i386: nid_zone_sizes_init() update
  2005-10-05  8:35 [PATCH] i386: nid_zone_sizes_init() update Magnus Damm
@ 2005-10-05 15:10 ` Martin J. Bligh
  2005-10-05 16:25   ` Dave Hansen
  2005-10-05 16:12 ` Dave Hansen
  1 sibling, 1 reply; 5+ messages in thread
From: Martin J. Bligh @ 2005-10-05 15:10 UTC (permalink / raw)
  To: Magnus Damm, linux-mm

> Broken out nid_zone_sizes_init() change from i386 NUMA emulation code.

Mmmm. what's the purpose of this change? Not sure I understand what
you're trying to acheive here ... looks like you're just removing
some abstractions? To me, they made the code a bit easier to read.
 
> Signed-off-by: Magnus Damm <magnus@valinux.co.jp>
> ---
> 
> Applies on top of linux-2.6.14-rc2-git8-mhp1
> 
> --- from-0053/arch/i386/kernel/setup.c
> +++ to-work/arch/i386/kernel/setup.c	2005-10-04 15:18:54.000000000 +0900
> @@ -1215,31 +1215,24 @@ static inline unsigned long max_hardware
>  {
>  	return virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
>  }
> -static inline unsigned long  nid_size_pages(int nid)
> -{
> -	return node_end_pfn[nid] - node_start_pfn[nid];
> -}
> -static inline int nid_starts_in_highmem(int nid)
> -{
> -	return node_start_pfn[nid] >= max_low_pfn;
> -}
>  
>  void __init nid_zone_sizes_init(int nid)
>  {
>  	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
> -	unsigned long max_dma;
> +	unsigned long max_dma = min(max_hardware_dma_pfn(), max_low_pfn);
>  	unsigned long start = node_start_pfn[nid];
>  	unsigned long end = node_end_pfn[nid];
>  
>  	if (node_has_online_mem(nid)){
> -		if (nid_starts_in_highmem(nid)) {
> -			zones_size[ZONE_HIGHMEM] = nid_size_pages(nid);
> -		} else {
> -			max_dma = min(max_hardware_dma_pfn(), max_low_pfn);
> -			zones_size[ZONE_DMA] = max_dma;
> -			zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
> -			zones_size[ZONE_HIGHMEM] = end - max_low_pfn;
> +		if (start < max_dma) {
> +			zones_size[ZONE_DMA] = min(end, max_dma) - start;
> +		}
> +		if (start < max_low_pfn && max_dma < end) {
> +			zones_size[ZONE_NORMAL] = min(end, max_low_pfn) - max(start, max_dma);
>  		}
> +		if (max_low_pfn <= end) {
> +			zones_size[ZONE_HIGHMEM] = end - max(start, max_low_pfn);
> +               }
>  	}
>  
>  	free_area_init_node(nid, NODE_DATA(nid), zones_size, start,
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 
> 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] i386: nid_zone_sizes_init() update
  2005-10-05  8:35 [PATCH] i386: nid_zone_sizes_init() update Magnus Damm
  2005-10-05 15:10 ` Martin J. Bligh
@ 2005-10-05 16:12 ` Dave Hansen
  2005-10-06 10:38   ` Magnus Damm
  1 sibling, 1 reply; 5+ messages in thread
From: Dave Hansen @ 2005-10-05 16:12 UTC (permalink / raw)
  To: Magnus Damm; +Cc: linux-mm

On Wed, 2005-10-05 at 17:35 +0900, Magnus Damm wrote:
> Broken out nid_zone_sizes_init() change from i386 NUMA emulation code.
...
> -static inline unsigned long  nid_size_pages(int nid)
> -{
> -	return node_end_pfn[nid] - node_start_pfn[nid];
> -}
> -static inline int nid_starts_in_highmem(int nid)
> -{
> -	return node_start_pfn[nid] >= max_low_pfn;
> -}

Hey, I liked those helpers!

When I suggested that you make your patches apply on top of the existing
-mhp stuff, I didn't just mean that they should _apply_, they should
probably mesh a little bit better.  For instance, it would be very
helpful to use those 'static inlines', or make a couple new ones if you
need them.

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] i386: nid_zone_sizes_init() update
  2005-10-05 15:10 ` Martin J. Bligh
@ 2005-10-05 16:25   ` Dave Hansen
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Hansen @ 2005-10-05 16:25 UTC (permalink / raw)
  To: Martin J. Bligh; +Cc: Magnus Damm, linux-mm

On Wed, 2005-10-05 at 08:10 -0700, Martin J. Bligh wrote:
> > Broken out nid_zone_sizes_init() change from i386 NUMA emulation code.
> 
> Mmmm. what's the purpose of this change? Not sure I understand what
> you're trying to acheive here ... looks like you're just removing
> some abstractions? To me, they made the code a bit easier to read.

Thanks for the compliment.  Perhaps we should merge this patch upstream:

http://www.sr71.net/patches/2.6.14/2.6.14-rc2-git8-mhp1/broken-out/B2.1-i386-discontig-consolidation.patch

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] i386: nid_zone_sizes_init() update
  2005-10-05 16:12 ` Dave Hansen
@ 2005-10-06 10:38   ` Magnus Damm
  0 siblings, 0 replies; 5+ messages in thread
From: Magnus Damm @ 2005-10-06 10:38 UTC (permalink / raw)
  To: Dave Hansen; +Cc: Magnus Damm, linux-mm

On 10/6/05, Dave Hansen <haveblue@us.ibm.com> wrote:
> On Wed, 2005-10-05 at 17:35 +0900, Magnus Damm wrote:
> > Broken out nid_zone_sizes_init() change from i386 NUMA emulation code.
> ...
> > -static inline unsigned long  nid_size_pages(int nid)
> > -{
> > -     return node_end_pfn[nid] - node_start_pfn[nid];
> > -}
> > -static inline int nid_starts_in_highmem(int nid)
> > -{
> > -     return node_start_pfn[nid] >= max_low_pfn;
> > -}
>
> Hey, I liked those helpers!

Well, too bad for you! ;)

> When I suggested that you make your patches apply on top of the existing
> -mhp stuff, I didn't just mean that they should _apply_, they should
> probably mesh a little bit better.  For instance, it would be very
> helpful to use those 'static inlines', or make a couple new ones if you
> need them.

Okey, I think I understand. And I agree that more effort could be put
into this to make the code look better.  I thought this change was
required for the NUMA emulation code, but it turns out it wasn't. I
guess keeping the code as is and ignoring the patch is probably the
best solution.

Thanks!

/ magnus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2005-10-06 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-05  8:35 [PATCH] i386: nid_zone_sizes_init() update Magnus Damm
2005-10-05 15:10 ` Martin J. Bligh
2005-10-05 16:25   ` Dave Hansen
2005-10-05 16:12 ` Dave Hansen
2005-10-06 10:38   ` Magnus Damm

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