Skip to contentSkip to conversation

2.6.18-rc6-mm2: fix for error compiling ppc/mm/init.c

PATCH Judith Lebzelter 5 participants 12 messages Sep 14, 2006 – Oct 9, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

Hello,

For ppc in our cross-compile build farm (PLM), there is an error compiling file ppc/mm/init.c:

CC arch/ppc/mm/init.o
CC arch/powerpc/kernel/init_task.o
arch/ppc/mm/init.c: In function 'paging_init':
arch/ppc/mm/init.c:381: error: subscripted value is neither array nor pointer arch/ppc/mm/init.c:383: warning: passing argument 1 of '/' makes pointer from integer without a cast make[1]: [arch/ppc/mm/init.o] Error 1 (ignored)

This is caused by an error/oversight in file 'have-power-use-add_active_range-and-free_area_init_nodes.patch'

Here is a patch to fix that patch.

Thanks;
Judith Lebzelter
OSDL

ppc/mm/init.c renamed from ppc/mm/init.c.old +1 -1
@@ -359,7 +359,7 @@
 void __init paging_init(void)
 {
 	unsigned long start_pfn, end_pfn;
-	unsigned long max_zone_pfns;
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
 #ifdef CONFIG_HIGHMEM
 	map_page(PKMAP_BASE, 0, 0);	/* XXX gross */
 	pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k
Acked-by
#1 lore raw
Quoted 11 lines · Judith Lebzelter

For ppc in our cross-compile build farm (PLM), there is an error compiling file ppc/mm/init.c:

CC arch/ppc/mm/init.o
CC arch/powerpc/kernel/init_task.o
arch/ppc/mm/init.c: In function 'paging_init':
arch/ppc/mm/init.c:381: error: subscripted value is neither array nor pointer arch/ppc/mm/init.c:383: warning: passing argument 1 of '/' makes pointer from integer without a cast make[1]: [arch/ppc/mm/init.o] Error 1 (ignored)

Quoted 5 lines

This is caused by an error/oversight in file 'have-power-use-add_active_range-and-free_area_init_nodes.patch'

Here is a patch to fix that patch.

Looks good. Thanks

Quoted 17 lines

Thanks;
Judith Lebzelter
OSDL

ppc/mm/init.c renamed from ppc/mm/init.c.old +1 -1
@@ -359,7 +359,7 @@
 void __init paging_init(void)
 {
 	unsigned long start_pfn, end_pfn;
-	unsigned long max_zone_pfns;
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
 #ifdef CONFIG_HIGHMEM
 	map_page(PKMAP_BASE, 0, 0);	/* XXX gross */
 	pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k
Signature · 3 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab
#2 lore raw
Quoted 16 lines · Mel Gorman
Quoted 14 lines · Judith Lebzelter

For ppc in our cross-compile build farm (PLM), there is an error compiling file ppc/mm/init.c:

CC arch/ppc/mm/init.o
CC arch/powerpc/kernel/init_task.o
arch/ppc/mm/init.c: In function 'paging_init':
arch/ppc/mm/init.c:381: error: subscripted value is neither array nor pointer arch/ppc/mm/init.c:383: warning: passing argument 1 of '/' makes pointer from integer without a cast make[1]: [arch/ppc/mm/init.o] Error 1 (ignored)

This is caused by an error/oversight in file 'have-power-use-add_active_range-and-free_area_init_nodes.patch'

Quoted 6 lines
Quoted 2 lines

Here is a patch to fix that patch.

Looks good. Thanks

Note that the whole ppc patch here seems broken. Sorry for not jumping earlier, I've been swamped with other things.

First, why the heck do you use indices 0 and 1 explicitely rather than the symbolic constants ? ppc doesn't have a ZONE_NORMAL, so we should be filling ZONE_DMA and ZONE_HIGHMEM but you end up filling ZONE_DMA and ZONE_NORMAL and leave ZONE_HIGHMEM alone. Also, you leave other entries filled with crap (the array isn't initialized) which cause some strange display of the PFN list, if not worse problems later, I don't know for sure at this stage.

I've about to run some tests with this patch. Looks like we need give a closer look at those patches, in case that breakage appears on other archs as well (or similar).
---

New zone initialisation on powerpc is broken, especially with CONFIG_HIGHMEM, this fixes it by initializing the array to 0 and filling up the right entries.

arch/powerpc/mm/mem.c +4 -3
Index: linux-work/arch/powerpc/mm/mem.c
===================================================================
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }
#3 lore raw
Quoted 22 lines · Benjamin Herrenschmidt
Quoted 21 lines · Mel Gorman
Quoted 11 lines · Judith Lebzelter

