Skip to contentSkip to conversation

no per-arch mem_map init

RFC PATCH In review Dave Hansen 3 participants 6 messages Feb 8, 2005 – Feb 9, 2005

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 no per-arch mem_map init

This patch has been one of the base patches in the -mhp tree for a bit now, and seems to be working pretty well, at least on x86. I would like to submit it upstream, but I want to get a bit more testing first. Is there a chance you ia64 guys could give it a quick test boot to make sure that it doesn't screw you over?

-- Dave

So, this patch started out with me trying to keep from passing contiguous, node-specific mem_map into free_area_init_node() and cousins. Instead, I relied on some calls to pfn_to_page().

This works fine and dandy when all you need is the pgdat->node_mem_map to do pfn_to_page(). However, the non-NUMA/DISCONTIG architectures use the real, global mem_map[] instead of a node_mem_map in the pfn_to_page() calculation. So, I ended up effectively trying to initialize mem_map from itself, when it was NULL. That was bad, and caused some very pretty colors on someone's screen when he tested it.

So, I had to make sure to initialize the global mem_map[] before calling into free_area_init_node(). Then, I realized how many architectures do this on their own, and have comments like this:

        /* XXX: MRB-remove - this doesn't seem sane, should this be done somewhere else ?*/
        mem_map = NODE_DATA(0)->node_mem_map;

The following patch does what my first one did (don't pass mem_map into the init functions), incorporates Jesse Barnes' ia64 fixes on top of that, and gets rid of all but one of the global mem_map initializations (parisc is weird). It also magically removes more code than it adds. It could be smaller, but I shamelessly added some comments.

Boot-tested on ppc64, i386 (NUMAQ, plain SMP, laptop), UML (i386).

---

 memhotplug-dave/arch/arm/mm/init.c           |    4 ----
 memhotplug-dave/arch/arm26/mm/init.c         |    2 --
 memhotplug-dave/arch/cris/arch-v10/mm/init.c |    1 -
 memhotplug-dave/arch/ia64/mm/contig.c        |    2 +-
 memhotplug-dave/arch/m32r/mm/init.c          |    2 --
 memhotplug-dave/arch/ppc64/mm/init.c         |    1 -
 memhotplug-dave/arch/sh/mm/init.c            |    2 --
 memhotplug-dave/arch/sh64/mm/init.c          |    3 ---
 memhotplug-dave/arch/sparc/mm/srmmu.c        |    1 -
 memhotplug-dave/arch/sparc/mm/sun4c.c        |    1 -
 memhotplug-dave/arch/sparc64/mm/init.c       |    1 -
 memhotplug-dave/arch/um/kernel/physmem.c     |    1 -
 memhotplug-dave/arch/v850/kernel/setup.c     |    1 -
 memhotplug-dave/mm/page_alloc.c              |   18 ++++++++++++++----
 14 files changed, 15 insertions(+), 25 deletions(-)
arch/arm/mm/init.c renamed from arch/arm/mm/init.c~A6-no_arch_mem_map_init +0 -4
diff -puN arch/arm/mm/init.c~A6-no_arch_mem_map_init arch/arm/mm/init.c
@@ -501,10 +501,6 @@ void __init paging_init(struct meminfo *
 				bdata->node_boot_start >> PAGE_SHIFT, zhole_size);
 	}
 
-#ifndef CONFIG_DISCONTIGMEM
-	mem_map = contig_page_data.node_mem_map;
-#endif
-
 	/*
 	 * finish off the bad pages once
 	 * the mem_map is initialised
arch/arm26/mm/init.c renamed from arch/arm26/mm/init.c~A6-no_arch_mem_map_init +0 -2
diff -puN arch/arm26/mm/init.c~A6-no_arch_mem_map_init arch/arm26/mm/init.c
@@ -309,8 +309,6 @@ void __init paging_init(struct meminfo *
 	free_area_init_node(0, pgdat, zone_size,
 			bdata->node_boot_start >> PAGE_SHIFT, zhole_size);
 
-	mem_map = NODE_DATA(0)->node_mem_map;
-
 	/*
 	 * finish off the bad pages once
 	 * the mem_map is initialised
arch/cris/arch-v10/mm/init.c renamed from arch/cris/arch-v10/mm/init.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/cris/arch-v10/mm/init.c~A6-no_arch_mem_map_init arch/cris/arch-v10/mm/init.c
@@ -184,7 +184,6 @@ paging_init(void)
 	 */
 
 	free_area_init_node(0, &contig_page_data, zones_size, PAGE_OFFSET >> PAGE_SHIFT, 0);
