initialize all arches mem_map in one place
Subsystems (9)
RFC 1/1 initialize all arches mem_map in one place
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;
Also, ppc64 has some interesting hacks^Wcode in this area to make up for any empty-memory NUMA nodes, which I think can go away now.
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.
arch/alpha/mm/numa.c | 2 - arch/arm/mm/init.c | 6 ---- arch/arm26/mm/init.c | 4 --- arch/cris/arch-v10/mm/init.c | 3 -- arch/i386/mm/discontig.c | 11 +++----- arch/ia64/mm/contig.c | 7 ++--- arch/ia64/mm/discontig.c | 4 +-- arch/ia64/mm/init.c | 8 +++--- arch/mips/sgi-ip27/ip27-memory.c | 2 - arch/parisc/mm/init.c | 2 - arch/ppc64/mm/init.c | 3 -- arch/ppc64/mm/numa.c | 12 --------- arch/sh/mm/init.c | 6 +--- arch/sh64/mm/init.c | 5 --- arch/sparc/mm/srmmu.c | 3 -- arch/sparc/mm/sun4c.c | 3 -- arch/sparc64/mm/init.c | 3 -- arch/v850/kernel/setup.c | 3 -- arch/x86_64/mm/numa.c | 2 - include/asm-ia64/pgtable.h | 2 - include/linux/mm.h | 5 +-- mm/page_alloc.c | 51 +++++++++++++++++++++++++-------------- 22 files changed, 66 insertions(+), 81 deletions(-)
-- Dave
---
memhotplug-dave/arch/alpha/mm/numa.c | 2 memhotplug-dave/arch/arm/mm/init.c | 6 -- memhotplug-dave/arch/arm26/mm/init.c | 4 - memhotplug-dave/arch/cris/arch-v10/mm/init.c | 3 - memhotplug-dave/arch/i386/mm/discontig.c | 11 +--- memhotplug-dave/arch/ia64/mm/contig.c | 7 +-- memhotplug-dave/arch/ia64/mm/discontig.c | 4 - memhotplug-dave/arch/ia64/mm/init.c | 8 ++- memhotplug-dave/arch/mips/sgi-ip27/ip27-memory.c | 2 memhotplug-dave/arch/parisc/mm/init.c | 2 memhotplug-dave/arch/ppc64/mm/init.c | 3 - memhotplug-dave/arch/ppc64/mm/numa.c | 12 ----- memhotplug-dave/arch/sh/mm/init.c | 6 -- memhotplug-dave/arch/sh64/mm/init.c | 5 -- memhotplug-dave/arch/sparc/mm/srmmu.c | 3 - memhotplug-dave/arch/sparc/mm/sun4c.c | 3 - memhotplug-dave/arch/sparc64/mm/init.c | 3 - memhotplug-dave/arch/v850/kernel/setup.c | 3 - memhotplug-dave/arch/x86_64/mm/numa.c | 2 memhotplug-dave/include/asm-ia64/pgtable.h | 2 memhotplug-dave/include/linux/mm.h | 5 -- memhotplug-dave/mm/page_alloc.c | 51 ++++++++++++++--------- 22 files changed, 66 insertions(+), 81 deletions(-)
arch/alpha/mm/numa.c renamed from arch/alpha/mm/numa.c~B-init-no-mem_map +1 -1
@@ -313,7 +313,7 @@ void __init paging_init(void) zones_size[ZONE_DMA ] = dma_local_pfn; zones_size[ZONE_NORMAL ] = (end_pfn - start_pfn) - dma_local_pfn; } -free_area_init_node (nid,NODE_DATA (nid),NULL , zones_size, start_pfn,NULL ); +free_area_init_node (nid,NODE_DATA (nid), zones_size, start_pfn,NULL ); }/* Initialize the kernel's ZERO_PGE. */
arch/arm/mm/init.c renamed from arch/arm/mm/init.c~B-init-no-mem_map +1 -5
@@ -502,13 +502,9 @@ void __init paging_init(struct meminfo **/ arch_adjust_zones (node, zone_size, zhole_size); -free_area_init_node (node, pgdat,NULL , zone_size, +free_area_init_node (node, pgdat, zone_size, 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
arch/arm26/mm/init.c renamed from arch/arm26/mm/init.c~B-init-no-mem_map +1 -3
@@ -306,10 +306,8 @@ void __init paging_init(struct meminfo *if (!zone_size[0 ])BUG (); -free_area_init_node (0 , pgdat,0 , zone_size, +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
arch/cris/arch-v10/mm/init.c renamed from arch/cris/arch-v10/mm/init.c~B-init-no-mem_map +1 -2
@@ -183,8 +183,7 @@ paging_init(void)* mem_map page array. */ -free_area_init_node (0 , &contig_page_data,0 , zones_size,PAGE_OFFSET >>PAGE_SHIFT ,0 ); - mem_map = contig_page_data.node_mem_map; +free_area_init_node (0 , &contig_page_data, zones_size,PAGE_OFFSET >>PAGE_SHIFT ,0 ); }/* Initialize remaps of some I/O-ports. It is important that this
arch/i386/mm/discontig.c renamed from arch/i386/mm/discontig.c~B-init-no-mem_map +4 -7
@@ -417,18 +417,15 @@ void __init zone_sizes_init(void)* normal bootmem allocator, but other nodes come from the * remapped KVA area - mbligh */ -if (!nid) -free_area_init_node (nid,NODE_DATA (nid),0 , - zones_size, start, zholes_size); -else { +if (nid) {unsigned long lmem_map; lmem_map = (unsigned long )node_remap_start_vaddr[nid]; lmem_map +=sizeof (pg_data_t) +PAGE_SIZE -1 ; lmem_map &=PAGE_MASK ; -free_area_init_node (nid,NODE_DATA (nid), - (struct page *)lmem_map, zones_size, - start, zholes_size); +NODE_DATA (nid)->node_mem_map = (struct page *)lmem_map; } +free_area_init_node (nid,NODE_DATA (nid), zones_size, + start, zholes_size); }return ; }
arch/ia64/mm/contig.c renamed from arch/ia64/mm/contig.c~B-init-no-mem_map +3 -4
@@ -267,9 +267,8 @@ paging_init (void)efi_memmap_walk (find_largest_hole, (u64 *)&max_gap);if (max_gap <LARGE_GAP ) { vmem_map = (struct page *)0 ; -free_area_init_node (0 , &contig_page_data,NULL , zones_size,0 , +free_area_init_node (0 , &contig_page_data, zones_size,0 , zholes_size); - mem_map = contig_page_data.node_mem_map; }else {unsigned long map_size;
@@ -280,10 +279,10 @@ paging_init (void) vmem_map = (struct page *) vmalloc_end;efi_memmap_walk (create_mem_map_page_table,0 ); -free_area_init_node (0 , &contig_page_data, vmem_map, zones_size, +NODE_DATA (0 )->node_mem_map = vmem_map; +free_area_init_node (0 , &contig_page_data, zones_size,0 , zholes_size); - mem_map = contig_page_data.node_mem_map; printk("Virtual mem_map starts at 0x%p\n", mem_map); }#else /* !CONFIG_VIRTUAL_MEM_MAP */
arch/ia64/mm/discontig.c renamed from arch/ia64/mm/discontig.c~B-init-no-mem_map +2 -2
@@ -665,8 +665,8 @@ void paging_init(void) pfn_offset = mem_data[node].min_pfn; -free_area_init_node (node,NODE_DATA (node), - vmem_map + pfn_offset, zones_size, +NODE_DATA (node)->node_mem_map = vmem_map + pfn_offset; +free_area_init_node (node,NODE_DATA (node), zones_size, pfn_offset, zholes_size); }
arch/ia64/mm/init.c renamed from arch/ia64/mm/init.c~B-init-no-mem_map +5 -3
@@ -433,14 +433,16 @@ virtual_memmap_init (u64 start, u64 end, }void -memmap_init (struct page *start,unsigned long size,int nid, -unsigned long zone,unsigned long start_pfn) +memmap_init (unsigned long size,int nid,unsigned long zone, +unsigned long start_pfn) {if (!vmem_map) -memmap_init_zone (start, size, nid, zone, start_pfn); +memmap_init_zone (size, nid, zone, start_pfn);else { +struct page *start;struct memmap_init_callback_data args; + start =pfn_to_page (start_pfn); args.start = start; args.end = start + size; args.nid = nid;
arch/mips/sgi-ip27/ip27-memory.c renamed from arch/mips/sgi-ip27/ip27-memory.c~B-init-no-mem_map +1 -1
@@ -225,7 +225,7 @@ void __init paging_init(void)pfn_t end_pfn =node_getmaxclick (node) +1 ; zones_size[ZONE_DMA ] = end_pfn - start_pfn; -free_area_init_node (node,NODE_DATA (node),NULL , +free_area_init_node (node,NODE_DATA (node), zones_size, start_pfn,NULL );if (end_pfn > max_low_pfn)
arch/parisc/mm/init.c renamed from arch/parisc/mm/init.c~B-init-no-mem_map +1 -1
@@ -761,7 +761,7 @@ void __init paging_init(void)unsigned long zones_size[MAX_NR_ZONES ] = {0 ,0 ,0 , }; zones_size[ZONE_DMA ] = pmem_ranges[i].pages; -free_area_init_node (i,NODE_DATA (i),NULL ,zones_size, +free_area_init_node (i,NODE_DATA (i),zones_size, (pmem_ranges[i].start_pfn <<PAGE_SHIFT ),0 ); }
arch/ppc64/mm/init.c renamed from arch/ppc64/mm/init.c~B-init-no-mem_map +1 -2
@@ -587,9 +587,8 @@ void __init paging_init(void) zones_size[ZONE_DMA ] = top_of_ram >>PAGE_SHIFT ; zholes_size[ZONE_DMA ] = (top_of_ram - total_ram) >>PAGE_SHIFT ; -free_area_init_node (0 , &contig_page_data,NULL , zones_size, +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/ppc64/mm/numa.c renamed from arch/ppc64/mm/numa.c~B-init-no-mem_map +1 -11
@@ -464,17 +464,7 @@ void __init paging_init(void)dbg ("free_area_init node %d %lx %lx (hole: %lx)\n" , nid, zones_size[ZONE_DMA ], start_pfn, zholes_size[ZONE_DMA ]); -/* -* Give this empty node a dummy struct page to avoid -* us from trying to allocate a node local mem_map -* in free_area_init_node (which will fail). -*/ -if (!node_data[nid].node_spanned_pages) - node_mem_map =alloc_bootmem (sizeof (struct page )); -else - node_mem_map =NULL ; - -free_area_init_node (nid,NODE_DATA (nid), node_mem_map, +free_area_init_node (nid,NODE_DATA (nid), zones_size, start_pfn, zholes_size); } }
arch/sh/mm/init.c renamed from arch/sh/mm/init.c~B-init-no-mem_map +2 -4
@@ -215,9 +215,7 @@ void __init paging_init(void)disable_mmu ();#endif -free_area_init_node (0 ,NODE_DATA (0 ),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; +free_area_init_node (0 ,NODE_DATA (0 ), zones_size, __MEMORY_START >>PAGE_SHIFT ,0 );#ifdef CONFIG_DISCONTIGMEM /*
@@ -225,7 +223,7 @@ void __init paging_init(void)*/ zones_size[ZONE_DMA ] = __MEMORY_SIZE_2ND >>PAGE_SHIFT ; zones_size[ZONE_NORMAL ] =0 ; -free_area_init_node (1 ,NODE_DATA (1 ),0 , zones_size, __MEMORY_START_2ND >>PAGE_SHIFT ,0 ); +free_area_init_node (1 ,NODE_DATA (1 ), zones_size, __MEMORY_START_2ND >>PAGE_SHIFT ,0 );#endif }
arch/sh64/mm/init.c renamed from arch/sh64/mm/init.c~B-init-no-mem_map +1 -4
@@ -123,10 +123,7 @@ void __init paging_init(void)*/ zones_size[ZONE_DMA ] =MAX_LOW_PFN -START_PFN ; -free_area_init_node (0 ,NODE_DATA (0 ),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; +free_area_init_node (0 ,NODE_DATA (0 ), zones_size, __MEMORY_START >>PAGE_SHIFT ,0 ); }void __init mem_init (void )
arch/sparc/mm/srmmu.c renamed from arch/sparc/mm/srmmu.c~B-init-no-mem_map +1 -2
@@ -1341,9 +1341,8 @@ void __init srmmu_paging_init(void) zones_size[ZONE_HIGHMEM ] = npages; zholes_size[ZONE_HIGHMEM ] = npages -calc_highpages (); -free_area_init_node (0 , &contig_page_data,NULL , zones_size, +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~B-init-no-mem_map +1 -2
@@ -2114,9 +2114,8 @@ void __init sun4c_paging_init(void) zones_size[ZONE_HIGHMEM ] = npages; zholes_size[ZONE_HIGHMEM ] = npages -calc_highpages (); -free_area_init_node (0 , &contig_page_data,NULL , zones_size, +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~B-init-no-mem_map +1 -2
@@ -1585,9 +1585,8 @@ void __init paging_init(void) zones_size[ZONE_DMA ] = npages; zholes_size[ZONE_DMA ] = npages - pages_avail; -free_area_init_node (0 , &contig_page_data,NULL , zones_size, +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/x86_64/mm/numa.c renamed from arch/x86_64/mm/numa.c~B-init-no-mem_map +1 -1
@@ -136,7 +136,7 @@ void __init setup_node_zones(int nodeid) zones[ZONE_NORMAL ] = end_pfn - start_pfn; } -free_area_init_node (nodeid,NODE_DATA (nodeid),NULL , zones, +free_area_init_node (nodeid,NODE_DATA (nodeid), zones, start_pfn,NULL ); }
include/linux/mm.h renamed from include/linux/mm.h~B-init-no-mem_map +2 -3
@@ -601,11 +601,10 @@ static inline pmd_t *pmd_alloc(struct mm }extern void free_area_init (unsigned long * zones_size); -extern void free_area_init_node (int nid,pg_data_t *pgdat,struct page *pmap, +extern void free_area_init_node (int nid,pg_data_t *pgdat,unsigned long * zones_size,unsigned long zone_start_pfn,unsigned long *zholes_size); -extern void memmap_init_zone (struct page *,unsigned long ,int , -unsigned long ,unsigned long ); +extern void memmap_init_zone (unsigned long ,int ,unsigned long ,unsigned long );extern void mem_init (void );extern void show_mem (void );extern void si_meminfo (struct sysinfo * val);
mm/page_alloc.c renamed from mm/page_alloc.c~B-init-no-mem_map +33 -18
101 lines not on this page · raw message
arch/v850/kernel/setup.c renamed from arch/v850/kernel/setup.c~B-init-no-mem_map +1 -2
@@ -281,7 +281,6 @@ init_mem_alloc (unsigned long ram_start,#error MAX_ORDER is too large for given PAGE_OFFSET (use CONFIG_FORCE_MAX_ZONEORDER to change it)#endif -free_area_init_node (0 ,NODE_DATA (0 ),0 , zones_size, +free_area_init_node (0 ,NODE_DATA (0 ), zones_size,ADDR_TO_PAGE (PAGE_OFFSET ),0 ); - mem_map =NODE_DATA (0 )->node_mem_map; }
include/asm-ia64/pgtable.h renamed from include/asm-ia64/pgtable.h~B-init-no-mem_map +1 -1
@@ -520,7 +520,7 @@ do { \# ifdef CONFIG_VIRTUAL_MEM_MAP /* arch mem_map init routine is needed due to holes in a virtual mem_map */ # define __HAVE_ARCH_MEMMAP_INIT -extern void memmap_init (struct page *start,unsigned long size,int nid,unsigned long zone, +extern void memmap_init (unsigned long size,int nid,unsigned long zone,unsigned long start_pfn);# endif /* CONFIG_VIRTUAL_MEM_MAP */ # endif /* !__ASSEMBLY__ */
_
Quoted 5 lines · Dave Hansen
The following patch does what my first one did (don't pass
mem_mapinto the init functions), incorporates Jesse Barnes' ia64 fixes on top of that, and gets rid of all but one of the globalmem_mapinitializations (parisc is weird). It also magically removes more code than it adds. It could be smaller, but I shamelessly added some comments.
Doesn't apply cleanly to the latest BK tree, which patch am I missing?
Thanks,
Jesse
--
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>
Quoted 8 lines · Jesse Barnes
Quoted 5 lines · Dave Hansen
The following patch does what my first one did (don't pass
mem_mapinto the init functions), incorporates Jesse Barnes' ia64 fixes on top of that, and gets rid of all but one of the globalmem_mapinitializations (parisc is weird). It also magically removes more code than it adds. It could be smaller, but I shamelessly added some comments.Doesn't apply cleanly to the latest BK tree, which patch am I missing?
It should only be against the latest mm: 2.6.8-rc3-mm1
-- 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>