For ppc in our cross-compile build farm (PLM), there is an error compiling file ppc/mm/init.c:

CC arch/ppc/mm/init.o
CC arch/powerpc/kernel/init_task.o
arch/ppc/mm/init.c: In function 'paging_init':
arch/ppc/mm/init.c:381: error: subscripted value is neither array nor pointer arch/ppc/mm/init.c:383: warning: passing argument 1 of '/' makes pointer from integer without a cast make[1]: [arch/ppc/mm/init.o] Error 1 (ignored)

Quoted 5 lines

This is caused by an error/oversight in file 'have-power-use-add_active_range-and-free_area_init_nodes.patch'

Here is a patch to fix that patch.

Looks good. Thanks

Quoted 7 lines
Quoted 1 line

Note that the whole ppc patch here seems broken. Sorry for not jumping earlier, I've been swamped with other things.

First, why the heck do you use indices 0 and 1 explicitely rather than the symbolic constants ?

Because in the -mm kernel the patches were rolled against, ZONE_DMA was optional and MAX_NR_ZONES could change which led to this confusion. It is wrong and thanks for catching it. However, this is a a fairly small part of the whole patch, is it an exaggeration to call the whole patch broken?

On a semi-related (but not very important) note, why does PPC use ZONE_DMA as it's lowest zone and not ZONE_NORMAL? I currently view zones as meaning;

ZONE_DMA - The physical range of memory usable by a subset of devices
available on the target platform (usually considered to be ISA devices). It is mapped into the kernel
virtual address space

ZONE_DMA32 - The physical range of memory usable by 32 bit devices on 64
bit platforms. It is mapped into the kernel virtual address space

ZONE_NORMAL - The physical range of memory excluding the lower
zones directly mapped into the kernel virtual address space.

ZONE_HIGHMEM - The higher physical address spaces not permanently mapped
into the kernel virtual address space

This is not 100% bullet-proof definition. For example, memmap can be allocated from highmem and placed in the kernel virtual address space. But by the definitions above, ppc would have no ZONE_DMA, only ZONE_NORMAL and ZONE_HIGHMEM. Was ZONE_DMA used for any particular reason?

Quoted 7 lines

ppc doesn't have a ZONE_NORMAL, so we should be
filling ZONE_DMA and ZONE_HIGHMEM but you end up filling ZONE_DMA and ZONE_NORMAL and leave ZONE_HIGHMEM alone. Also, you leave other entries filled with crap (the array isn't initialized) which cause some strange display of the PFN list, if not worse problems later, I don't know for sure at this stage.

By the PFN list, I assume you mean the dmesg entry that starts with "Zone PFN ranges:". If that is messed up, it is bad, but it should still boot albeit with memory in the wrong zones.

Quoted 1 line

I've about to run some tests with this patch.

I made a minor comment on your patch below.

Quoted 3 lines

Looks like we need give a
closer look at those patches, in case that breakage appears on other archs as well (or similar).

I looked through the other patches for similar breakage. On x86, max_zone_pfns is initialised as;

# x86 init
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
+               max_low_pfn,
+               highend_pfn
+       };

as it does not have ZONE_DMA32, I believe it's ok. On x86_64, I used

# x86_64 init
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
+                                                       MAX_DMA32_PFN,
+                                                       end_pfn};

This should be ok because x86_64 uses ZONE_NORMAL as the highest zone.

On ia64, there is

# ia64
+       max_zone_pfns[ZONE_DMA] = max_dma;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;

That should also be ok because it doesn't use HIGHMEM.

How do they look to you?

Quoted 13 lines

---

New zone initialisation on powerpc is broken, especially with CONFIG_HIGHMEM, this fixes it by initializing the array to 0 and filling up the right entries.

Index: linux-work/arch/powerpc/mm/mem.c
===================================================================

arch/powerpc/mm/mem.c void __init paging_init(void) · line 312

