Replace 'numnodes' with 'node_online_map'
Subsystems (12)
cover Replace 'numnodes' with 'node_online_map'
The next 10 messages will contain 10 patches to remove the global variable 'numnodes' and replace it's use with manipulations of 'node_online_map'. This will remove the requirement that nodes be numbered sequentially [0 ... (numnodes-1)] with no gaps in the numbering. The removal of this requirement will facilitate node HotPlug as well as remove the need for some of the arch-specific node renumbering schemes in the kernel. Several architectures have to map their native node numbers to 'Linux' node numbers, and I hope that some of this may be removed now.
The following 10 patches replace numnodes in arch-independent code and the 9 architectures that reference numnodes (alpha, arm, i386, ia64, m32r, mips, parisc, ppc64, & x86_64). A rollup patch has been lightly tested (aka: booted) on x86 & ppc64.
Cheers!
-Matt
RFC PATCH 1/10 Replace 'numnodes' with 'node_online_map' - alpha
1/10 - Replace numnodes with node_online_map for alpha
[mcd@arrakis node_online_map]$ diffstat arch-alpha.patch
numa.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
-Matt
arch/alpha/mm/numa.c +5 -5
@@ -246,7 +246,7 @@ setup_memory_node(int nid, void *kernel_reserve_bootmem_node (NODE_DATA (nid),PFN_PHYS (bootmap_start), bootmap_size);printk (" reserving pages %ld:%ld\n" , bootmap_start, bootmap_start+PFN_UP (bootmap_size)); - numnodes++; +node_set_online (nid); }void __init
@@ -256,7 +256,7 @@ setup_memory(void *kernel_end)show_mem_layout (); - numnodes =0 ; +nodes_clear (node_online_map); min_low_pfn = ~0UL ; max_low_pfn =0UL ;
@@ -303,7 +303,7 @@ void __init paging_init(void)*/ dma_local_pfn =virt_to_phys ((char *)MAX_DMA_ADDRESS ) >>PAGE_SHIFT ; -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {unsigned long start_pfn = node_bdata[nid].node_boot_start >>PAGE_SHIFT ;unsigned long end_pfn = node_bdata[nid].node_low_pfn;
@@ -332,7 +332,7 @@ void __init mem_init(void) high_memory = (void *)__va (max_low_pfn <<PAGE_SHIFT ); reservedpages =0 ; -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {/* * This will free up the bootmem, ie, slot 0 memory */
@@ -372,7 +372,7 @@ show_mem(void)printk ("\nMem-info:\n" );show_free_areas ();printk ("Free swap: %6ldkB\n" , nr_swap_pages<<(PAGE_SHIFT -10 )); -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {struct page * lmem_map =node_mem_map (nid); i =node_spanned_pages (nid);while (i-- >0 ) {
RFC PATCH 2/10 Replace 'numnodes' with 'node_online_map' - arm
In reply to Matthew Dobson2/10 - Replace numnodes with node_online_map for arm
[mcd@arrakis node_online_map]$ diffstat arch-arm.patch
arch/arm/mm/init.c | 34 +++++++++++++++------------------- arch/arm/mm/mm-armv.c | 2 +- arch/arm26/mm/init.c | 3 ++- include/asm-arm/arch-pxa/memory.h | 2 -- 4 files changed, 18 insertions(+), 23 deletions(-)
-Matt
arch/arm/mm/init.c +15 -19
@@ -55,7 +55,7 @@ void show_mem(void)show_free_areas ();printk ("Free swap: %6ldkB\n" , nr_swap_pages<<(PAGE_SHIFT -10 )); -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) {struct page *page, *end; page =NODE_MEM_MAP (node);
@@ -178,18 +178,14 @@ find_memend_and_nodes(struct meminfo *mi node = mi->bank[i].node; -if (node >= numnodes) { - numnodes = node +1 ; - -/* -* Make sure we haven't exceeded the maximum number -* of nodes that we have in this configuration. If -* we have, we're in trouble. (maybe we ought to -* limit, instead of bugging?) -*/ -if (numnodes >MAX_NUMNODES ) -BUG (); - } +/* +* Make sure we haven't exceeded the maximum number of nodes +* that we have in this configuration. If we have, we're in +* trouble. (maybe we ought to limit, instead of bugging?) +*/ +if (node >=MAX_NUMNODES ) +BUG (); +node_set_online (node);/* * Get the start and end pfns for this bank
@@ -211,7 +207,7 @@ find_memend_and_nodes(struct meminfo *mi* Calculate the number of pages we require to * store the bootmem bitmaps. */ -for (i =0 ; i < numnodes; i++) { +for_each_online_node (i) {if (np[i].end ==0 )continue ;
@@ -380,13 +376,13 @@ static void __init bootmem_init(struct m* (we could also do with rolling bootmem_init and paging_init * into one generic "memory_init" type function). */ - np += numnodes -1 ; -for (node = numnodes -1 ; node >=0 ; node--, np--) { + np +=num_online_nodes () -1 ; +for (node =num_online_nodes () -1 ; node >=0 ; node--, np--) {/* * If there are no pages in this node, ignore it. * Note that node 0 must always have some pages. */ -if (np->end ==0 ) { +if (np->end ==0 || !node_online (node)) {if (node ==0 )BUG ();continue ;
@@ -449,7 +445,7 @@ void __init paging_init(struct meminfo */* * initialise the zones within each node */ -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) {unsigned long zone_size[MAX_NR_ZONES ];unsigned long zhole_size[MAX_NR_ZONES ];struct bootmem_data *bdata;
@@ -558,7 +554,7 @@ void __init mem_init(void)create_memmap_holes (&meminfo);/* this will put all unused low memory onto the freelists */ -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) {pg_data_t *pgdat =NODE_DATA (node);if (pgdat->node_spanned_pages !=0 )
arch/arm/mm/mm-armv.c +1 -1
@@ -681,6 +681,6 @@ void __init create_memmap_holes(struct m {int node; -for (node =0 ; node < numnodes; node++) +for_each_online_node (node)free_unused_memmap_node (node, mi); }
arch/arm26/mm/init.c +2 -1
@@ -156,7 +156,8 @@ find_memend_and_nodes(struct meminfo *mi {unsigned int memend_pfn =0 ; - numnodes =1 ; +nodes_clear (node_online_map); +node_set_online (0 ); np->bootmap_pages =0 ;
include/asm-arm/arch-pxa/memory.h +0 -2
@@ -37,8 +37,6 @@* node 3: 0xac000000-0xafffffff --> 0xcc000000-0xcfffffff */ -#define NR_NODES 4 -/* * Given a kernel address, find the home node of the underlying memory. */
RFC PATCH 3/10 Replace 'numnodes' with 'node_online_map' - i386
In reply to Matthew Dobson3/10 - Replace numnodes with node_online_map for i386
[mcd@arrakis node_online_map]$ diffstat arch-i386.patch
arch/i386/kernel/mpparse.c | 4 ++-- arch/i386/kernel/numaq.c | 10 ++++------ arch/i386/kernel/srat.c | 32 ++++++++++++++++++-------------- arch/i386/mm/discontig.c | 28 +++++++++++++++++----------- arch/i386/pci/numa.c | 7 ++++--- include/asm-i386/mach-numaq/mach_apic.h | 10 ++++++---- 6 files changed, 51 insertions(+), 40 deletions(-)
-Matt
arch/i386/kernel/mpparse.c +2 -2
@@ -309,8 +309,8 @@ static void __init MP_translation_info (printk (KERN_ERR "MAX_MPC_ENTRY exceeded!\n" ); else translation_table[mpc_record] = m;/* stash this for later */ -if (m->trans_quad+1 > numnodes) - numnodes = m->trans_quad+1 ; +if (m->trans_quad <MAX_NUMNODES && !node_online (m->trans_quad)) +node_set_online (m->trans_quad); }/*
arch/i386/kernel/numaq.c +4 -6
@@ -40,8 +40,7 @@ extern long node_start_pfn[], node_end_p* Function: smp_dump_qct() * * Description: gets memory layout from the quad config table. This -* function also increments numnodes with the number of nodes (quads) -* present. +* function also updates node_online_map with the nodes (quads) present. */ static void __init smp_dump_qct (void ) {
@@ -50,11 +49,10 @@ static void __init smp_dump_qct(void)struct sys_cfg_data *scd = (struct sys_cfg_data *)__va (SYS_CFG_DATA_PRIV_ADDR ); - numnodes =0 ; -for (node =0 ; node <MAX_NUMNODES ; node++) { -if (scd->quads_present31_0 & (1 << node)) { +nodes_clear (node_online_map); +for_each_node (node) { +if (scd->quads_present31_0 & (1 << node)) {node_set_online (node); - numnodes++; eq = &scd->eq[node];/* Convert to pages */ node_start_pfn[node] = MB_TO_PAGES(
arch/i386/kernel/srat.c +18 -14
@@ -232,18 +232,22 @@ static int __init acpi20_parse_srat(stru* a set of sequential node IDs starting at zero. (ACPI doesn't seem * to specify the range of _PXM values.) */ - numnodes =0 ;/* init total nodes in system */ +/* +* MCD - we no longer HAVE to number nodes sequentially. PXM domain +* numbers could go as high as 256, and MAX_NUMNODES for i386 is typically +* 32, so we will continue numbering them in this manner until MAX_NUMNODES +* approaches MAX_PXM_DOMAINS for i386. +*/ +nodes_clear (node_online_map);for (i =0 ; i <MAX_PXM_DOMAINS ; i++) {if (BMAP_TEST (pxm_bitmap, i)) { - pxm_to_nid_map[i] = numnodes; - nid_to_pxm_map[numnodes] = i; -node_set_online (numnodes); - ++numnodes; + nid =num_online_nodes (); + pxm_to_nid_map[i] = nid; + nid_to_pxm_map[nid] = i; +node_set_online (nid); } } - -if (numnodes ==0 ) -BUG (); +BUG_ON (num_online_nodes () ==0 );/* set cnode id in memory chunk structure */ for (i =0 ; i < num_memory_chunks; i++)
@@ -254,7 +258,7 @@ static int __init acpi20_parse_srat(struprintk ("%02X " , pxm_bitmap[i]); }printk ("\n" ); -printk ("Number of logical nodes in system = %d\n" , numnodes); +printk ("Number of logical nodes in system = %d\n" ,num_online_nodes ());printk ("Number of memory chunks in system = %d\n" , num_memory_chunks);for (j =0 ; j < num_memory_chunks; j++){
@@ -265,7 +269,7 @@ static int __init acpi20_parse_srat(stru }/*calculate node_start_pfn/node_end_pfn arrays*/ -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {int been_here_before =0 ;for (j =0 ; j < num_memory_chunks; j++){
@@ -397,7 +401,7 @@ static void __init get_zholes_init(void)int first;unsigned long end =0 ; -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) { first =1 ;for (c =0 ; c < num_memory_chunks; c++){if (node_memory_chunk[c].nid == nid) {
@@ -425,8 +429,8 @@ unsigned long * __init get_zholes_size(i zholes_size_init++;get_zholes_init (); } -if ((nid >= numnodes) | (nid >=MAX_NUMNODES )) -printk ("%s: nid = %d is invalid. numnodes = %d" , - __FUNCTION__, nid, numnodes); +if (nid >=MAX_NUMNODES || !node_online (nid)) +printk ("%s: nid = %d is invalid/offline. num_online_nodes = %d" , + __FUNCTION__, nid,num_online_nodes ());return &zholes_size[nid *MAX_NR_ZONES ]; }
arch/i386/mm/discontig.c +17 -11
@@ -42,7 +42,7 @@ bootmem_data_t node0_bdata;* numa interface - we expect the numa architecture specfic code to have * populated the following initialisation. * -* 1) numnodes - the total number of nodes configured in the system +* 1) node_online_map - the map of all nodes configured (online) in the system * 2) physnode_map - the mapping between a pfn and owning node * 3) node_start_pfn - the starting page frame number for a node * 3) node_end_pfn - the ending page fram number for a node
@@ -94,12 +94,12 @@ int __init get_memcfg_numa_flat(void)/* Run the memory configuration and find the top of memory. */ find_max_pfn (); - node_start_pfn[0 ] =0 ; - node_end_pfn[0 ] = max_pfn; + node_start_pfn[0 ] =0 ; + node_end_pfn[0 ] = max_pfn;/* Indicate there is one node available. */ +nodes_clear (node_online_map);node_set_online (0 ); - numnodes =1 ;return 1 ; }
@@ -184,7 +184,9 @@ void __init remap_numa_kva(void)unsigned long pfn;int node; -for (node =1 ; node < numnodes; ++node) { +for_each_online_node (node) { +if (node ==0 ) +continue ;for (pfn=0 ; pfn < node_remap_size[node]; pfn +=PTRS_PER_PTE ) { vaddr = node_remap_start_vaddr[node]+(pfn<<PAGE_SHIFT ); set_pmd_pfn((ulong) vaddr,
@@ -199,7 +201,9 @@ static unsigned long calculate_numa_remaint nid;unsigned long size, reserve_pages =0 ; -for (nid =1 ; nid < numnodes; nid++) { +for_each_online_node (nid) { +if (nid ==0 ) +continue ;/* calculate the size of the mem_map needed in bytes */ size = (node_end_pfn[nid] - node_start_pfn[nid] +1 ) *sizeof (struct page ) +sizeof (pg_data_t);
@@ -249,7 +253,7 @@ unsigned long __init setup_memory(void)get_memcfg_numa ();/* Fill in the physnode_map */ -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {printk ("Node: %d, start_pfn: %ld, end_pfn: %ld\n" , nid, node_start_pfn[nid], node_end_pfn[nid]); printk(" Setting physnode_map array to node %d for pfns:\n ",
@@ -286,7 +290,7 @@ unsigned long __init setup_memory(void)printk ("Low memory ends at vaddr %08lx\n" , (ulong )pfn_to_kaddr (max_low_pfn)); -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) { node_remap_start_vaddr[nid] =pfn_to_kaddr ( (highstart_pfn + reserve_pages) - node_remap_offset[nid]);allocate_pgdat (nid);
@@ -298,7 +302,7 @@ unsigned long __init setup_memory(void)printk ("High memory starts at vaddr %08lx\n" , (ulong )pfn_to_kaddr (highstart_pfn)); vmalloc_earlyreserve = reserve_pages *PAGE_SIZE ; -for (nid =0 ; nid < numnodes; nid++) +for_each_online_node (nid)find_max_pfn_node (nid);NODE_DATA (0 )->bdata = &node0_bdata;
@@ -379,14 +383,16 @@ void __init zone_sizes_init(void)* Clobber node 0's links and NULL out pgdat_list before starting. */ pgdat_list =NULL ; -for (nid = numnodes -1 ; nid >=0 ; nid--) { +for (nid =MAX_NUMNODES -1 ; nid >=0 ; nid--) { +if (!node_online (nid)) +continue ;if (nid)memset (NODE_DATA (nid),0 ,sizeof (pg_data_t));NODE_DATA (nid)->pgdat_next = pgdat_list; pgdat_list =NODE_DATA (nid); } -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {unsigned long zones_size[MAX_NR_ZONES ] = {0 ,0 ,0 };unsigned long *zholes_size;unsigned int max_dma;
arch/i386/pci/numa.c +4 -3
@@ -112,14 +112,15 @@ static int __init pci_numa_init(void)return 0 ; pci_root_bus =pcibios_scan_root (0 ); -if (numnodes >1 ) { -for (quad =1 ; quad < numnodes; ++quad) { +if (num_online_nodes () >1 ) +for_each_online_node (quad) { +if (quad ==0 ) +continue ;printk ("Scanning PCI bus %d for quad %d\n" ,QUADLOCAL2BUS (quad,0 ), quad);pci_scan_bus (QUADLOCAL2BUS (quad,0 ), &pci_root_ops,NULL ); } - }return 0 ; }
include/asm-i386/mach-numaq/mach_apic.h +6 -4
@@ -112,13 +112,15 @@ static inline int mpc_apic_id(struct mpcstatic inline void setup_portio_remap (void ) { -if (numnodes <=1 ) +int num_quads =num_online_nodes (); + +if (num_quads <=1 )return ; -printk ("Remapping cross-quad port I/O for %d quads\n" , numnodes); - xquad_portio =ioremap (XQUAD_PORTIO_BASE , numnodes*XQUAD_PORTIO_QUAD ); +printk ("Remapping cross-quad port I/O for %d quads\n" , num_quads); + xquad_portio =ioremap (XQUAD_PORTIO_BASE , num_quads*XQUAD_PORTIO_QUAD );printk ("xquad_portio vaddr 0x%08lx, len %08lx\n" , - (u_long ) xquad_portio, (u_long ) numnodes*XQUAD_PORTIO_QUAD ); + (u_long ) xquad_portio, (u_long ) num_quads*XQUAD_PORTIO_QUAD ); }static inline int check_phys_apicid_present (int boot_cpu_physical_apicid)
RFC PATCH 4/10 Replace 'numnodes' with 'node_online_map' - ia64
In reply to Matthew Dobson4/10 - Replace numnodes with node_online_map for ia64
[mcd@arrakis node_online_map]$ diffstat arch-ia64.patch
arch/ia64/kernel/acpi.c | 22 +++++----- arch/ia64/kernel/topology.c | 3 - arch/ia64/mm/discontig.c | 70 ++++++++++++++++++-------------- arch/ia64/sn/kernel/io_init.c | 2 arch/ia64/sn/kernel/setup.c | 16 +++---- arch/ia64/sn/kernel/sn2/prominfo_proc.c | 13 +++-- arch/ia64/sn/kernel/sn2/sn2_smp.c | 14 ++---- include/asm-ia64/mmzone.h | 11 ++--- include/asm-ia64/nodedata.h | 2 include/asm-ia64/numa.h | 2 10 files changed, 85 insertions(+), 70 deletions(-)
-Matt
arch/ia64/kernel/acpi.c +13 -9
@@ -445,16 +445,20 @@ acpi_numa_arch_fixup (void)return ; } +/* +* MCD - This can probably be dropped now. No need for pxm ID to node ID +* mapping with sparse node numbering iff MAX_PXM_DOMAINS <= MAX_NUMNODES. +*/ /* calculate total number of nodes in system from PXM bitmap */ - numnodes =0 ;/* init total nodes in system */ -memset (pxm_to_nid_map,-1 ,sizeof (pxm_to_nid_map));memset (nid_to_pxm_map,-1 ,sizeof (nid_to_pxm_map)); +nodes_clear (node_online_map);for (i =0 ; i <MAX_PXM_DOMAINS ; i++) {if (pxm_bit_test (i)) { - pxm_to_nid_map[i] = numnodes; -node_set_online (numnodes); - nid_to_pxm_map[numnodes++] = i; +int nid =num_online_nodes (); + pxm_to_nid_map[i] = nid; + nid_to_pxm_map[nid] = i; +node_set_online (nid); } }
@@ -463,7 +467,7 @@ acpi_numa_arch_fixup (void) node_memblk[i].nid = pxm_to_nid_map[node_memblk[i].nid];/* assign memory bank numbers for each chunk on each node */ -for (i =0 ; i < numnodes; i++) { +for_each_online_node (i) {int bank; bank =0 ;
@@ -476,7 +480,7 @@ acpi_numa_arch_fixup (void)for (i =0 ; i < srat_num_cpus; i++) node_cpuid[i].nid = pxm_to_nid_map[node_cpuid[i].nid]; -printk (KERN_INFO "Number of logical nodes in system = %d\n" , numnodes); +printk (KERN_INFO "Number of logical nodes in system = %d\n" ,num_online_nodes ());printk (KERN_INFO "Number of memory chunks in system = %d\n" , num_node_memblks);if (!slit_table)return ;
@@ -496,8 +500,8 @@ acpi_numa_arch_fixup (void)#ifdef SLIT_DEBUG printk ("ACPI 2.0 SLIT locality table:\n" ); -for (i =0 ; i < numnodes; i++) { -for (j =0 ; j < numnodes; j++) +for_each_online_node (i) { +for_each_online_node (j)printk ("%03d " ,node_distance (i,j));printk ("\n" ); }
arch/ia64/kernel/topology.c +2 -1
@@ -68,7 +68,8 @@ static int __init topology_init(void) }memset (sysfs_nodes,0 ,sizeof (struct node ) *MAX_NUMNODES ); -for (i =0 ; i < numnodes; i++) +/* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? */ +for_each_online_node (i)if ((err =register_node (&sysfs_nodes[i], i,0 ))) goto out;#endif
arch/ia64/mm/discontig.c +41 -29
189 lines not on this page · raw message
arch/ia64/sn/kernel/io_init.c +1 -1
@@ -382,7 +382,7 @@ void hubdev_init_node(nodepda_t * npda,struct hubdev_info *hubdev_info; -if (node >= numnodes)/* Headless/memless IO nodes */ +if (node >=num_online_nodes ())/* Headless/memless IO nodes */ hubdev_info = (struct hubdev_info *)alloc_bootmem_node(NODE_DATA(0), sizeof(struct
arch/ia64/sn/kernel/setup.c +8 -8
@@ -224,7 +224,7 @@ static void __init sn_check_for_wars(voi {int cnode; -for (cnode =0 ; cnode < numnodes; cnode++) +for_each_online_node (cnode)if (is_shub_1_1 (cnodeid_to_nasid (cnode))) shub_1_1_found =1 ; }
@@ -346,17 +346,17 @@ void __init sn_init_pdas(char **cmdline_memset (pda->cnodeid_to_nasid_table,-1 ,sizeof (pda->cnodeid_to_nasid_table)); -for (cnode =0 ; cnode < numnodes; cnode++) +for_each_online_node (cnode) pda->cnodeid_to_nasid_table[cnode] =pxm_to_nasid (nid_to_pxm_map[cnode]); - numionodes = numnodes; + numionodes =num_online_nodes ();scan_for_ionodes ();/* * Allocate & initalize the nodepda for each node. */ -for (cnode =0 ; cnode < numnodes; cnode++) { +for_each_online_node (cnode) { nodepdaindr[cnode] =alloc_bootmem_node (NODE_DATA (cnode),sizeof (nodepda_t));memset (nodepdaindr[cnode],0 ,sizeof (nodepda_t));
@@ -367,7 +367,7 @@ void __init sn_init_pdas(char **cmdline_/* * Allocate & initialize nodepda for TIOs. For now, put them on node 0. */ -for (cnode = numnodes; cnode < numionodes; cnode++) { +for (cnode =num_online_nodes (); cnode < numionodes; cnode++) { nodepdaindr[cnode] =alloc_bootmem_node (NODE_DATA (0 ),sizeof (nodepda_t));memset (nodepdaindr[cnode],0 ,sizeof (nodepda_t));
@@ -385,7 +385,7 @@ void __init sn_init_pdas(char **cmdline_* The following routine actually sets up the hubinfo struct * in nodepda. */ -for (cnode =0 ; cnode < numnodes; cnode++) { +for_each_online_node (cnode) {bte_init_node (nodepdaindr[cnode], cnode); }
@@ -431,7 +431,7 @@ void __init sn_cpu_init(void)if (ia64_sn_get_sapic_info (cpuphyid, &nasid, &subnode, &slice))BUG (); -for (i=0 ; i <NR_NODES ; i++) { +for (i=0 ; i <MAX_NUMNODES ; i++) {if (nodepdaindr[i]) { nodepdaindr[i]->phys_cpuid[cpuid].nasid = nasid; nodepdaindr[i]->phys_cpuid[cpuid].slice = slice;
@@ -484,7 +484,7 @@ void __init sn_cpu_init(void)int buddy_nasid; buddy_nasid =cnodeid_to_nasid (numa_node_id () == - numnodes -1 ?0 :numa_node_id () +1 ); +num_online_nodes () -1 ?0 :numa_node_id () +1 ); pda->pio_shub_war_cam_addr = (volatile unsigned long *)GLOBAL_MMR_ADDR (nasid,SH_PI_CAM_CONTROL );
arch/ia64/sn/kernel/sn2/prominfo_proc.c +7 -6
@@ -233,14 +233,13 @@ int __init prominfo_init(void)if (!ia64_platform_is ("sn2" ))return 0 ; - proc_entries =kmalloc (numnodes *sizeof (struct proc_dir_entry *), + proc_entries =kmalloc (num_online_nodes () *sizeof (struct proc_dir_entry *),GFP_KERNEL ); sgi_prominfo_entry =proc_mkdir ("sgi_prominfo" ,NULL ); -for (cnodeid =0 , entp = proc_entries; - cnodeid < numnodes; - cnodeid++, entp++) { + entp = proc_entries; +for_each_online_node (cnodeid) {sprintf (name,"node%d" , cnodeid); *entp =proc_mkdir (name, sgi_prominfo_entry); nasid =cnodeid_to_nasid (cnodeid);
@@ -254,6 +253,7 @@ int __init prominfo_init(void) (void *)nasid);if (p) p->owner =THIS_MODULE ; + entp++; }return 0 ;
@@ -265,12 +265,13 @@ void __exit prominfo_exit(void)unsigned cnodeid;char name[NODE_NAME_LEN ]; -for (cnodeid =0 , entp = proc_entries; - cnodeid < numnodes; cnodeid++, entp++) { + entp = proc_entries; + for (cnodeid) {remove_proc_entry ("fit" , *entp);remove_proc_entry ("version" , *entp);sprintf (name,"node%d" , cnodeid);remove_proc_entry (name, sgi_prominfo_entry); + entp++; }remove_proc_entry ("sgi_prominfo" ,NULL );kfree (proc_entries);
arch/ia64/sn/kernel/sn2/sn2_smp.c +6 -8
@@ -92,16 +92,15 @@ sn2_global_tlb_purge(unsigned long startvolatile unsigned long *ptc0, *ptc1;unsigned long flags =0 , data0, data1;struct mm_struct *mm = current->active_mm; -short nasids[NR_NODES ], nix; -DECLARE_BITMAP (nodes_flushed,NR_NODES ); - -bitmap_zero (nodes_flushed,NR_NODES ); +short nasids[MAX_NUMNODES ], nix; +nodemask_t nodes_flushed; +nodes_clear (nodes_flushed); i =0 ;for_each_cpu_mask (cpu, mm->cpu_vm_mask) { cnode =cpu_to_node (cpu); -__set_bit (cnode, nodes_flushed); +node_set (cnode, nodes_flushed); lcpu = cpu; i++; }
@@ -125,8 +124,7 @@ sn2_global_tlb_purge(unsigned long start } nix =0 ; -for (cnode =find_first_bit (&nodes_flushed,NR_NODES ); cnode <NR_NODES ; - cnode =find_next_bit (&nodes_flushed,NR_NODES , ++cnode)) +for_each_node_mask (cnode, nodes_flushed) nasids[nix++] =cnodeid_to_nasid (cnode); data0 = (1UL << SH_PTC_0_A_SHFT) |
@@ -194,7 +192,7 @@ void sn2_ptc_deadlock_recovery(unsigned mycnode =numa_node_id (); -for (cnode =0 ; cnode < numnodes; cnode++) { +for_each_online_node (cnode) {if (is_headless_node (cnode) || cnode == mycnode)continue ; nasid =cnodeid_to_nasid (cnode);
include/asm-ia64/mmzone.h +5 -6
@@ -11,7 +11,7 @@#ifndef _ASM_IA64_MMZONE_H#define _ASM_IA64_MMZONE_H -#include <linux/config.h> +#include <linux/numa.h> #include <asm/page.h> #include <asm/meminit.h>
@@ -19,15 +19,14 @@#ifdef CONFIG_IA64_DIG /* DIG systems are small */ # define MAX_PHYSNODE_ID 8 -# define NR_NODES 8 -# define NR_NODE_MEMBLKS (NR_NODES * 8) +# define NR_NODE_MEMBLKS (MAX_NUMNODES * 8)#else /* sn2 is the biggest case, so we use that if !DIG */ # define MAX_PHYSNODE_ID 2048 -# define NR_NODES 256 -# define NR_NODE_MEMBLKS (NR_NODES * 4) +# define NR_NODE_MEMBLKS (MAX_NUMNODES * 4)#endif #else /* CONFIG_DISCONTIGMEM */ -# define NR_NODE_MEMBLKS 4 +# define NR_NODE_MEMBLKS (MAX_NUMNODES * 4)#endif /* CONFIG_DISCONTIGMEM */ +#endif /* _ASM_IA64_MMZONE_H */
include/asm-ia64/nodedata.h +1 -1
@@ -27,7 +27,7 @@ struct pglist_data;struct ia64_node_data {short active_cpu_count;short node; -struct pglist_data *pg_data_ptrs[NR_NODES ]; +struct pglist_data *pg_data_ptrs[MAX_NUMNODES ]; };
include/asm-ia64/numa.h +1 -1
@@ -59,7 +59,7 @@ extern struct node_cpuid_s node_cpuid[NR*/ extern u8 numa_slit[MAX_NUMNODES *MAX_NUMNODES ]; -#define node_distance (from,to) (numa_slit[(from) * numnodes + (to)]) +#define node_distance (from,to) (numa_slit[(from) * num_online_nodes() + (to)])extern int paddr_to_nid (unsigned long paddr);
RFC PATCH 5/10 Replace 'numnodes' with 'node_online_map' - m32r
In reply to Matthew Dobson5/10 - Replace numnodes with node_online_map for m32r
[mcd@arrakis node_online_map]$ diffstat arch-m32r.patch
kernel/setup.c | 4 +++- mm/discontig.c | 6 +++--- mm/init.c | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-)
-Matt
arch/m32r/kernel/setup.c +3 -1
@@ -251,7 +251,9 @@ void __init setup_arch(char **cmdline_p)#endif #ifdef CONFIG_DISCONTIGMEM - numnodes =2 ; +nodes_clear (node_online_map); +node_set_online (0 ); +node_set_online (1 );#endif /* CONFIG_DISCONTIGMEM */ init_mm.start_code = (unsigned long ) _text;
arch/m32r/mm/discontig.c +3 -3
@@ -75,7 +75,7 @@ unsigned long __init setup_memory(void)mem_prof_init (); -for (nid =0 ; nid < numnodes ; nid++) { +for_each_online_node (nid) { mp = &mem_prof[nid];NODE_DATA (nid)=(pg_data_t *)&m32r_node_data[nid];NODE_DATA (nid)->bdata = &node_bdata[nid];
@@ -135,12 +135,12 @@ unsigned long __init zone_sizes_init(voimem_prof_t *mp; pgdat_list =NULL ; -for (nid = numnodes -1 ; nid >=0 ; nid--) { +for (nid =num_online_nodes () -1 ; nid >=0 ; nid--) {NODE_DATA (nid)->pgdat_next = pgdat_list; pgdat_list =NODE_DATA (nid); } -for (nid =0 ; nid < numnodes ; nid++) { +for_each_online_node (nid) { mp = &mem_prof[nid];for (i =0 ; i <MAX_NR_ZONES ; i++) { zones_size[i] =0 ;
arch/m32r/mm/init.c +3 -3
@@ -153,7 +153,7 @@ int __init reservedpages_count(void)int reservedpages, nid, i; reservedpages =0 ; -for (nid =0 ; nid < numnodes ; nid++) +for_each_online_node (nid)for (i =0 ; i <MAX_LOW_PFN (nid) -START_PFN (nid) ; i++)if (PageReserved (NODE_DATA (nid)->node_mem_map + i)) reservedpages++;
@@ -174,7 +174,7 @@ void __init mem_init(void)#endif num_physpages =0 ; -for (nid =0 ; nid < numnodes ; nid++) +for_each_online_node (nid) num_physpages +=MAX_LOW_PFN (nid) -START_PFN (nid) +1 ; num_physpages -= hole_pages;
@@ -193,7 +193,7 @@ void __init mem_init(void)memset (empty_zero_page,0 ,PAGE_SIZE );/* this will put all low memory onto the freelists */ -for (nid =0 ; nid < numnodes ; nid++) +for_each_online_node (nid) totalram_pages +=free_all_bootmem_node (NODE_DATA (nid)); reservedpages =reservedpages_count () - hole_pages;
RFC PATCH 6/10 Replace 'numnodes' with 'node_online_map' - mips
In reply to Matthew Dobson6/10 - Replace numnodes with node_online_map for mips
[mcd@arrakis node_online_map]$ diffstat arch-mips.patch
arch/mips/sgi-ip27/ip27-init.c | 1 - arch/mips/sgi-ip27/ip27-klnuma.c | 28 +++++++++++----------------- arch/mips/sgi-ip27/ip27-memory.c | 32 ++++++++++++++++---------------- arch/mips/sgi-ip27/ip27-nmi.c | 8 ++++---- arch/mips/sgi-ip27/ip27-reset.c | 4 ++-- arch/mips/sgi-ip27/ip27-smp.c | 14 +++++++++----- include/asm-mips/sn/sn_private.h | 4 ++-- 7 files changed, 44 insertions(+), 47 deletions(-)
-Matt
arch/mips/sgi-ip27/ip27-init.c +0 -1
@@ -10,7 +10,6 @@#include <linux/kernel.h> #include <linux/init.h> #include <linux/sched.h> -#include <linux/mmzone.h> /* for numnodes */ #include <linux/mm.h> #include <linux/module.h> #include <linux/cpumask.h>
arch/mips/sgi-ip27/ip27-klnuma.c +11 -17
@@ -27,33 +27,25 @@ static cpumask_t ktext_repmask;* kernel. For example, we should never put a copy on a headless node, * and we should respect the topology of the machine. */ -void __init setup_replication_mask (int maxnodes) +void __init setup_replication_mask () { -static int numa_kernel_replication_ratio;cnodeid_t cnode;/* Set only the master cnode's bit. The master cnode is always 0. */ cpus_clear (ktext_repmask);cpu_set (0 , ktext_repmask); - numa_kernel_replication_ratio =0 ;#ifdef CONFIG_REPLICATE_KTEXT #ifndef CONFIG_MAPPED_KERNEL #error Kernel replication works with mapped kernel support. No calias support.#endif - numa_kernel_replication_ratio =1 ; -#endif - -for (cnode =1 ; cnode < numnodes; cnode++) { -/* See if this node should get a copy of the kernel */ -if (numa_kernel_replication_ratio && - !(cnode % numa_kernel_replication_ratio)) { - -/* Advertise that we have a copy of the kernel */ -cpu_set (cnode, ktext_repmask); - } +for_each_online_node (cnode) { +if (cnode ==0 ) +continue ; +/* Advertise that we have a copy of the kernel */ +cpu_set (cnode, ktext_repmask); } - +#endif /* Set up a GDA pointer to the replication mask. */ GDA ->g_ktext_repmask = &ktext_repmask; }
@@ -92,7 +84,7 @@ static __init void copy_kernel(nasid_t dmemcpy ((void *)dest_kern_start, (void *)source_start, kern_size); } -void __init replicate_kernel_text (int maxnodes) +void __init replicate_kernel_text () {cnodeid_t cnode;nasid_t client_nasid;
@@ -103,7 +95,9 @@ void __init replicate_kernel_text(int ma/* Record where the master node should get its kernel text */ set_ktext_source (master_nasid, master_nasid); -for (cnode =1 ; cnode < maxnodes; cnode++) { +for_each_online_node (cnode) { +if (cnode ==0 ) +continue ; client_nasid =COMPACT_TO_NASID_NODEID (cnode);/* Check if this node should get a copy of the kernel */
arch/mips/sgi-ip27/ip27-memory.c +16 -16
@@ -59,12 +59,12 @@ static hubreg_t get_region(cnodeid_t cnostatic hubreg_t region_mask; -static void gen_region_mask (hubreg_t *region_mask,int maxnodes) +static void gen_region_mask (hubreg_t *region_mask) {cnodeid_t cnode; (*region_mask) =0 ; -for (cnode =0 ; cnode < maxnodes; cnode++) { +for_each_online_node (cnode) { (*region_mask) |=1ULL <<get_region (cnode); } }
@@ -120,7 +120,7 @@ static int __init compute_node_distance(int port;/* Figure out which routers nodes in question are connected to */ -for (cnode =0 ; cnode < numnodes; cnode++) { +for_each_online_node (cnode) { nasid =COMPACT_TO_NASID_NODEID (cnode);if (nasid ==-1 )continue ;
@@ -187,9 +187,9 @@ static void __init init_topology_matrix(for (col =0 ; col <MAX_COMPACT_NODES ; col++) __node_distances[row][col] =-1 ; -for (row =0 ; row < numnodes; row++) { +for_each_online_node (row) { nasid =COMPACT_TO_NASID_NODEID (row); -for (col =0 ; col < numnodes; col++) { +for_each_online_node (col) { nasid2 =COMPACT_TO_NASID_NODEID (col); __node_distances[row][col] =compute_node_distance (nasid, nasid2);
@@ -210,17 +210,17 @@ static void __init dump_topology(void)printk ("************** Topology ********************\n" );printk (" " ); -for (col =0 ; col < numnodes; col++) +for_each_online_node (col)printk ("%02d " , col);printk ("\n" ); -for (row =0 ; row < numnodes; row++) { +for_each_online_node (row) {printk ("%02d " , row); -for (col =0 ; col < numnodes; col++) +for_each_online_node (col)printk ("%2d " ,node_distance (row, col));printk ("\n" ); } -for (cnode =0 ; cnode < numnodes; cnode++) { +for_each_online_node (cnode) { nasid =COMPACT_TO_NASID_NODEID (cnode);if (nasid ==-1 )continue ;
@@ -363,14 +363,14 @@ static void __init mlreset(void)init_topology_matrix ();dump_topology (); -gen_region_mask (®ion_mask, numnodes); +gen_region_mask (®ion_mask); -setup_replication_mask (numnodes); +setup_replication_mask ();/* * Set all nodes' calias sizes to 8k */ -for (i =0 ; i < numnodes; i++) { +for_each_online_node (i) {nasid_t nasid; nasid =COMPACT_TO_NASID_NODEID (i);
@@ -407,7 +407,7 @@ static void __init szmem(void) num_physpages =0 ; -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) { ignore = nodebytes =0 ;for (slot =0 ; slot <MAX_MEM_SLOTS ; slot++) { slot_psize =slot_psize_compute (node, slot);
@@ -489,7 +489,7 @@ void __init prom_meminit(void)szmem ();for (node =0 ; node <MAX_COMPACT_NODES ; node++) { -if (node < numnodes) { +if (node_online (node)) {node_mem_init (node);continue ; }
@@ -513,7 +513,7 @@ void __init paging_init(void)pagetable_init (); -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) {pfn_t start_pfn =slot_getbasepfn (node,0 );pfn_t end_pfn =node_getmaxclick (node) +1 ;
@@ -533,7 +533,7 @@ void __init mem_init(void) high_memory = (void *)__va (num_physpages <<PAGE_SHIFT ); -for (node =0 ; node < numnodes; node++) { +for_each_online_node (node) {unsigned slot, numslots;struct page *end, *p;
arch/mips/sgi-ip27/ip27-nmi.c +4 -4
@@ -183,7 +183,7 @@ nmi_eframes_save(void) {cnodeid_t cnode; -for (cnode =0 ; cnode < numnodes; cnode++) +for_each_online_node (cnode)nmi_node_eframe_save (cnode); }
@@ -214,13 +214,13 @@ cont_nmi_dump(void)* send NMIs to all cpus on a 256p system. */ for (i=0 ; i <1500 ; i++) { -for (node=0 ; node < numnodes; node++) +for_each_online_node (node)if (NODEPDA (node)->dump_count ==0 )break ; -if (node == numnodes) +if (node ==MAX_NUMNODES )break ;if (i ==1000 ) { -for (node=0 ; node < numnodes; node++) +for_each_online_node (node)if (NODEPDA (node)->dump_count ==0 ) { cpu =node_to_first_cpu (node);for (n=0 ; n <CNODE_NUM_CPUS (node); cpu++, n++) {
arch/mips/sgi-ip27/ip27-reset.c +2 -2
@@ -43,7 +43,7 @@ static void ip27_machine_restart(char *csmp_send_stop ();#endif #if 0 -for (i =0 ; i < numnodes; i++) +for_each_online_node (i)REMOTE_HUB_S (COMPACT_TO_NASID_NODEID (i),PROMOP_REG ,PROMOP_REBOOT );#else
@@ -59,7 +59,7 @@ static void ip27_machine_halt(void)#ifdef CONFIG_SMP smp_send_stop ();#endif -for (i =0 ; i < numnodes; i++) +for_each_online_node (i)REMOTE_HUB_S (COMPACT_TO_NASID_NODEID (i),PROMOP_REG ,PROMOP_RESTART );LOCAL_HUB_S (NI_PORT_RESET ,NPR_PORTRESET |NPR_LOCALRESET );
arch/mips/sgi-ip27/ip27-smp.c +9 -5
@@ -108,18 +108,22 @@ void cpu_node_probe(void)for (i =0 ; i <MAXCPUS ; i++) cpuid_to_compact_node[i] =INVALID_CNODEID ; - numnodes =0 ; +/* +* MCD - this whole "compact node" stuff can probably be dropped, +* as we can handle sparse numbering now +*/ +nodes_clear (node_online_map);for (i =0 ; i <MAX_COMPACT_NODES ; i++) {nasid_t nasid = gdap->g_nasidtable[i];if (nasid ==INVALID_NASID )break ; compact_to_nasid_node[i] = nasid; nasid_to_compact_node[nasid] = i; - numnodes++; +node_set_online (num_online_nodes ()); highest =do_cpumask (i, nasid, highest); } -printk ("Discovered %d cpus on %d nodes\n" , highest +1 , numnodes); +printk ("Discovered %d cpus on %d nodes\n" , highest +1 ,num_online_nodes ()); } static void intr_clear_bits(nasid_t nasid, volatile hubreg_t *pend,
@@ -151,10 +155,10 @@ void __init prom_prepare_cpus(unsigned i {cnodeid_t cnode; -for (cnode =0 ; cnode < numnodes; cnode++) +for_each_online_node (cnode)intr_clear_all (COMPACT_TO_NASID_NODEID (cnode)); -replicate_kernel_text (numnodes); +replicate_kernel_text ();/* * Assumption to be fixed: we're always booted on logical / physical
include/asm-mips/sn/sn_private.h +2 -2
@@ -12,8 +12,8 @@ extern void cpu_time_init(void);extern void per_cpu_init (void );extern void install_cpu_nmi_handler (int slice);extern void install_ipi (void ); -extern void setup_replication_mask (int ); -extern void replicate_kernel_text (int ); +extern void setup_replication_mask (); +extern void replicate_kernel_text ();extern pfn_t node_getfirstfree (cnodeid_t );#endif /* __ASM_SN_SN_PRIVATE_H */
RFC PATCH 7/10 Replace 'numnodes' with 'node_online_map' - parisc
In reply to Matthew Dobson7/10 - Replace numnodes with node_online_map for parisc
[mcd@arrakis node_online_map]$ diffstat arch-parisc.patch
init.c | 2 -- 1 files changed, 2 deletions(-)
-Matt
arch/parisc/mm/init.c +0 -2
@@ -269,8 +269,6 @@ static void __init setup_bootmem(void) }memset (pfnnid_map,0xff ,sizeof (pfnnid_map)); - numnodes = npmem_ranges; -for (i =0 ; i < npmem_ranges; i++)node_set_online (i);#endif
RFC PATCH 8/10 Replace 'numnodes' with 'node_online_map' - ppc64
In reply to Matthew Dobson8/10 - Replace numnodes with node_online_map for ppc64
[mcd@arrakis node_online_map]$ diffstat arch-ppc64.patch
init.c | 2 +- numa.c | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-)
-Matt
arch/ppc64/mm/init.c +1 -1
@@ -703,7 +703,7 @@ void __init mem_init(void) high_memory = (void *)__va (max_low_pfn *PAGE_SIZE );#ifdef CONFIG_DISCONTIGMEM -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {if (NODE_DATA (nid)->node_spanned_pages !=0 ) {printk ("freeing bootmem node %x\n" , nid); totalram_pages +=
arch/ppc64/mm/numa.c +6 -8
@@ -216,7 +216,7 @@ static int numa_setup_cpu(unsigned long numa_domain =of_node_numa_domain (cpu); -if (numa_domain >= numnodes) { +if (numa_domain >=num_online_nodes ()) {/* * POWER4 LPAR uses 0xffff as invalid node, * dont warn in this case.
@@ -384,7 +384,8 @@ new_range: goto new_range; } - numnodes = max_domain +1 ; +for (i =0 ; i <= max_domain; i++) +node_set_online (i);return 0 ; }
@@ -430,12 +431,9 @@ static void __init dump_numa_topology(voif (min_common_depth ==-1 || !numa_enabled)return ; -for (node =0 ; node <MAX_NUMNODES ; node++) { +for_each_online_node (node) {unsigned long i; -if (!node_online (node)) -continue ; -printk (KERN_INFO "Node %d Memory:" , node); count =0 ;
@@ -519,7 +517,7 @@ void __init do_init_bootmem(void)register_cpu_notifier (&ppc64_numa_nb); -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {unsigned long start_paddr, end_paddr;int i;unsigned long bootmem_paddr;
@@ -619,7 +617,7 @@ void __init paging_init(void)memset (zones_size,0 ,sizeof (zones_size));memset (zholes_size,0 ,sizeof (zholes_size)); -for (nid =0 ; nid < numnodes; nid++) { +for_each_online_node (nid) {unsigned long start_pfn;unsigned long end_pfn;
RFC PATCH 9/10 Replace 'numnodes' with 'node_online_map' - x86_64
In reply to Matthew Dobson9/10 - Replace numnodes with node_online_map for x86_64
[mcd@arrakis node_online_map]$ diffstat arch-x86_64.patch
arch/x86_64/kernel/setup64.c | 3 ++- arch/x86_64/mm/k8topology.c | 9 +++++---- arch/x86_64/mm/numa.c | 15 +++++++-------- arch/x86_64/mm/srat.c | 13 +++++-------- include/asm-x86_64/numa.h | 3 --- 5 files changed, 19 insertions(+), 24 deletions(-)
-Matt
arch/x86_64/kernel/setup64.c +2 -1
@@ -82,7 +82,8 @@ void __init setup_per_cpu_areas(void)unsigned char *ptr;if (!NODE_DATA (cpu_to_node (i))) { -printk ("cpu with no node %d, numnodes %d\n" , i, numnodes); +printk ("cpu with no node %d, num_online_nodes %d\n" , + i,num_online_nodes ()); ptr =alloc_bootmem (size); }else { ptr =alloc_bootmem_node (NODE_DATA (cpu_to_node (i)), size);
arch/x86_64/mm/k8topology.c +5 -4
@@ -55,9 +55,10 @@ int __init k8_scan_nodes(unsigned long sprintk (KERN_INFO "Scanning NUMA topology in Northbridge %d\n" , nb); reg =read_pci_config (0 , nb,0 ,0x60 ); - numnodes = ((reg >>4 ) &7 ) +1 ; +for (i =0 ; i <= ((reg >>4 ) &7 ); i++) +node_set_online (i); -printk (KERN_INFO "Number of nodes %d (%x)\n" , numnodes, reg); +printk (KERN_INFO "Number of nodes %d (%x)\n" ,num_online_nodes (), reg);memset (&nodes,0 ,sizeof (nodes)); prevbase =0 ;
@@ -69,11 +70,11 @@ int __init k8_scan_nodes(unsigned long s nodeid = limit &7 ;if ((base &3 ) ==0 ) { -if (i < numnodes) +if (i <num_online_nodes ())printk ("Skipping disabled node %d\n" , i);continue ; } -if (nodeid >= numnodes) { +if (nodeid >=num_online_nodes ()) {printk ("Ignoring excess node %d (%lx:%lx)\n" , nodeid, base, limit);continue ;
arch/x86_64/mm/numa.c +7 -8
@@ -45,7 +45,7 @@ int __init compute_hash_shift(struct nod/* When in doubt use brute force. */ while (shift <48 ) {memset (memnodemap,0xff ,sizeof (*memnodemap) *NODEMAPSIZE ); -for (i =0 ; i < numnodes; i++) { +for_each_online_node (i) {if (nodes[i].start == nodes[i].end)continue ; for (addr = nodes[i].start;
@@ -111,8 +111,6 @@ void __init setup_node_bootmem(int nodeireserve_bootmem_node (NODE_DATA (nodeid), nodedata_phys, pgdat_size);reserve_bootmem_node (NODE_DATA (nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT ); -if (nodeid +1 > numnodes) - numnodes = nodeid +1 ;node_set_online (nodeid); }
@@ -197,15 +195,15 @@ static int numa_emulation(unsigned long i, nodes[i].start, nodes[i].end, (nodes[i].end - nodes[i].start) >> 20); +node_set_online (i); } - numnodes = numa_fake; memnode_shift =compute_hash_shift (nodes);if (memnode_shift <0 ) { memnode_shift =0 ;printk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" );return -1 ; } -for (i =0 ; i < numa_fake; i++) +for_each_online_node (i)setup_node_bootmem (i, nodes[i].start, nodes[i].end);numa_init_array ();return 0 ;
@@ -240,7 +238,8 @@ void __init numa_initmem_init(unsigned l/* setup dummy node covering all memory */ memnode_shift =63 ; memnodemap[0 ] =0 ; - numnodes =1 ; +nodes_clear (node_online_map); +node_set_online (0 );for (i =0 ; i <NR_CPUS ; i++) cpu_to_node[i] =0 ; node_to_cpumask[0 ] =cpumask_of_cpu (0 );
@@ -258,7 +257,7 @@ unsigned long __init numa_free_all_bootm {int i;unsigned long pages =0 ; -for_all_nodes (i) { +for_each_online_node (i) { pages +=free_all_bootmem_node (NODE_DATA (i)); }return pages;
@@ -267,7 +266,7 @@ unsigned long __init numa_free_all_bootmvoid __init paging_init (void ) {int i; -for_all_nodes (i) { +for_each_online_node (i) {setup_node_zones (i); } }
arch/x86_64/mm/srat.c +5 -8
@@ -27,10 +27,10 @@ static __u8 pxm2node[256] __initdata =static __init int setup_node (int pxm) {if (pxm2node[pxm] ==0xff ) { -if (numnodes >MAX_NUMNODES ) +if (num_online_nodes () >=MAX_NUMNODES )return -1 ; - pxm2node[pxm] = numnodes -1 ; - numnodes++; + pxm2node[pxm] =num_online_nodes (); +node_set_online (num_online_nodes ()); }return pxm2node[pxm]; }
@@ -38,7 +38,7 @@ static __init int setup_node(int pxm)static __init int conflicting_nodes (unsigned long start,unsigned long end) {int i; -for (i =0 ; i < numnodes; i++) { +for_each_online_node (i) {struct node *nd = &nodes[i];if (nd->start == nd->end)continue ;
@@ -155,10 +155,7 @@ acpi_numa_memory_affinity_init(struct ac nd->start, nd->end); } -void __init acpi_numa_arch_fixup (void ) -{ - numnodes--; -} +void __init acpi_numa_arch_fixup (void ) {}/* Use the information discovered above to actually set up the nodes. */ int __init acpi_scan_nodes (unsigned long start,unsigned long end)
include/asm-x86_64/numa.h +0 -3
@@ -8,9 +8,6 @@ struct node {u64 start,end; }; -#define for_all_nodes (x) for ((x) = 0; (x) < numnodes; (x)++) \ - if (node_online(x)) -extern int compute_hash_shift (struct node *nodes);#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
RFC PATCH 10/10 Replace 'numnodes' with 'node_online_map' - arch-independent
In reply to Matthew Dobson10/10 - Replace numnodes with node_online_map for arch-independent code
[mcd@arrakis node_online_map]$ diffstat arch-generic.patch
Documentation/vm/numa | 2 +- drivers/base/node.c | 2 +- include/linux/mmzone.h | 1 - include/linux/topology.h | 13 +++---------- mm/hugetlb.c | 4 ++-- mm/mempolicy.c | 2 +- mm/page_alloc.c | 46 ++++++++++++++++++++++++++-------------------- 7 files changed, 34 insertions(+), 36 deletions(-)
-Matt
Documentation/vm/numa +1 -1
@@ -29,7 +29,7 @@ Each node's page allocation data structu into a pg_data_t. The bootmem_data_t is just one part of this. To make the code look uniform between NUMA and regular UMA platforms, UMA platforms have a statically allocated pg_data_t too (contig_page_data). -For the sake of uniformity, the variable "numnodes" is also defined +For the sake of uniformity, the function num_online_nodes() is also defined for all platforms. As we run benchmarks, we might decide to NUMAize more variables like low_on_memory, nr_free_pages etc into the pg_data_t.
drivers/base/node.c +1 -1
@@ -120,7 +120,7 @@ static ssize_t node_read_distance(struct/* buf currently PAGE_SIZE, need ~4 chars per node */ BUILD_BUG_ON (MAX_NUMNODES *4 >PAGE_SIZE /2 ); -for (i =0 ; i < numnodes; i++) +for_each_online_node (i) len +=sprintf (buf + len,"%s%d" , i ?" " :"" ,node_distance (nid, i)); len +=sprintf (buf + len,"\n" );
include/linux/mmzone.h +0 -1
@@ -271,7 +271,6 @@ typedef struct pglist_data {#define node_present_pages (nid) (NODE_DATA(nid)->node_present_pages)#define node_spanned_pages (nid) (NODE_DATA(nid)->node_spanned_pages) -extern int numnodes;extern struct pglist_data *pgdat_list; void __get_zone_counts(unsigned long *active, unsigned long *inactive,
include/linux/topology.h +3 -10
@@ -43,16 +43,9 @@ })#endif -static inline int __next_node_with_cpus (int node) -{ -do - ++node; -while (node < numnodes && !nr_cpus_node (node)); -return node; -} - -#define for_each_node_with_cpus (node) \ - for (node = 0; node < numnodes; node = __next_node_with_cpus(node)) +#define for_each_node_with_cpus (node) \ + for_each_online_node(node) \ + if (nr_cpus_node(node))#ifndef node_distance/* Conform to ACPI 2.0 SLIT distance definitions */
mm/hugetlb.c +2 -2
@@ -54,10 +54,10 @@ static struct page *alloc_fresh_huge_pagstruct page *page; page =alloc_pages_node (nid,GFP_HIGHUSER |__GFP_COMP|__GFP_NOWARN,HUGETLB_PAGE_ORDER ); - nid = (nid +1 ) % numnodes; + nid = (nid +1 ) %num_online_nodes ();if (page) { nr_huge_pages++; - nr_huge_pages_node[page_zone (page)->zone_pgdat->node_id]++; + nr_huge_pages_node[page_to_nid (page)]++; }return page; }
mm/mempolicy.c +1 -1
@@ -714,7 +714,7 @@ asmlinkage long sys_get_mempolicy(int __if (flags & ~(unsigned long )(MPOL_F_NODE |MPOL_F_ADDR ))return -EINVAL ; -if (nmask !=NULL && maxnode < numnodes) +if (nmask !=NULL && maxnode <MAX_NUMNODES )return -EINVAL ;if (flags &MPOL_F_ADDR ) {down_read (&mm->mmap_sem);
mm/page_alloc.c +26 -20
119 lines not on this page · raw message