]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Replace 'numnodes' with 'node_online_map' - i386
authorMatthew Dobson <colpatch@us.ibm.com>
Sat, 8 Jan 2005 05:55:22 +0000 (21:55 -0800)
committerLinus Torvalds <torvalds@evo.osdl.org>
Sat, 8 Jan 2005 05:55:22 +0000 (21:55 -0800)
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/mpparse.c
arch/i386/kernel/numaq.c
arch/i386/kernel/srat.c
arch/i386/mm/discontig.c
arch/i386/pci/numa.c
include/asm-i386/mach-numaq/mach_apic.h

index 0c8026c2c600dd4ac8be39040b5d6be5682c166f..e5ad7e03fc7fed6b476cc2ed1ff8cd2c1ee19654 100644 (file)
@@ -309,8 +309,8 @@ static void __init MP_translation_info (struct mpc_config_translation *m)
                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);
 }
 
 /*
index 38c762daba5a5a8a2c2c1e062193d5ca974c6188..0ee22fcb12d152f80f922580c4ea85d6db576e93 100644 (file)
@@ -40,8 +40,7 @@ extern long node_start_pfn[], node_end_pfn[];
  * 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(
index bb55e0d5187ea3da646ea4bfa421b6d39ff35426..74b0c8e03fb8078e0513aa148d5d023ceb32ac00 100644 (file)
@@ -232,18 +232,22 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp)
         * 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(struct acpi_table_srat *sratp)
                printk("%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(struct acpi_table_srat *sratp)
        }
  
        /*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(int nid)
                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];
 }
index 3906c48d6e2f48b28bed03045ada45e12ae45a88..2b535d2c97daccdefc7d0761630f06de94e22458 100644 (file)
@@ -41,7 +41,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
@@ -93,12 +93,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;
 }
 
@@ -183,7 +183,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, 
@@ -198,7 +200,9 @@ static unsigned long calculate_numa_remap_pages(void)
        int 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);
@@ -248,7 +252,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  ",
@@ -285,7 +289,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);
@@ -297,7 +301,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;
@@ -375,14 +379,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;
index c8046737bd16103745957319079c7ebe92852842..070661abda067f7c7eb0c2af6766c1cd492fd7e5 100644 (file)
@@ -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;
 }
 
index b852593a1c7ba19975fb8144378c31ff5b405c2b..7bf453bd3305ecf36731f23c2261d1b918343c53 100644 (file)
@@ -112,13 +112,15 @@ static inline int mpc_apic_id(struct mpc_config_processor *m,
 
 static 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)