Quoted 8 lines
arch/powerpc/mm/mem.c +2 -2
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;

Add

max_zone_pfns[ZONE_NORMAL] = total_lowmem >> PAGE_SHIFT;

The effect will be that ZONE_NORMAL will be initialised as empty.

Quoted 10 lines
arch/powerpc/mm/mem.c +2 -1
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }
Signature · 3 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab
#4 lore raw
Quoted 5 lines

Because in the -mm kernel the patches were rolled against, ZONE_DMA was optional and MAX_NR_ZONES could change which led to this confusion. It is wrong and thanks for catching it. However, this is a a fairly small part of the whole patch, is it an exaggeration to call the whole patch broken?

Well, that and the partially uninitialized array, that comprises most of the ppc patch :) I wasn't talking about the other patches forming your patch set, mostly the whole PPC... the lack of usage of symbolic constants looked pretty bad to me, I didn't know there were those other -mm related constraints.

Quoted 3 lines

On a semi-related (but not very important) note, why does PPC use ZONE_DMA as it's lowest zone and not ZONE_NORMAL? I currently view zones as meaning;

History... A lot of driver used to request memory in ZONE_DMA "just in case" (the SCSI subsystem for example). Not having one meant that those drivers or subsystem would just not work on powerpc. I don't know if they have all been fixed, but if that's the case, then we can move everything to ZONE_NORMAL.

Quoted 2 lines

ZONE_DMA32 - The physical range of memory usable by 32 bit devices on 64
bit platforms. It is mapped into the kernel virtual address space

We haven't done a ZONE_DMA32 for now. Currently, all supported 64 bits implementations have an iommu that makes this unnecessary, though the thread of having to deal with an implementation without one is getting more and more precise, so we may have to add it.

Quoted 4 lines

This is not 100% bullet-proof definition. For example, memmap can be allocated from highmem and placed in the kernel virtual address space. But by the definitions above, ppc would have no ZONE_DMA, only ZONE_NORMAL and ZONE_HIGHMEM. Was ZONE_DMA used for any particular reason?

As explained above. Is that a problem ?

Quoted 3 lines

By the PFN list, I assume you mean the dmesg entry that starts with "Zone PFN ranges:". If that is messed up, it is bad, but it should still boot albeit with memory in the wrong zones.

It was messed up with ZONE_DMA 0 -> xxx where xxx was my actual max_pfn, and ZONE_NORMAL from xxx -> yyy where yyy was a random very big number. That was with CONFIG_HIGHMEM off and it did boot. It didn't with CONFIG_HIGHMEM on as the high memory was being put in ZONE_NORMAL and ZONE_HIGHMEM left uninitialized.

Quoted 18 lines
Quoted 1 line

I've about to run some tests with this patch.

I made a minor comment on your patch below.

Quoted 3 lines

Looks like we need give a
closer look at those patches, in case that breakage appears on other archs as well (or similar).

I looked through the other patches for similar breakage. On x86, max_zone_pfns is initialised as;

# x86 init
(quoted diff) +5 -0
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
+               max_low_pfn,
+               highend_pfn
+       };
Quoted 1 line

as it does not have ZONE_DMA32, I believe it's ok. On x86_64, I used

I would much prefer to use explicit array index initializers... but ok.

Quoted 6 lines
# x86_64 init
(quoted diff) +3 -0
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
+                                                       MAX_DMA32_PFN,
+                                                       end_pfn};

This should be ok because x86_64 uses ZONE_NORMAL as the highest zone.

Same comment.

Quoted 9 lines

On ia64, there is

# ia64
(quoted diff) +2 -0
+       max_zone_pfns[ZONE_DMA] = max_dma;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;

That should also be ok because it doesn't use HIGHMEM.

How do they look to you?

I suppose they are ok. I dislike this CONFIG_* variation of the definition of the ZONE_* constants, it's error prone though.

Quoted 24 lines
Quoted 13 lines

---

New zone initialisation on powerpc is broken, especially with CONFIG_HIGHMEM, this fixes it by initializing the array to 0 and filling up the right entries.

Index: linux-work/arch/powerpc/mm/mem.c
===================================================================

arch/powerpc/mm/mem.c void __init paging_init(void) · line 312

