mm: move bootmem descriptors definition to a single place
[linux-2.6.git] / arch / alpha / mm / numa.c
index ba81c44..a53fda0 100644 (file)
@@ -6,19 +6,20 @@
  *  Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/swap.h>
 #include <linux/initrd.h>
+#include <linux/pfn.h>
+#include <linux/module.h>
 
 #include <asm/hwrpb.h>
 #include <asm/pgalloc.h>
 
 pg_data_t node_data[MAX_NUMNODES];
-bootmem_data_t node_bdata[MAX_NUMNODES];
+EXPORT_SYMBOL(node_data);
 
 #undef DEBUG_DISCONTIG
 #ifdef DEBUG_DISCONTIG
@@ -27,9 +28,6 @@ bootmem_data_t node_bdata[MAX_NUMNODES];
 #define DBGDCONT(args...)
 #endif
 
-#define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-#define PFN_DOWN(x)     ((x) >> PAGE_SHIFT)
-#define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
 #define for_each_mem_cluster(memdesc, cluster, i)              \
        for ((cluster) = (memdesc)->cluster, (i) = 0;           \
             (i) < (memdesc)->numclusters; (i)++, (cluster)++)
@@ -142,7 +140,7 @@ setup_memory_node(int nid, void *kernel_end)
                printk(" not enough mem to reserve NODE_DATA");
                return;
        }
-       NODE_DATA(nid)->bdata = &node_bdata[nid];
+       NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
 
        printk(" Detected node memory:   start %8lu, end %8lu\n",
               node_min_pfn, node_max_pfn);
@@ -243,7 +241,8 @@ setup_memory_node(int nid, void *kernel_end)
        }
 
        /* Reserve the bootmap memory.  */
-       reserve_bootmem_node(NODE_DATA(nid), PFN_PHYS(bootmap_start), bootmap_size);
+       reserve_bootmem_node(NODE_DATA(nid), PFN_PHYS(bootmap_start),
+                       bootmap_size, BOOTMEM_DEFAULT);
        printk(" reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
 
        node_set_online(nid);
@@ -282,7 +281,7 @@ setup_memory(void *kernel_end)
                        nid = kvaddr_to_nid(initrd_start);
                        reserve_bootmem_node(NODE_DATA(nid),
                                             virt_to_phys((void *)initrd_start),
-                                            INITRD_SIZE);
+                                            INITRD_SIZE, BOOTMEM_DEFAULT);
                }
        }
 #endif /* CONFIG_BLK_DEV_INITRD */
@@ -304,8 +303,9 @@ void __init paging_init(void)
        dma_local_pfn = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
 
        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;
+               bootmem_data_t *bdata = &bootmem_node_data[nid];
+               unsigned long start_pfn = bdata->node_boot_start >> PAGE_SHIFT;
+               unsigned long end_pfn = bdata->node_low_pfn;
 
                if (dma_local_pfn >= end_pfn - start_pfn)
                        zones_size[ZONE_DMA] = end_pfn - start_pfn;
@@ -327,8 +327,6 @@ void __init mem_init(void)
        extern char _text, _etext, _data, _edata;
        extern char __init_begin, __init_end;
        unsigned long nid, i;
-       struct page * lmem_map;
-
        high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
        reservedpages = 0;
@@ -338,10 +336,10 @@ void __init mem_init(void)
                 */
                totalram_pages += free_all_bootmem_node(NODE_DATA(nid));
 
-               lmem_map = node_mem_map(nid);
                pfn = NODE_DATA(nid)->node_start_pfn;
                for (i = 0; i < node_spanned_pages(nid); i++, pfn++)
-                       if (page_is_ram(pfn) && PageReserved(lmem_map+i))
+                       if (page_is_ram(pfn) &&
+                           PageReserved(nid_page_nr(nid, i)))
                                reservedpages++;
        }
 
@@ -373,19 +371,22 @@ show_mem(void)
        show_free_areas();
        printk("Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
        for_each_online_node(nid) {
-               struct page * lmem_map = node_mem_map(nid);
+               unsigned long flags;
+               pgdat_resize_lock(NODE_DATA(nid), &flags);
                i = node_spanned_pages(nid);
                while (i-- > 0) {
+                       struct page *page = nid_page_nr(nid, i);
                        total++;
-                       if (PageReserved(lmem_map+i))
+                       if (PageReserved(page))
                                reserved++;
-                       else if (PageSwapCache(lmem_map+i))
+                       else if (PageSwapCache(page))
                                cached++;
-                       else if (!page_count(lmem_map+i))
+                       else if (!page_count(page))
                                free++;
                        else
-                               shared += page_count(lmem_map + i) - 1;
+                               shared += page_count(page) - 1;
                }
+               pgdat_resize_unlock(NODE_DATA(nid), &flags);
        }
        printk("%ld pages of RAM\n",total);
        printk("%ld free pages\n",free);