-	mem_map = contig_page_data.node_mem_map;
 }
 
 /* Initialize remaps of some I/O-ports. It is important that this

diff -puN arch/i386/mm/discontig.c~A6-no_arch_mem_map_init arch/i386/mm/discontig.c

arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +1 -1
diff -puN arch/ia64/mm/contig.c~A6-no_arch_mem_map_init arch/ia64/mm/contig.c
@@ -280,7 +280,7 @@ paging_init (void)
 		vmem_map = (struct page *) vmalloc_end;
 		efi_memmap_walk(create_mem_map_page_table, NULL);
 
-		mem_map = contig_page_data.node_mem_map = vmem_map;
+		NODE_DATA(0)->node_mem_map = vmem_map;
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    0, zholes_size);
 
arch/ppc64/mm/init.c renamed from arch/ppc64/mm/init.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/ppc64/mm/init.c~A6-no_arch_mem_map_init arch/ppc64/mm/init.c
@@ -659,7 +659,6 @@ void __init paging_init(void)
 
 	free_area_init_node(0, &contig_page_data, zones_size,
 			    __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
-	mem_map = contig_page_data.node_mem_map;
 }
 #endif /* CONFIG_DISCONTIGMEM */
 
arch/sh/mm/init.c renamed from arch/sh/mm/init.c~A6-no_arch_mem_map_init +0 -2
diff -puN arch/sh/mm/init.c~A6-no_arch_mem_map_init arch/sh/mm/init.c
@@ -216,8 +216,6 @@ void __init paging_init(void)
 #endif
 	NODE_DATA(0)->node_mem_map = NULL;
 	free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
-	/* XXX: MRB-remove - this doesn't seem sane, should this be done somewhere else ?*/
-	mem_map = NODE_DATA(0)->node_mem_map;
 
 #ifdef CONFIG_DISCONTIGMEM
 	/*
arch/sh64/mm/init.c renamed from arch/sh64/mm/init.c~A6-no_arch_mem_map_init +0 -3
diff -puN arch/sh64/mm/init.c~A6-no_arch_mem_map_init arch/sh64/mm/init.c
@@ -124,9 +124,6 @@ void __init paging_init(void)
 	zones_size[ZONE_DMA] = MAX_LOW_PFN - START_PFN;
 	NODE_DATA(0)->node_mem_map = NULL;
 	free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
-
-	/* XXX: MRB-remove - this doesn't seem sane, should this be done somewhere else ?*/
-	mem_map = NODE_DATA(0)->node_mem_map;
 }
 
 void __init mem_init(void)
arch/sparc/mm/srmmu.c renamed from arch/sparc/mm/srmmu.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/sparc/mm/srmmu.c~A6-no_arch_mem_map_init arch/sparc/mm/srmmu.c
@@ -1343,7 +1343,6 @@ void __init srmmu_paging_init(void)
 
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    pfn_base, zholes_size);
-		mem_map = contig_page_data.node_mem_map;
 	}
 }
 
arch/sparc/mm/sun4c.c renamed from arch/sparc/mm/sun4c.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/sparc/mm/sun4c.c~A6-no_arch_mem_map_init arch/sparc/mm/sun4c.c
@@ -2116,7 +2116,6 @@ void __init sun4c_paging_init(void)
 
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    pfn_base, zholes_size);
-		mem_map = contig_page_data.node_mem_map;
 	}
 
 	cnt = 0;
arch/sparc64/mm/init.c renamed from arch/sparc64/mm/init.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/sparc64/mm/init.c~A6-no_arch_mem_map_init arch/sparc64/mm/init.c
@@ -1512,7 +1512,6 @@ void __init paging_init(void)
 
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    phys_base >> PAGE_SHIFT, zholes_size);
-		mem_map = contig_page_data.node_mem_map;
 	}
 
 	device_scan();
arch/v850/kernel/setup.c renamed from arch/v850/kernel/setup.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/v850/kernel/setup.c~A6-no_arch_mem_map_init arch/v850/kernel/setup.c
@@ -283,5 +283,4 @@ init_mem_alloc (unsigned long ram_start,
 	NODE_DATA(0)->node_mem_map = NULL;
 	free_area_init_node (0, NODE_DATA(0), zones_size,
 			     ADDR_TO_PAGE (PAGE_OFFSET), 0);
-	mem_map = NODE_DATA(0)->node_mem_map;
 }