Quoted 8 lines
arch/powerpc/mm/mem.c +2 -2
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;

Add

Quoted 3 lines

max_zone_pfns[ZONE_NORMAL] = total_lowmem >> PAGE_SHIFT;

The effect will be that ZONE_NORMAL will be initialised as empty.

Ok, but what happens with the patch code where it's 0 ? I much prefer, in general, initializing an array to 0, and then only fill the entries that matter. This avoids the problem of the ZONE_* constants floating around (or adding a new one or whatever). It might make sense to have the generic code handle that instead...

Cheers,
Ben.

#5 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines

Because in the -mm kernel the patches were rolled against, ZONE_DMA was optional and MAX_NR_ZONES could change which led to this confusion. It is wrong and thanks for catching it. However, this is a a fairly small part of the whole patch, is it an exaggeration to call the whole patch broken?

Well, that and the partially uninitialized array, that comprises most of the ppc patch :)

ok, that's a fair enough point :) .

Quoted 3 lines

I wasn't talking about the other patches forming your patch set, mostly the whole PPC... the lack of usage of symbolic constants looked pretty bad to me

Once we have a patch using symbolic names working on ppc, I'll make a patch that uses symbolic names on the other architectures and post it.

Quoted 7 lines

, I didn't know there were those other
-mm related constraints.

Quoted 3 lines

On a semi-related (but not very important) note, why does PPC use ZONE_DMA as it's lowest zone and not ZONE_NORMAL? I currently view zones as meaning;

Quoted 6 lines

History... A lot of driver used to request memory in ZONE_DMA "just in case" (the SCSI subsystem for example). Not having one meant that those drivers or subsystem would just not work on powerpc. I don't know if they have all been fixed, but if that's the case, then we can move everything to ZONE_NORMAL.

I don't know if it has been fixed either.

Quoted 8 lines
Quoted 2 lines

ZONE_DMA32 - The physical range of memory usable by 32 bit devices on 64
bit platforms. It is mapped into the kernel virtual address space

We haven't done a ZONE_DMA32 for now. Currently, all supported 64 bits implementations have an iommu that makes this unnecessary, though the thread of having to deal with an implementation without one is getting more and more precise, so we may have to add it.

Quoted 7 lines
Quoted 4 lines

This is not 100% bullet-proof definition. For example, memmap can be allocated from highmem and placed in the kernel virtual address space. But by the definitions above, ppc would have no ZONE_DMA, only ZONE_NORMAL and ZONE_HIGHMEM. Was ZONE_DMA used for any particular reason?

As explained above. Is that a problem ?

No, it's not. It was out of curiousity more than anything else. I need to update my definition of ZONE_DMA slightly, that's all.

Quoted 10 lines
Quoted 3 lines

By the PFN list, I assume you mean the dmesg entry that starts with "Zone PFN ranges:". If that is messed up, it is bad, but it should still boot albeit with memory in the wrong zones.

It was messed up with ZONE_DMA 0 -> xxx where xxx was my actual max_pfn, and ZONE_NORMAL from xxx -> yyy where yyy was a random very big number. That was with CONFIG_HIGHMEM off and it did boot. It didn't with CONFIG_HIGHMEM on as the high memory was being put in ZONE_NORMAL and ZONE_HIGHMEM left uninitialized.

ok, the problem is pretty clear at least.

Quoted 18 lines
Quoted 18 lines
Quoted 1 line

I've about to run some tests with this patch.

I made a minor comment on your patch below.

Quoted 3 lines

Looks like we need give a
closer look at those patches, in case that breakage appears on other archs as well (or similar).

I looked through the other patches for similar breakage. On x86, max_zone_pfns is initialised as;

# x86 init
(quoted diff) +5 -0
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
+               max_low_pfn,
+               highend_pfn
+       };
Quoted 4 lines
Quoted 1 line

as it does not have ZONE_DMA32, I believe it's ok. On x86_64, I used

I would much prefer to use explicit array index initializers... but ok.

Once we get ppc sorted, I'll make a patch that uses explicit array initialisation and symbolic index names on the other arches.

Quoted 15 lines
Quoted 6 lines
# x86_64 init
(quoted diff) +3 -0
+       unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
+                                                       MAX_DMA32_PFN,
+                                                       end_pfn};

