Sizing zones and holes in an architecture independent manner V3
Subsystems (5)
cover Sizing zones and holes in an architecture independent manner V3
This is V3 of the patchset to size zones and memory holes in an architecture-independent manner. A number of bugs have been fixed in the IA64 changes and it is now known to boot with the correct zone sizes. In this release, 98 lines of x86_64 arch-specific code is removed because it used similar initialisation functions to powerpc. In the last release, only 34 lines were removed.
Andi, in light of the x86_64 changes since the last release, can you take another look at the x86_64 changes please? Does this release make a bit more sense for x86_64 now?
Changelog since V2
o Fix a bug where holes in lower zones get double counted
o Catch the case where a new range is registered that is within an range
o Catch the case where a zone boundary is within a hole
o Use the EFI map for registering ranges on x86_64+numa
o On IA64+NUMA, add the active ranges before rounding for granules
o On x86_64, remove e820_hole_size and e820_bootmem_free and use arch-independent equivalents
o On x86_64, remove the map walk in e820_end_of_ram()
o Rename memory_present_with_active_regions, name ambiguous
o Add absent_pages_in_range() for arches to call
Changelog since V1
o Correctly convert virtual and physical addresses to PFNs on ia64
o Correctly convert physical addresses to PFN on older ppc
o When add_active_range() is called with overlapping pfn ranges, merge them
o When a zone boundary occurs within a memory hole, account correctly
o Minor whitespace damage cleanup
o Debugging patch temporarily included
At a basic level, architectures define structures to record where active ranges of page frames are located. Once located, the code to calculate zone sizes and holes in each architecture is very similar. Some of this zone and hole sizing code is difficult to read for no good reason. This set of patches eliminates the similar-looking architecture-specific code.
The patches introduce a mechanism where architectures register where the active ranges of page frames are with add_active_range(). When all areas have been discovered, free_area_init_nodes() is called to initialise the pgdat and zones. The zone sizes and holes are then calculated in an architecture independent manner.
Patch 1 introduces the mechanism for registering and initialising PFN ranges Patch 2 changes ppc to use the mechanism - 128 arch-specific LOC removed Patch 3 changes x86 to use the mechanism - 150 arch-specific LOC removed Patch 4 changes x86_64 to use the mechanism - 98 arch-specific LOC removed Patch 5 changes ia64 to use the mechanism - 60 arch-specific LOC removed
At this point, there is a net reduction of 62 lines of code and the arch-independent code is a lot easier to read in comparison to some of the arch-specific stuff, particularly in arch/i386/ .
For Patch 6, it was also noted that page_alloc.c has a *lot* of initialisation code which makes the file harder to read than it needs to be. Patch 6 creates a new file mem_init.c and moves a lot of initialisation code from page_alloc.c to it. After the patch is applied, there is still a net loss of 43 lines.
The patches have been successfully boot tested and verified that the zones are the correct size on
o x86, flatmem
o x86, NUMAQ
o PPC64, NUMA
o PPC64, CONFIG_NUMA=n
o x86_64, NUMA with SRAT
o x86_64, CONFIG_NUMA=n
There are differences in the zone sizes for x86_64 as the arch-specific code for x86_64 accounts the kernel image and the starting mem_maps as memory holes but the architecture-specific code accounts the memory as present. The patches have been compile tested for ia64 for flatmem and sparsemem configurations. At attempt was made to boot test on an ancient RS/6000 but the vanilla kernel does not boot so I have to investigate there.
The net reduction seems small but the big benefit of this set of patches is the reduction of 437 lines of architecture-specific code, some of which is very hairy. There should be a greater net reduction when other architectures use the same mechanisms for zone and hole sizing but I lack the hardware to test on.
Comments?
Additional credit;
Dave Hansen for the initial suggestion and comments on early patches Andy Whitcroft for reviewing early versions and catching numerous errors Tony Luck and Yasunori Goto for testing and debugging on IA64 Bob Picco for testing and fixing bugs related to pfn registration
arch/i386/Kconfig | 8 arch/i386/kernel/setup.c | 19 arch/i386/kernel/srat.c | 98 ---- arch/i386/mm/discontig.c | 59 -- arch/ia64/Kconfig | 3 arch/ia64/mm/contig.c | 60 -- arch/ia64/mm/discontig.c | 41 - arch/ia64/mm/init.c | 12 arch/powerpc/Kconfig | 13 arch/powerpc/mm/mem.c | 53 -- arch/powerpc/mm/numa.c | 157 ------ arch/ppc/Kconfig | 3 arch/ppc/mm/init.c | 26 - arch/x86_64/Kconfig | 3 arch/x86_64/kernel/e820.c | 109 +--- arch/x86_64/kernel/setup.c | 3 arch/x86_64/mm/init.c | 62 -- arch/x86_64/mm/numa.c | 18 arch/x86_64/mm/srat.c | 7 include/asm-ia64/meminit.h | 1 include/asm-x86_64/e820.h | 5 include/asm-x86_64/proto.h | 2 include/linux/mm.h | 18 include/linux/mmzone.h | 15 mm/Makefile | 2 mm/mem_init.c | 1040 +++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 678 ----------------------------- 27 files changed, 1236 insertions(+), 1279 deletions(-)
Signature · 10 lines
-- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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>
PATCH 1/7 Introduce mechanism for registering active regions of memory
This patch defines the structure to represent an active range of page frames within a node in an architecture independent manner. Architectures are expected to register active ranges of PFNs using add_active_range(nid, start_pfn, end_pfn) and call free_area_init_nodes() passing the PFNs of the end of each zone.
include/linux/mm.h | 18 ++ include/linux/mmzone.h | 15 + mm/page_alloc.c | 391 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 399 insertions(+), 25 deletions(-)
include/linux/mm.h +18 -0
@@ -867,6 +867,24 @@ extern void free_area_init(unsigned longextern void free_area_init_node (int nid,pg_data_t *pgdat,unsigned long * zones_size,unsigned long zone_start_pfn,unsigned long *zholes_size); +#ifdef CONFIG_ARCH_POPULATES_NODE_MAP +extern void free_area_init_nodes (unsigned long max_dma_pfn, +unsigned long max_dma32_pfn, +unsigned long max_low_pfn, +unsigned long max_high_pfn); +extern void add_active_range (unsigned int nid,unsigned long start_pfn, +unsigned long end_pfn); +extern void get_pfn_range_for_nid (unsigned int nid, +unsigned long *start_pfn,unsigned long *end_pfn); +extern unsigned long find_min_pfn_with_active_regions (void ); +extern unsigned long find_max_pfn_with_active_regions (void ); +extern int early_pfn_to_nid (unsigned long pfn); +extern void free_bootmem_with_active_regions (int nid, +unsigned long max_low_pfn); +extern void sparse_memory_present_with_active_regions (int nid); +extern unsigned long absent_pages_in_range (unsigned long start_pfn, +unsigned long end_pfn); +#endif extern void memmap_init_zone (unsigned long ,int ,unsigned long ,unsigned long );extern void setup_per_zone_pages_min (void );extern void mem_init (void );
include/linux/mmzone.h +14 -1
@@ -271,6 +271,18 @@ struct zonelist {struct zone *zones[MAX_NUMNODES *MAX_NR_ZONES +1 ];// NULL delimited }; +#ifdef CONFIG_ARCH_POPULATES_NODE_MAP +/* +* This represents an active range of physical memory. Architectures register +* a pfn range using add_active_range() and later initialise the nodes and +* free list with free_area_init_nodes() +*/ +struct node_active_region { +unsigned long start_pfn; +unsigned long end_pfn; +int nid; +}; +#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */ /* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
@@ -465,7 +477,8 @@ extern struct zone *next_zone(struct zon#endif -#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID +#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID ) && \ + !defined(CONFIG_ARCH_POPULATES_NODE_MAP )#define early_pfn_to_nid (nid) (0UL)#endif
mm/page_alloc.c +367 -24
433 lines not on this page · raw message
--
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>
PATCH 2/7 Have Power use add_active_range() and free_area_init_nodes()
In reply to Mel GormanSize zones and holes in an architecture independent manner for Power.
This has been boot tested on PPC64 with NUMA both enabled and disabled. It has been compile tested for an older CHRP-based machine.
powerpc/Kconfig | 13 ++-- powerpc/mm/mem.c | 53 ++++++---------- powerpc/mm/numa.c | 157 ++++--------------------------------------------- ppc/Kconfig | 3 ppc/mm/init.c | 26 ++++---- 5 files changed, 62 insertions(+), 190 deletions(-)
arch/powerpc/Kconfig +9 -4
@@ -665,11 +665,16 @@ config ARCH_SPARSEMEM_DEFAULT def_bool y depends on SMP && PPC_PSERIES -source "mm/Kconfig" - -config HAVE_ARCH_EARLY_PFN_TO_NID +config ARCH_POPULATES_NODE_MAP def_bool y - depends on NEED_MULTIPLE_NODES + +# Value of 256 is MAX_LMB_REGIONS * 2 +config MAX_ACTIVE_REGIONS + int + default 256 + depends on ARCH_POPULATES_NODE_MAP + +source "mm/Kconfig" config ARCH_MEMORY_PROBE def_bool y
arch/powerpc/mm/mem.c +22 -31
85 lines not on this page · raw message
arch/powerpc/mm/numa.c +14 -143
207 lines not on this page · raw message
arch/ppc/Kconfig +3 -0
@@ -949,6 +949,9 @@ config NR_CPUS config HIGHMEM bool "High memory support" +config ARCH_POPULATES_NODE_MAP + def_bool y + source kernel/Kconfig.hz source kernel/Kconfig.preempt source "mm/Kconfig"
arch/ppc/mm/init.c +14 -12
@@ -359,8 +359,7 @@ void __init do_init_bootmem(void)*/ void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ], i; - +unsigned long start_pfn, end_pfn;#ifdef CONFIG_HIGHMEM map_page (PKMAP_BASE ,0 ,0 );/* XXX gross */ pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k
@@ -370,19 +369,22 @@ void __init paging_init(void) (KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN); kmap_prot =PAGE_KERNEL ;#endif /* CONFIG_HIGHMEM */ - -/* -* All pages are DMA-able so we put them all in the DMA zone. -*/ - zones_size[ZONE_DMA ] = total_lowmem >>PAGE_SHIFT ; -for (i =1 ; i <MAX_NR_ZONES ; i++) - zones_size[i] =0 ; +/* All pages are DMA-able so we put them all in the DMA zone. */ + start_pfn =__pa (PAGE_OFFSET ) >>PAGE_SHIFT ; + end_pfn = start_pfn + (total_memory >>PAGE_SHIFT ); +add_active_range (0 , start_pfn, end_pfn);#ifdef CONFIG_HIGHMEM - zones_size[ZONE_HIGHMEM ] = (total_memory - total_lowmem) >>PAGE_SHIFT ; +free_area_init_nodes (total_lowmem >>PAGE_SHIFT , + total_lowmem >>PAGE_SHIFT , + total_lowmem >>PAGE_SHIFT , + total_memory >>PAGE_SHIFT ); +#else +free_area_init_nodes (total_memory >>PAGE_SHIFT , + total_memory >>PAGE_SHIFT , + total_memory >>PAGE_SHIFT , + total_memory >>PAGE_SHIFT );#endif /* CONFIG_HIGHMEM */ - -free_area_init (zones_size); }void __init mem_init (void )
--
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>
PATCH 3/7 Have x86 use add_active_range() and free_area_init_nodes
In reply to Mel GormanSize zones and holes in an architecture independent manner for x86.
This has been boot tested on;
x86 with 4 CPUs, flatmem
x86 on NUMAQ
It needs to be boot tested on an x86 machine that uses SRAT.
Kconfig | 8 +--- kernel/setup.c | 19 +++------- kernel/srat.c | 98 ---------------------------------------------------- mm/discontig.c | 59 ++++--------------------------- 4 files changed, 17 insertions(+), 167 deletions(-)
arch/i386/Kconfig +3 -5
@@ -563,12 +563,10 @@ config ARCH_SELECT_MEMORY_MODEL def_bool y depends on ARCH_SPARSEMEM_ENABLE -source "mm/Kconfig" +config ARCH_POPULATES_NODE_MAP + def_bool y -config HAVE_ARCH_EARLY_PFN_TO_NID - bool - default y - depends on NUMA +source "mm/Kconfig" config HIGHPTE bool "Allocate 3rd-level pagetables from highmem"
arch/i386/kernel/setup.c +6 -13
@@ -1156,22 +1156,15 @@ static unsigned long __init setup_memoryvoid __init zone_sizes_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 ,0 ,0 }; -unsigned int max_dma, low; +unsigned int max_dma; +#ifndef CONFIG_HIGHMEM +unsigned long highend_pfn = max_low_pfn; +#endif max_dma =virt_to_phys ((char *)MAX_DMA_ADDRESS ) >>PAGE_SHIFT ; - low = max_low_pfn; -if (low < max_dma) - zones_size[ZONE_DMA ] = low; -else { - zones_size[ZONE_DMA ] = max_dma; - zones_size[ZONE_NORMAL ] = low - max_dma; -#ifdef CONFIG_HIGHMEM - zones_size[ZONE_HIGHMEM ] = highend_pfn - low; -#endif - } -free_area_init (zones_size); +add_active_range (0 ,0 , highend_pfn); +free_area_init_nodes (max_dma, max_dma, max_low_pfn, highend_pfn); }#else extern unsigned long __init setup_memory (void );
arch/i386/kernel/srat.c +0 -98
119 lines not on this page · raw message
arch/i386/mm/discontig.c +8 -51
74 lines not on this page · raw message
--
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>
PATCH 4/7 Have x86_64 use add_active_range() and free_area_init_nodes
In reply to Mel GormanSize zones and holes in an architecture independent manner for x86_64.
This has only been boot tested on an x86_64 with NUMA and SRAT.
arch/x86_64/Kconfig | 3 + arch/x86_64/kernel/e820.c | 109 ++++++++++----------------------------- arch/x86_64/kernel/setup.c | 3 - arch/x86_64/mm/init.c | 62 +--------------------- arch/x86_64/mm/k8topology.c | 3 + arch/x86_64/mm/numa.c | 18 +++--- arch/x86_64/mm/srat.c | 7 +- include/asm-x86_64/e820.h | 5 - include/asm-x86_64/proto.h | 2 9 files changed, 57 insertions(+), 155 deletions(-)
arch/x86_64/Kconfig +3 -0
@@ -73,6 +73,9 @@ config ARCH_MAY_HAVE_PC_FDC bool default y +config ARCH_POPULATES_NODE_MAP + def_bool y + config DMI bool default y
arch/x86_64/kernel/e820.c +30 -79
140 lines not on this page · raw message
arch/x86_64/kernel/setup.c +2 -1
@@ -466,7 +466,8 @@ contig_initmem_init(unsigned long start_if (bootmap ==-1L )panic ("Cannot find bootmem map of size %ld\n" ,bootmap_size); bootmap_size =init_bootmem (bootmap >>PAGE_SHIFT , end_pfn); -e820_bootmem_free (NODE_DATA (0 ),0 , end_pfn <<PAGE_SHIFT ); +e820_register_active_regions (0 ,0 , end_pfn); +free_bootmem_with_active_regions (0 , end_pfn); reserve_bootmem(bootmap, bootmap_size); }#endif
arch/x86_64/mm/init.c +3 -59
79 lines not on this page · raw message
arch/x86_64/mm/k8topology.c +3 -0
@@ -149,6 +149,9 @@ int __init k8_scan_nodes(unsigned long s prevbase = base; +e820_register_active_regions (nodeid, + nodes[nodeid].start >>PAGE_SHIFT , + nodes[nodeid].end >>PAGE_SHIFT );node_set (nodeid, nodes_parsed); }
arch/x86_64/mm/numa.c +9 -9
@@ -138,7 +138,7 @@ void __init setup_node_bootmem(int nodei bootmap_start >>PAGE_SHIFT , start_pfn, end_pfn); -e820_bootmem_free (NODE_DATA (nodeid), start, end); +free_bootmem_with_active_regions (nodeid, end);reserve_bootmem_node (NODE_DATA (nodeid), nodedata_phys, pgdat_size);reserve_bootmem_node (NODE_DATA (nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT );
@@ -149,13 +149,11 @@ void __init setup_node_bootmem(int nodeivoid __init setup_node_zones (int nodeid) {unsigned long start_pfn, end_pfn, memmapsize, limit; -unsigned long zones[MAX_NR_ZONES ]; -unsigned long holes[MAX_NR_ZONES ]; start_pfn =node_start_pfn (nodeid); end_pfn =node_end_pfn (nodeid); -Dprintk (KERN_INFO "Setting up node %d %lx-%lx\n" , +Dprintk (KERN_INFO "Setting up memmap for node %d %lx-%lx\n" , nodeid, start_pfn, end_pfn);/* Try to allocate mem_map at end to not fill up precious <4GB
@@ -167,10 +165,6 @@ void __init setup_node_zones(int nodeid) memmapsize,SMP_CACHE_BYTES ,round_down (limit - memmapsize,PAGE_SIZE ), limit); - -size_zones (zones, holes, start_pfn, end_pfn); -free_area_init_node (nodeid,NODE_DATA (nodeid), zones, - start_pfn, holes); }void __init numa_init_array (void )
@@ -231,8 +225,11 @@ static int numa_emulation(unsigned longprintk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" );return -1 ; } -for_each_online_node (i) +for_each_online_node (i) { +e820_register_active_regions (i, nodes[i].start >>PAGE_SHIFT , + nodes[i].end >>PAGE_SHIFT );setup_node_bootmem (i, nodes[i].start, nodes[i].end); + }numa_init_array ();return 0 ; }
@@ -271,6 +268,7 @@ void __init numa_initmem_init(unsigned lfor (i =0 ; i <NR_CPUS ; i++)numa_set_node (i,0 ); node_to_cpumask[0 ] =cpumask_of_cpu (0 ); +e820_register_active_regions (0 , start_pfn, end_pfn);setup_node_bootmem (0 , start_pfn <<PAGE_SHIFT , end_pfn <<PAGE_SHIFT ); }
@@ -318,6 +316,8 @@ void __init paging_init(void)for_each_online_node (i) {setup_node_zones (i); } + +free_area_init_nodes (MAX_DMA_PFN ,MAX_DMA32_PFN , end_pfn, end_pfn); }/* [numa=off] */
arch/x86_64/mm/srat.c +5 -2
@@ -15,6 +15,7 @@#include <linux/bitmap.h> #include <linux/module.h> #include <linux/topology.h> +#include <linux/mm.h> #include <asm/proto.h> #include <asm/numa.h> #include <asm/e820.h>
@@ -208,6 +209,8 @@ acpi_numa_memory_affinity_init(struct acif (nd->end < end) nd->end = end; } +e820_register_active_regions (node, + nd->start >>PAGE_SHIFT , nd->end >>PAGE_SHIFT );printk (KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n" , node, pxm, nd->start, nd->end); }
@@ -224,10 +227,10 @@ static int nodes_cover_memory(void)unsigned long s = nodes[i].start >>PAGE_SHIFT ;unsigned long e = nodes[i].end >>PAGE_SHIFT ; pxmram += e - s; - pxmram -=e820_hole_size (s, e); + pxmram -=absent_pages_in_range (s, e); } - e820ram = end_pfn -e820_hole_size (0 , end_pfn); + e820ram = end_pfn -absent_pages_in_range (0 , end_pfn);/* We seem to lose 3 pages somewhere. Allow a bit of slack. */ if ((long )(e820ram - pxmram) >=1 *1024 *1024 ) { printk(KERN_ERR
include/asm-x86_64/e820.h +2 -3
@@ -49,10 +49,9 @@ extern void e820_reserve_resources(void)extern void e820_print_map (char *who);extern int e820_mapped (unsigned long start,unsigned long end,unsigned type); -extern void e820_bootmem_free (pg_data_t *pgdat,unsigned long start,unsigned long end);extern void e820_setup_gap (void ); -extern unsigned long e820_hole_size (unsigned long start_pfn, -unsigned long end_pfn); +extern void e820_register_active_regions (int nid, +unsigned long start_pfn,unsigned long end_pfn);extern void __init parse_memopt (char *p,char **end);extern void __init parse_memmapopt (char *p,char **end);
include/asm-x86_64/proto.h +0 -2
@@ -24,8 +24,6 @@ extern void mtrr_bp_init(void);#define mtrr_bp_init () do {} while (0)#endif extern void init_memory_mapping (unsigned long start,unsigned long end); -extern void size_zones (unsigned long *z,unsigned long *h, -unsigned long start_pfn,unsigned long end_pfn);extern void system_call (void );extern int kernel_syscall (void );
--
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>
PATCH 5/7 Have ia64 use add_active_range() and free_area_init_nodes
In reply to Mel GormanSize zones and holes in an architecture independent manner for ia64.
This has only been compile-tested due to lack of a suitable test machine.
arch/ia64/Kconfig | 3 + arch/ia64/mm/contig.c | 60 +++++---------------------------------- arch/ia64/mm/discontig.c | 41 +++----------------------- arch/ia64/mm/init.c | 12 +++++++ arch/x86_64/mm/k8topology.c | 3 - include/asm-ia64/meminit.h | 1 6 files changed, 30 insertions(+), 90 deletions(-)
arch/ia64/Kconfig +3 -0
@@ -352,6 +352,9 @@ config NUMA Access). This option is for configuring high-end multiprocessor server systems. If in doubt, say N. +config ARCH_POPULATES_NODE_MAP + def_bool y + # VIRTUAL_MEM_MAP and FLAT_NODE_MEM_MAP are functionally equivalent. # VIRTUAL_MEM_MAP has been retained for historical reasons. config VIRTUAL_MEM_MAP
arch/ia64/mm/contig.c +8 -52
102 lines not on this page · raw message
arch/ia64/mm/discontig.c +6 -35
67 lines not on this page · raw message
arch/ia64/mm/init.c +12 -0
@@ -539,6 +539,18 @@ find_largest_hole (u64 start, u64 end, v last_end = end;return 0 ; } + +int __init +register_active_ranges (u64 start,u64 end,void *nid) +{ +BUG_ON (nid ==NULL ); +BUG_ON (*(unsigned long *)nid >=MAX_NUMNODES ); + +add_active_range (*(unsigned long *)nid, +__pa (start) >>PAGE_SHIFT , +__pa (end) >>PAGE_SHIFT ); +return 0 ; +}#endif /* CONFIG_VIRTUAL_MEM_MAP */ static int __init
arch/x86_64/mm/k8topology.c +0 -3
@@ -149,9 +149,6 @@ int __init k8_scan_nodes(unsigned long s prevbase = base; -e820_register_active_regions (nodeid, - nodes[nodeid].start >>PAGE_SHIFT , - nodes[nodeid].end >>PAGE_SHIFT );node_set (nodeid, nodes_parsed); }
include/asm-ia64/meminit.h +1 -0
@@ -56,6 +56,7 @@ extern void efi_memmap_init(unsigned lonextern unsigned long vmalloc_end;extern struct page *vmem_map;extern int find_largest_hole (u64 start,u64 end,void *arg); +extern int register_active_ranges (u64 start,u64 end,void *arg);extern int create_mem_map_page_table (u64 start,u64 end,void *arg);#endif
--
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>
PATCH 6/7 Break out memory initialisation code from page_alloc.c to mem_init.c
In reply to Mel Gormanpage_alloc.c contains a large amount of memory initialisation code. This patch breaks out the initialisation code to a separate file to make page_alloc.c a bit easier to read.
Makefile | 2 mem_init.c | 1040 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ page_alloc.c | 1021 ----------------------------------------------------- 3 files changed, 1041 insertions(+), 1022 deletions(-)
mm/Makefile +1 -1
@@ -8,7 +8,7 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o vmalloc.o obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ - page_alloc.o page-writeback.o pdflush.o \ + page_alloc.o mem_init.o page-writeback.o pdflush.o \ readahead.o swap.o truncate.o vmscan.o \ prio_tree.o util.o mmzone.o $(mmu-y)
mm/mem_init.c +1040 -0
1,040 lines not on this page · raw message
mm/page_alloc.c +0 -1021
1,056 lines not on this page · raw message
--
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>
PATCH 7/7 Print out debugging information during initialisation
In reply to Mel GormanThe zone and hole sizing code is new and unexpected problems showed up on machines that were not covered by the pre-release tests. This patch prints out useful information when those unexpected situations occur.
It is not expected that this patch become a permanent part of the set.
mem_init.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 47 insertions(+), 4 deletions(-)
mm/mem_init.c +47 -4
@@ -593,6 +593,7 @@ static __meminit void init_currently_emp }#ifdef CONFIG_ARCH_POPULATES_NODE_MAP +/* Note: nid == MAX_NUMNODES returns first region */ static int __init first_active_region_index_in_nid (int nid) {
@@ -645,13 +646,24 @@ void __init free_bootmem_with_active_regfor_each_active_range_index_in_nid (i, nid) {unsigned long size_pages =0 ;unsigned long end_pfn = early_node_map[i].end_pfn; -if (early_node_map[i].start_pfn >= max_low_pfn) +if (early_node_map[i].start_pfn >= max_low_pfn) { +printk ("start_pfn %lu >= %lu\n" , early_node_map[i].start_pfn, + max_low_pfn);continue ; + } -if (end_pfn > max_low_pfn) +if (end_pfn > max_low_pfn) { +printk ("end_pfn %lu going back to %lu\n" , early_node_map[i].end_pfn, + max_low_pfn); end_pfn = max_low_pfn; + } size_pages = end_pfn - early_node_map[i].start_pfn; +printk ("free_bootmem_node(%d, %lu, %lu) :::: pfn ranges (%d, %lu, %lu)\n" , + early_node_map[i].nid, +PFN_PHYS (early_node_map[i].start_pfn), +PFN_PHYS (size_pages), + early_node_map[i].nid, early_node_map[i].start_pfn, end_pfn);free_bootmem_node (NODE_DATA (early_node_map[i].nid),PFN_PHYS (early_node_map[i].start_pfn),PFN_PHYS (size_pages));
@@ -661,10 +673,15 @@ void __init free_bootmem_with_active_regvoid __init sparse_memory_present_with_active_regions (int nid) {unsigned int i; -for_each_active_range_index_in_nid (i, nid) +for_each_active_range_index_in_nid (i, nid) { +printk ("memory_present(%d, %lu, %lu)\n" , + early_node_map[i].nid, + early_node_map[i].start_pfn, + early_node_map[i].end_pfn);memory_present (early_node_map[i].nid, early_node_map[i].start_pfn, early_node_map[i].end_pfn); + } } void __init get_pfn_range_for_nid(unsigned int nid,
@@ -722,6 +739,8 @@ unsigned long __init __absent_pages_in_runsigned long prev_end_pfn =0 , hole_pages =0 ;unsigned long start_pfn; +printk ("__absent_pages_in_range(%d, %lu, %lu) = " , nid, + range_start_pfn, range_end_pfn);/* Find the end_pfn of the first active range of pfns in the node */ i =first_active_region_index_in_nid (nid); prev_end_pfn = early_node_map[i].start_pfn;
@@ -749,6 +768,8 @@ unsigned long __init __absent_pages_in_r prev_end_pfn = early_node_map[i].end_pfn; } +printk ("%lu\n" , hole_pages); +return hole_pages; }
@@ -911,6 +932,9 @@ void __init add_active_range(unsigned in {unsigned int i; +printk ("add_active_range(%d, %lu, %lu): " , + nid, start_pfn, end_pfn); +/* Merge with existing active regions if possible */ for (i =0 ; early_node_map[i].end_pfn; i++) {if (early_node_map[i].nid != nid)
@@ -918,12 +942,15 @@ void __init add_active_range(unsigned in/* Skip if an existing region covers this new one */ if (start_pfn >= early_node_map[i].start_pfn && - end_pfn <= early_node_map[i].end_pfn) + end_pfn <= early_node_map[i].end_pfn) { +printk ("Existing\n" );return ; + }/* Merge forward if suitable */ if (start_pfn <= early_node_map[i].end_pfn && end_pfn > early_node_map[i].end_pfn) { +printk ("Merging forward\n" ); early_node_map[i].end_pfn = end_pfn;return ; }
@@ -931,6 +958,7 @@ void __init add_active_range(unsigned in/* Merge backward if suitable */ if (start_pfn < early_node_map[i].end_pfn && end_pfn >= early_node_map[i].start_pfn) { +printk ("Merging backwards\n" ); early_node_map[i].start_pfn = start_pfn;return ; }
@@ -942,6 +970,7 @@ void __init add_active_range(unsigned inreturn ; } +printk ("New\n" ); early_node_map[i].nid = nid; early_node_map[i].start_pfn = start_pfn; early_node_map[i].end_pfn = end_pfn;
@@ -971,6 +1000,14 @@ static void __init sort_node_map(void)sort (early_node_map, num,sizeof (struct node_active_region ), cmp_node_active_region,NULL ); + +printk ("Dumping sorted node map\n" ); +for (num =0 ; early_node_map[num].end_pfn; num++) { +printk ("entry %lu: %d %lu -> %lu\n" , num, + early_node_map[num].nid, + early_node_map[num].start_pfn, + early_node_map[num].end_pfn); + } }/* Find the lowest pfn for a node. This depends on a sorted early_node_map */
@@ -1012,6 +1049,10 @@ void __init free_area_init_nodes(unsigneunsigned long nid;int zone_index; +printk ("free_area_init_nodes(%lu, %lu, %lu, %lu)\n" , + arch_max_dma_pfn, arch_max_dma32_pfn, + arch_max_low_pfn, arch_max_high_pfn); +/* Record where the zone boundaries are */ memset (arch_zone_lowest_possible_pfn,0 ,sizeof (arch_zone_lowest_possible_pfn));
@@ -1028,6 +1069,8 @@ void __init free_area_init_nodes(unsigne arch_zone_highest_possible_pfn[zone_index-1 ]; } +printk ("free_area_init_nodes(): find_min_pfn = %lu\n" ,find_min_pfn_with_active_regions ()); +/* Regions in the early_node_map can be in any order */ sort_node_map ();
--
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 1 line · Mel Gorman
This is V3 of the patchset to size zones and memory holes in an
...
FYI, I applied the patches to a recent kernel & booted on a large SGI system. No problem aside from what I assume is a very large number of debug messages.
------
Linux version 2.6.17-tony (steiner@attica) (gcc version 4.1.0 (SUSE Linux)) #5 SMP PREEMPT Tue Apr 18 14:01:54 CDT 2006 EFI v1.10 by INTEL: SALsystab=0x6002c51df0 ACPI 2.0=0x6002c51ee0
Number of logical nodes in system = 512
Number of memory chunks in system = 512
SAL 2.9: SGI SN2 version 1.10
SAL Platform features: ITC_Drift
SAL: AP wakeup using external interrupt vector 0x12
No logical to physical processor mapping available
ACPI: Local APIC address c0000000fee00000
ACPI: Error parsing MADT - no IOSAPIC entriesregister_intr: No IOSAPIC for GSI 52
512 CPUs available, 512 CPUs total
MCA related initialization done
SGI SAL version 1.10add_active_range(0, 25168900, 25235456): Newadd_active_range(0, 25236375, 25419776): Newadd_active_range(0, 27262976, 27516927): Newadd_active_range(0, 29360128, 29614080): Newadd_active_range(1, 92277760, 92528640): New
...add_active_range(511, 34322242024, 34322242047): Newadd_active_range(511, 34322243072, 34322243417): Newadd_active_range(511, 34322243432, 34322243460): Newadd_active_range(511, 34322243488, 34322243500): New
Virtual mem_map starts at 0xa0007e407d270000free_area_init_nodes(68719476736, 68719476736, 34322243584, 34322243584)free_area_init_nodes(): find_min_pfn = 25168900
Dumping sorted node map
entry 0: 0 25168900 -> 25235456
entry 1: 0 25236375 -> 25419776
entry 2: 0 27262976 -> 27516927
entry 3: 0 29360128 -> 29614080
entry 4: 1 92277760 -> 92528640
entry 5: 1 94371840 -> 94625792
entry 6: 1 96468992 -> 96722944
...
entry 1536: 511 34321989632 -> 34322242001
entry 1537: 511 34322242016 -> 34322242022
entry 1538: 511 34322242024 -> 34322242047
entry 1539: 511 34322243072 -> 34322243417
entry 1540: 511 34322243432 -> 34322243460
entry 1541: 511 34322243488 -> 34322243500__absent_pages_in_range(0, 25168900, 68719476736) = 3687320__absent_pages_in_range(0, 68719476736, 68719476736) = 0__absent_pages_in_range(0, 68719476736, 34322243584) = 0__absent_pages_in_range(0, 34322243584, 34322243584) = 0__absent_pages_in_range(0, 25168900, 68719476736) = 3687320
...__absent_pages_in_range(511, 34322243584, 34322243584) = 0__absent_pages_in_range(511, 25168900, 68719476736) = 3687485__absent_pages_in_range(511, 68719476736, 68719476736) = 0__absent_pages_in_range(511, 68719476736, 34322243584) = 0__absent_pages_in_range(511, 34322243584, 34322243584) = 0
Built 512 zonelists
Kernel command line: BOOT_IMAGE=net0:jfs/tonys ro hashdist=1 dhash_entries=2097152 ihash_entries=2097152 rhash_entries=2097152 thash_entries=2097152 console=ttySG0,38400n8 kdb=on noprobe root=/dev/sda5
PID hash table entries: 4096 (order: 12, 32768 bytes)
Console: colour dummy device 80x25
Memory: 4639378784k/4655642784k available (7021k code, 16279040k reserved, 4361k data, 736k init)
(essentially the same numbers as with a kernel w/o the patches)
McKinley Errata 9 workaround not needed; disabling it
--
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 · Jack Steiner
Quoted 1 line · Mel Gorman
This is V3 of the patchset to size zones and memory holes in an
...
FYI, I applied the patches to a recent kernel & booted on a large SGI system.
Very cool, thanks for testing. I'm glad to see the assumptions related to the size of node_map held up for a large machine.
Quoted 3 lines
No problem aside from what I assume is a very large number of debug messages.
The debug messages are all in patch 7/7 and will be dropped before I try and push this to -mm. The patch was included here in case a machine failed to boot so I could figure out what went wrong.
Quoted 63 lines
------
Linux version 2.6.17-tony (steiner@attica) (gcc version 4.1.0 (SUSE Linux)) #5 SMP PREEMPT Tue Apr 18 14:01:54 CDT 2006 EFI v1.10 by INTEL: SALsystab=0x6002c51df0 ACPI 2.0=0x6002c51ee0
Number of logical nodes in system = 512
Number of memory chunks in system = 512
SAL 2.9: SGI SN2 version 1.10
SAL Platform features:ITC_Drift
SAL: AP wakeup using external interrupt vector0x12
No logical to physical processor mapping available
ACPI: Local APIC addressc0000000fee00000
ACPI: Error parsing MADT - no IOSAPIC entriesregister_intr: No IOSAPIC for GSI 52
512 CPUs available, 512 CPUs total
MCA related initialization done
SGI SAL version 1.10add_active_range(0, 25168900, 25235456): Newadd_active_range(0, 25236375, 25419776): Newadd_active_range(0, 27262976, 27516927): Newadd_active_range(0, 29360128, 29614080): Newadd_active_range(1, 92277760, 92528640): New
...add_active_range(511, 34322242024, 34322242047): Newadd_active_range(511, 34322243072, 34322243417): Newadd_active_range(511, 34322243432, 34322243460): Newadd_active_range(511, 34322243488, 34322243500): New
Virtualmem_mapstarts at0xa0007e407d270000free_area_init_nodes(68719476736, 68719476736, 34322243584, 34322243584)free_area_init_nodes():find_min_pfn= 25168900
Dumping sorted node map
entry 0: 0 25168900 -> 25235456
entry 1: 0 25236375 -> 25419776
entry 2: 0 27262976 -> 27516927
entry 3: 0 29360128 -> 29614080
entry 4: 1 92277760 -> 92528640
entry 5: 1 94371840 -> 94625792
entry 6: 1 96468992 -> 96722944
...
entry 1536: 511 34321989632 -> 34322242001
entry 1537: 511 34322242016 -> 34322242022
entry 1538: 511 34322242024 -> 34322242047
entry 1539: 511 34322243072 -> 34322243417
entry 1540: 511 34322243432 -> 34322243460
entry 1541: 511 34322243488 -> 34322243500__absent_pages_in_range(0, 25168900, 68719476736)= 3687320__absent_pages_in_range(0, 68719476736, 68719476736)= 0__absent_pages_in_range(0, 68719476736, 34322243584)= 0__absent_pages_in_range(0, 34322243584, 34322243584)= 0__absent_pages_in_range(0, 25168900, 68719476736)= 3687320
...__absent_pages_in_range(511, 34322243584, 34322243584)= 0__absent_pages_in_range(511, 25168900, 68719476736)= 3687485__absent_pages_in_range(511, 68719476736, 68719476736)= 0__absent_pages_in_range(511, 68719476736, 34322243584)= 0__absent_pages_in_range(511, 34322243584, 34322243584)= 0
Built 512 zonelists
Kernel command line: BOOT_IMAGE=net0:jfs/tonys ro hashdist=1 dhash_entries=2097152 ihash_entries=2097152 rhash_entries=2097152 thash_entries=2097152 console=ttySG0,38400n8 kdb=on noprobe root=/dev/sda5
PID hash table entries: 4096 (order: 12, 32768 bytes)
Console: colour dummy device 80x25
Memory: 4639378784k/4655642784k available (7021k code, 16279040k reserved, 4361k data, 736k init)
(essentially the same numbers as with a kernel w/o the patches)
McKinley Errata 9 workaround not needed; disabling it
Signature · 9 lines
Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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>