mm/page_alloc.c renamed from mm/page_alloc.c~A6-no_arch_mem_map_init +14 -4
diff -puN mm/page_alloc.c~A6-no_arch_mem_map_init mm/page_alloc.c
@@ -1848,14 +1848,25 @@ static void __init free_area_init_core(s
 	}
 }
 
-void __init node_alloc_mem_map(struct pglist_data *pgdat)
+static void __init alloc_node_mem_map(struct pglist_data *pgdat)
 {
 	unsigned long size;
 
+	/*
+	 * Make sure that the architecture hasn't already allocated
+	 * a node_mem_map, and that the node contains memory.
+	 */
+	if (pgdat->node_mem_map || !pgdat->node_spanned_pages)
+		return;
+
 	size = (pgdat->node_spanned_pages + 1) * sizeof(struct page);
 	pgdat->node_mem_map = alloc_bootmem_node(pgdat, size);
 #ifndef CONFIG_DISCONTIGMEM
-	mem_map = contig_page_data.node_mem_map;
+	/*
+	 * With no DISCONTIG, the global mem_map is just set as node 0's
+	 */
+	if (pgdat == NODE_DATA(0))
+		mem_map = NODE_DATA(0)->node_mem_map;
 #endif
 }
 
@@ -1867,8 +1878,7 @@ void __init free_area_init_node(int nid,
 	pgdat->node_start_pfn = node_start_pfn;
 	calculate_zone_totalpages(pgdat, zones_size, zholes_size);
 
-	if (!pfn_to_page(node_start_pfn))
-		node_alloc_mem_map(pgdat);
+	alloc_node_mem_map(pgdat);
 
 	free_area_init_core(pgdat, zones_size, zholes_size);
 }

diff -puN arch/i386/kernel/mpparse.c~A6-no_arch_mem_map_init arch/i386/kernel/mpparse.c diff -puN arch/i386/kernel/setup.c~A6-no_arch_mem_map_init arch/i386/kernel/setup.c

arch/m32r/mm/init.c renamed from arch/m32r/mm/init.c~A6-no_arch_mem_map_init +0 -2
diff -puN arch/m32r/mm/init.c~A6-no_arch_mem_map_init arch/m32r/mm/init.c
@@ -121,8 +121,6 @@ unsigned long __init zone_sizes_init(voi
 
 	free_area_init_node(0, NODE_DATA(0), zones_size, start_pfn, 0);
 
-	mem_map = contig_page_data.node_mem_map;
-
 	return 0;
 }
 #else	/* CONFIG_DISCONTIGMEM */
arch/um/kernel/physmem.c renamed from arch/um/kernel/physmem.c~A6-no_arch_mem_map_init +0 -1
diff -puN arch/um/kernel/physmem.c~A6-no_arch_mem_map_init arch/um/kernel/physmem.c
@@ -294,7 +294,6 @@ int init_maps(unsigned long physmem, uns
 		INIT_LIST_HEAD(&p->lru);
 	}
 
-	mem_map = map;
 	max_mapnr = total_pages;
 	return(0);
 }

_

#1 lore raw

Hi Dave-san.

Quoted 5 lines

This patch has been one of the base patches in the -mhp tree for a bit now, and seems to be working pretty well, at least on x86. I would like to submit it upstream, but I want to get a bit more testing first. Is there a chance you ia64 guys could give it a quick test boot to make sure that it doesn't screw you over?

I tried this single patch with 2.6.11-rc2-mm2 on my Tiger4, and there is no problem in booting. In addition, I compliled other kernel as simple workload test on this test kernel, I didn't find any problem.

Bye.

Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com>


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 8 lines · Yasunori Goto

Hi Dave-san.

Quoted 5 lines

This patch has been one of the base patches in the -mhp tree for a bit now, and seems to be working pretty well, at least on x86. I would like to submit it upstream, but I want to get a bit more testing first. Is there a chance you ia64 guys could give it a quick test boot to make sure that it doesn't screw you over?

Quoted 4 lines

I tried this single patch with 2.6.11-rc2-mm2 on my Tiger4, and there is no problem in booting. In addition, I compliled other kernel as simple workload test on this test kernel, I didn't find any problem.