This should be ok because x86_64 uses ZONE_NORMAL as the highest zone.

Same comment.

Quoted 6 lines

On ia64, there is

# ia64
(quoted diff) +2 -0
+       max_zone_pfns[ZONE_DMA] = max_dma;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
Quoted 7 lines
Quoted 3 lines

That should also be ok because it doesn't use HIGHMEM.

How do they look to you?

I suppose they are ok. I dislike this CONFIG_* variation of the definition of the ZONE_* constants, it's error prone though.

I believe it was to stop having more empty zones than was really necessary. It was a saving on NUMA. I might be wrong, I'll need to check the archives again.

Quoted 24 lines
Quoted 24 lines
Quoted 13 lines

---

New zone initialisation on powerpc is broken, especially with CONFIG_HIGHMEM, this fixes it by initializing the array to 0 and filling up the right entries.

Index: linux-work/arch/powerpc/mm/mem.c
===================================================================

arch/powerpc/mm/mem.c void __init paging_init(void) · line 312

Quoted 8 lines
arch/powerpc/mm/mem.c +2 -2
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;

Add

Quoted 5 lines
Quoted 3 lines

max_zone_pfns[ZONE_NORMAL] = total_lowmem >> PAGE_SHIFT;

The effect will be that ZONE_NORMAL will be initialised as empty.

Ok, but what happens with the patch code where it's 0 ?

Ah (wipes egg off face). In free_area_init_nodes(), it will be set to (total_lowmem >> PAGE_SHIFT) by this;

+ arch_zone_lowest_possible_pfn[i] =
+ arch_zone_highest_possible_pfn[i-1];
+ arch_zone_highest_possible_pfn[i] =
+ max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]);

so you can leave it as 0.

Quoted 6 lines

I much prefer,
in general, initializing an array to 0, and then only fill the entries that matter. This avoids the problem of the ZONE_* constants floating around (or adding a new one or whatever). It might make sense to have the generic code handle that instead...

You're right. The generic code does handle this case because at one point, I remembered clearly that not all zones would be in use :/

Signature · 3 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab
#6 lore raw
Quoted 3 lines

Once we have a patch using symbolic names working on ppc, I'll make a patch that uses symbolic names on the other architectures and post it.

Ok, good :) I don't like magic numbers

Quoted 1 line

I don't know if it has been fixed either.

Yeah... I'm not in a mood to audit all of that for 2.6.19, so I'd rather keep it the way it is for now.

Quoted 2 lines

Once we get ppc sorted, I'll make a patch that uses explicit array initialisation and symbolic index names on the other arches.

Ok. Any reason why my current patch wouldn't be good then ? If it's ok for you, I'll put it in paulus queue for merging.

Quoted 3 lines

I believe it was to stop having more empty zones than was really necessary. It was a saving on NUMA. I might be wrong, I'll need to check the archives again.

Well, as long as we use named indices in the array and make sure it's properly initialized to 0, that should be ok.

Quoted 2 lines

You're right. The generic code does handle this case because at one point, I remembered clearly that not all zones would be in use :/

Good then :)

Cheers,
Ben.

#7 lore raw
Quoted 6 lines
Quoted 3 lines

Once we have a patch using symbolic names working on ppc, I'll make a patch that uses symbolic names on the other architectures and post it.

Ok, good :) I don't like magic numbers

Yep, they can really kick you in the pants.

Quoted 5 lines
Quoted 1 line

I don't know if it has been fixed either.

Yeah... I'm not in a mood to audit all of that for 2.6.19, so I'd rather keep it the way it is for now.

Fully agreed. It would not be an easy job and doesn't win anything until there is a 100%-agreed-by-everybody definition of what ZONE_DMA is.

Quoted 6 lines
Quoted 2 lines

Once we get ppc sorted, I'll make a patch that uses explicit array initialisation and symbolic index names on the other arches.

Ok. Any reason why my current patch wouldn't be good then ? If it's ok for you, I'll put it in paulus queue for merging.

Your patch may be incomplete for ppc and ppc64. I've included a patch below which I'm currently testing. It's a superset of yours with changes to arch/powerpc/mm/numa.c, arch/powerpc/mm/mem.c and arch/ppc/mm/init.c as well as the other arches to use symbolic names. I can split the patch per-arch if you want to take the power-related patches seperatly. Can you look through it please?

It's currently being tested on the machines I have but I do not access to a ppc that needs ZONE_HIGHMEM :(

Quoted 7 lines
Quoted 2 lines

I believe it was to stop having more empty zones than was really necessary. It was a saving on NUMA. I might be wrong, I'll need to check

the archives again.

Well, as long as we use named indices in the array and make sure it's properly initialized to 0, that should be ok.

I think I have that.

Quoted 5 lines
Quoted 2 lines

You're right. The generic code does handle this case because at one point, I remembered clearly that not all zones would be in use :/

Good then :)

arch/i386/kernel/setup.c +6 -7
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/kernel/setup.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/kernel/setup.c
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn,
-			highend_pfn};
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 	add_active_range(0, 0, highend_pfn);
 #else
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn};
 	add_active_range(0, 0, max_low_pfn);
 #endif
 
arch/i386/mm/discontig.c +6 -5
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/mm/discontig.c
@@ -357,11 +357,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
 	int nid;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-		max_low_pfn,
-		highend_pfn
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
 	/* If SRAT has not registered memory, register it now */
 	if (find_max_pfn_with_active_regions() == 0) {
arch/ia64/mm/contig.c +1 -0
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/contig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/contig.c
@@ -233,6 +233,7 @@ paging_init (void)
 	efi_memmap_walk(count_pages, &num_physpages);
 
 	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 
arch/ia64/mm/discontig.c +1 -0
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/discontig.c
@@ -709,6 +709,7 @@ void __init paging_init(void)
 			max_pfn = mem_data[node].max_pfn;
 	}
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_pfn;
 	free_area_init_nodes(max_zone_pfns);
arch/powerpc/mm/mem.c +4 -3
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/mem.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/mem.c
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }
arch/powerpc/mm/numa.c +3 -3
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/numa.c
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
 
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-				lmb_end_of_DRAM() >> PAGE_SHIFT
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
 	free_area_init_nodes(max_zone_pfns);
 }
 
arch/ppc/mm/init.c +4 -3
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ppc/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ppc/mm/init.c
@@ -374,11 +374,12 @@ void __init paging_init(void)
 	end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
 	add_active_range(0, start_pfn, end_pfn);
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
 #endif /* CONFIG_HIGHMEM */
 	free_area_init_nodes(max_zone_pfns);
 }
arch/x86_64/mm/init.c +6 -3
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/init.c
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
 #ifndef CONFIG_NUMA
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
-							MAX_DMA32_PFN,
-							end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
+
 	memory_present(0, 0, end_pfn);
 	sparse_init();
 	free_area_init_nodes(max_zone_pfns);
arch/x86_64/mm/numa.c +5 -3
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/numa.c
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void
 void __init paging_init(void)
 { 
 	int i;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
-		MAX_DMA32_PFN,
-		end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
 
 	arch_sparse_init();
 
#8 lore raw

Patch looks good on a quick look. I will try to test later today at which point, it should go in asap, current upstream doesn't boot on CONFIG_HIGHMEM powerpc, which is a lot of them...

Ben.

Quoted 166 lines

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/kernel/setup.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/kernel/setup.c

arch/i386/kernel/setup.c +6 -7
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn,
-			highend_pfn};
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 	add_active_range(0, 0, highend_pfn);
 #else
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn};
 	add_active_range(0, 0, max_low_pfn);
 #endif
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/mm/discontig.c

arch/i386/mm/discontig.c +6 -5
@@ -357,11 +357,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
 	int nid;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-		max_low_pfn,
-		highend_pfn
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
 	/* If SRAT has not registered memory, register it now */
 	if (find_max_pfn_with_active_regions() == 0) {

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/contig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/contig.c

arch/ia64/mm/contig.c +1 -0
@@ -233,6 +233,7 @@ paging_init (void)
 	efi_memmap_walk(count_pages, &num_physpages);
 
 	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/discontig.c

arch/ia64/mm/discontig.c +1 -0
@@ -709,6 +709,7 @@ void __init paging_init(void)
 			max_pfn = mem_data[node].max_pfn;
 	}
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_pfn;
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/mem.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/mem.c