Thanks for the testing!

-- Dave

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

#3 lore raw
In reply to Dave Hansen

Dave,

Dave Hansen wrote: [Tue Feb 08 2005, 02:37:14PM EST]

Quoted 7 lines

This patch has been one of the base patches in the -mhp tree for a bit now, and seems to be working pretty well, at least on x86. I would like to submit it upstream, but I want to get a bit more testing first. Is there a chance you ia64 guys could give it a quick test boot to make sure that it doesn't screw you over?

-- Dave

[snip]

arch/ia64/mm/contig.c paging_init (void) · line 283

Quoted 10 lines

diff -puN arch/i386/mm/discontig.c~A6-no_arch_mem_map_init arch/i386/mm/discontig.c diff -puN arch/ia64/mm/contig.c~A6-no_arch_mem_map_init arch/ia64/mm/contig.c

arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +1 -1
@@ -280,7 +280,7 @@ paging_init (void)
 		vmem_map = (struct page *) vmalloc_end;
 		efi_memmap_walk(create_mem_map_page_table, NULL);
 
-		mem_map = contig_page_data.node_mem_map = vmem_map;
+		NODE_DATA(0)->node_mem_map = vmem_map;

This has to be changed to.

		mem_map = NODE_DATA(0)->node_mem_map = vmem_map;

arch/ia64/mm/contig.c paging_init (void) · line 286

Quoted 3 lines
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +0 -0
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    0, zholes_size);
 

[snip]
I actually submitted an identical change within my last patchset to lhms. Not making this change requires changing use of mem_map throughout contig.c and one BUG assertion in init.c. I haven't tested this patch but it was indirectly tested by me in FLATMEM configuration for lhms.

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

#4 lore raw
Quoted 9 lines · Bob Picco

arch/ia64/mm/contig.c paging_init (void) · line 283

Quoted 2 lines
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +1 -1
-		mem_map = contig_page_data.node_mem_map = vmem_map;
+		NODE_DATA(0)->node_mem_map = vmem_map;

This has to be changed to.

		mem_map = NODE_DATA(0)->node_mem_map = vmem_map;

arch/ia64/mm/contig.c paging_init (void) · line 285

Quoted 3 lines
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +0 -0
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    0, zholes_size);

[snip]
I actually submitted an identical change within my last patchset to lhms.

Good to know. I hadn't actually noticed that bit in your patch. It's another good example why to split things up into as many small, logical pieces as possible.

Quoted 3 lines

Not making this change requires changing use of mem_map throughout contig.c and one BUG assertion in init.c. I haven't tested this patch but it was indirectly tested by me in FLATMEM configuration for lhms.

Hmm. Do you really need the 'mem_map = ' part? I *think* free_area_init_node() calls alloc_node_mem_map(), which should do that exact assignment for you.

-- Dave

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

#5 lore raw

Dave Hansen wrote: [Tue Feb 08 2005, 08:17:30PM EST]

Quoted 19 lines · Bob Picco
Quoted 9 lines

arch/ia64/mm/contig.c paging_init (void) · line 283

Quoted 2 lines
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +1 -1
-		mem_map = contig_page_data.node_mem_map = vmem_map;
+		NODE_DATA(0)->node_mem_map = vmem_map;

This has to be changed to.

		mem_map = NODE_DATA(0)->node_mem_map = vmem_map;

arch/ia64/mm/contig.c paging_init (void) · line 285

Quoted 3 lines
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~A6-no_arch_mem_map_init +0 -0
 		free_area_init_node(0, &contig_page_data, zones_size,
 				    0, zholes_size);

[snip]
I actually submitted an identical change within my last patchset to lhms.

Good to know. I hadn't actually noticed that bit in your patch. It's another good example why to split things up into as many small, logical pieces as possible.

Quoted 3 lines

Not making this change requires changing use of mem_map throughout contig.c and one BUG assertion in init.c. I haven't tested this patch but it was indirectly tested by me in FLATMEM configuration for lhms.

Quoted 5 lines

Hmm. Do you really need the 'mem_map = ' part? I *think* free_area_init_node() calls alloc_node_mem_map(), which should do that exact assignment for you.

-- Dave

okay. I see what happened here. alloc_node_mem_map is correct and makes my suggested change not required. I think this was fallout from our bad composite lhms patchset.

bob

Quoted 1 line

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