arch/powerpc/mm/mem.c +4 -3
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/numa.c

arch/powerpc/mm/numa.c +3 -3
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
 
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-				lmb_end_of_DRAM() >> PAGE_SHIFT
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
 	free_area_init_nodes(max_zone_pfns);
 }
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ppc/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ppc/mm/init.c

arch/ppc/mm/init.c +4 -3
@@ -374,11 +374,12 @@ void __init paging_init(void)
 	end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
 	add_active_range(0, start_pfn, end_pfn);
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
 #endif /* CONFIG_HIGHMEM */
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/init.c

arch/x86_64/mm/init.c +6 -3
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
 #ifndef CONFIG_NUMA
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
-							MAX_DMA32_PFN,
-							end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
+
 	memory_present(0, 0, end_pfn);
 	sparse_init();
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/numa.c

arch/x86_64/mm/numa.c +5 -4
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void
 void __init paging_init(void)
 { 
 	int i;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
-		MAX_DMA32_PFN,
-		end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
 
 	arch_sparse_init();
 
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw
Quoted 5 lines · Benjamin Herrenschmidt

Patch looks good on a quick look. I will try to test later today at which point, it should go in asap, current upstream doesn't boot on CONFIG_HIGHMEM powerpc, which is a lot of them...

The patch has passed tests here on x86, x86_64, ia64 and ppc64. Testing on powerpc with HIGHMEM is a configuration I cannot test. If you say it passes, I'll see can I get it pushed before 2.6.19-rc1

Thanks

Quoted 161 lines
Quoted 161 lines

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/kernel/setup.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/kernel/setup.c

arch/i386/kernel/setup.c +6 -7
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn,
-			highend_pfn};
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 	add_active_range(0, 0, highend_pfn);
 #else
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn};
 	add_active_range(0, 0, max_low_pfn);
 #endif
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/mm/discontig.c

arch/i386/mm/discontig.c +6 -5
@@ -357,11 +357,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
 	int nid;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-		max_low_pfn,
-		highend_pfn
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
 	/* If SRAT has not registered memory, register it now */
 	if (find_max_pfn_with_active_regions() == 0) {

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/contig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/contig.c

arch/ia64/mm/contig.c +1 -0
@@ -233,6 +233,7 @@ paging_init (void)
 	efi_memmap_walk(count_pages, &num_physpages);
 
 	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/discontig.c

arch/ia64/mm/discontig.c +1 -0
@@ -709,6 +709,7 @@ void __init paging_init(void)
 			max_pfn = mem_data[node].max_pfn;
 	}
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_pfn;
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/mem.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/mem.c

arch/powerpc/mm/mem.c +4 -3
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/numa.c

arch/powerpc/mm/numa.c +3 -3
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
 
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-				lmb_end_of_DRAM() >> PAGE_SHIFT
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
 	free_area_init_nodes(max_zone_pfns);
 }
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ppc/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ppc/mm/init.c

arch/ppc/mm/init.c +4 -3
@@ -374,11 +374,12 @@ void __init paging_init(void)
 	end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
 	add_active_range(0, start_pfn, end_pfn);
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
 #endif /* CONFIG_HIGHMEM */
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/init.c

arch/x86_64/mm/init.c +6 -3
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
 #ifndef CONFIG_NUMA
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
-							MAX_DMA32_PFN,
-							end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
+
 	memory_present(0, 0, end_pfn);
 	sparse_init();
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/numa.c

arch/x86_64/mm/numa.c +5 -3
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void
 void __init paging_init(void)
 {
 	int i;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
-		MAX_DMA32_PFN,
-		end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
 
 	arch_sparse_init();
 
Signature · 3 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab
#10 lore raw
Quoted 11 lines · Mel Gorman
Quoted 5 lines · Benjamin Herrenschmidt

Patch looks good on a quick look. I will try to test later today at which point, it should go in asap, current upstream doesn't boot on CONFIG_HIGHMEM powerpc, which is a lot of them...

The patch has passed tests here on x86, x86_64, ia64 and ppc64. Testing on powerpc with HIGHMEM is a configuration I cannot test. If you say it passes, I'll see can I get it pushed before 2.6.19-rc1

Too late for rc1 :( I'll ask Johannes to test as I don't have access to the box atm.

Thanks.
Ben.

Quoted 164 lines

Thanks

Quoted 161 lines
Quoted 161 lines

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/kernel/setup.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/kernel/setup.c

arch/i386/kernel/setup.c +6 -7
@@ -1083,16 +1083,15 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 #ifdef CONFIG_HIGHMEM
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn,
-			highend_pfn};
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 	add_active_range(0, 0, highend_pfn);
 #else
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-			virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-			max_low_pfn};
 	add_active_range(0, 0, max_low_pfn);
 #endif
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/i386/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/i386/mm/discontig.c

arch/i386/mm/discontig.c +6 -5
@@ -357,11 +357,12 @@ void __init numa_kva_reserve(void)
 void __init zone_sizes_init(void)
 {
 	int nid;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
-		max_low_pfn,
-		highend_pfn
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] =
+		virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+	max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
 
 	/* If SRAT has not registered memory, register it now */
 	if (find_max_pfn_with_active_regions() == 0) {

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/contig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/contig.c

arch/ia64/mm/contig.c +1 -0
@@ -233,6 +233,7 @@ paging_init (void)
 	efi_memmap_walk(count_pages, &num_physpages);
 
 	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ia64/mm/discontig.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ia64/mm/discontig.c

arch/ia64/mm/discontig.c +1 -0
@@ -709,6 +709,7 @@ void __init paging_init(void)
 			max_pfn = mem_data[node].max_pfn;
 	}
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 	max_zone_pfns[ZONE_DMA] = max_dma;
 	max_zone_pfns[ZONE_NORMAL] = max_pfn;
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/mem.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/mem.c

arch/powerpc/mm/mem.c +4 -3
@@ -307,11 +307,12 @@ void __init paging_init(void)
 	       top_of_ram, total_ram);
 	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = top_of_ram >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
 #endif
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/powerpc/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/powerpc/mm/numa.c

arch/powerpc/mm/numa.c +3 -3
@@ -617,9 +617,9 @@ void __init do_init_bootmem(void)
 
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-				lmb_end_of_DRAM() >> PAGE_SHIFT
-	};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT;
 	free_area_init_nodes(max_zone_pfns);
 }
 

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/ppc/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/ppc/mm/init.c

arch/ppc/mm/init.c +4 -3
@@ -374,11 +374,12 @@ void __init paging_init(void)
 	end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
 	add_active_range(0, start_pfn, end_pfn);
 
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_HIGHMEM
-	max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
-	max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_HIGHMEM] = total_memory >> PAGE_SHIFT;
 #else
-	max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
+	max_zone_pfns[ZONE_DMA] = total_memory >> PAGE_SHIFT;
 #endif /* CONFIG_HIGHMEM */
 	free_area_init_nodes(max_zone_pfns);
 }

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/init.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/init.c

arch/x86_64/mm/init.c +6 -3
@@ -406,9 +406,12 @@ void __cpuinit zap_low_mappings(int cpu)
 #ifndef CONFIG_NUMA
 void __init paging_init(void)
 {
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
-							MAX_DMA32_PFN,
-							end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
+
 	memory_present(0, 0, end_pfn);
 	sparse_init();
 	free_area_init_nodes(max_zone_pfns);

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.18-git19-clean/arch/x86_64/mm/numa.c linux-2.6.18-git19-use_zone_symbolic_names/arch/x86_64/mm/numa.c

arch/x86_64/mm/numa.c +5 -3
@@ -338,9 +338,11 @@ static void __init arch_sparse_init(void
 void __init paging_init(void)
 {
 	int i;
-	unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
-		MAX_DMA32_PFN,
-		end_pfn};
+	unsigned long max_zone_pfns[MAX_NR_ZONES];
+	memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+	max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
+	max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+	max_zone_pfns[ZONE_NORMAL] = end_pfn;
 
 	arch_sparse_init();
 
#11 lore raw
In reply to Mel Gorman
Quoted 3 lines · Mel Gorman

The patch has passed tests here on x86, x86_64, ia64 and ppc64. Testing on powerpc with HIGHMEM is a configuration I cannot test. If you say it passes, I'll see can I get it pushed before 2.6.19-rc1

Seems fine on my powerbook with 1G of RAM, with 768M lowmem and 256M highmem.

Paul.