Commit 5b73f882 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] free_area_init cleanup

From Christoph Hellwig.

If we always pass &contig_page_data into free_area_init_node for the
non-distcontig case we can merge both versions of that function into
one.  Move that one to page_alloc.c and thus kill numa.c which was
totally misnamed, btw.
parent e175e9b2
...@@ -345,7 +345,7 @@ paging_init(void) ...@@ -345,7 +345,7 @@ paging_init(void)
* mem_map page array. * mem_map page array.
*/ */
free_area_init_node(0, 0, 0, zones_size, PAGE_OFFSET >> PAGE_SHIFT, 0); free_area_init_node(0, &contig_page_data, 0, zones_size, PAGE_OFFSET >> PAGE_SHIFT, 0);
} }
......
...@@ -1340,7 +1340,7 @@ void __init srmmu_paging_init(void) ...@@ -1340,7 +1340,7 @@ void __init srmmu_paging_init(void)
zones_size[ZONE_HIGHMEM] = npages; zones_size[ZONE_HIGHMEM] = npages;
zholes_size[ZONE_HIGHMEM] = npages - calc_highpages(); zholes_size[ZONE_HIGHMEM] = npages - calc_highpages();
free_area_init_node(0, NULL, NULL, zones_size, free_area_init_node(0, &contig_page_data, NULL, zones_size,
phys_base >> PAGE_SHIFT, zholes_size); phys_base >> PAGE_SHIFT, zholes_size);
} }
......
...@@ -2066,7 +2066,7 @@ void __init sun4c_paging_init(void) ...@@ -2066,7 +2066,7 @@ void __init sun4c_paging_init(void)
zones_size[ZONE_HIGHMEM] = npages; zones_size[ZONE_HIGHMEM] = npages;
zholes_size[ZONE_HIGHMEM] = npages - calc_highpages(); zholes_size[ZONE_HIGHMEM] = npages - calc_highpages();
free_area_init_node(0, NULL, NULL, zones_size, free_area_init_node(0, &contig_page_data, NULL, zones_size,
phys_base >> PAGE_SHIFT, zholes_size); phys_base >> PAGE_SHIFT, zholes_size);
} }
......
...@@ -1552,7 +1552,7 @@ void __init paging_init(void) ...@@ -1552,7 +1552,7 @@ void __init paging_init(void)
zones_size[ZONE_DMA] = npages; zones_size[ZONE_DMA] = npages;
zholes_size[ZONE_DMA] = npages - pages_avail; zholes_size[ZONE_DMA] = npages - pages_avail;
free_area_init_node(0, NULL, NULL, zones_size, free_area_init_node(0, &contig_page_data, NULL, zones_size,
phys_base >> PAGE_SHIFT, zholes_size); phys_base >> PAGE_SHIFT, zholes_size);
} }
......
...@@ -172,7 +172,7 @@ typedef struct pglist_data { ...@@ -172,7 +172,7 @@ typedef struct pglist_data {
} pg_data_t; } pg_data_t;
extern int numnodes; extern int numnodes;
extern pg_data_t *pgdat_list; extern struct pglist_data *pgdat_list;
static inline int static inline int
memclass(struct zone *pgzone, struct zone *classzone) memclass(struct zone *pgzone, struct zone *classzone)
...@@ -184,19 +184,8 @@ memclass(struct zone *pgzone, struct zone *classzone) ...@@ -184,19 +184,8 @@ memclass(struct zone *pgzone, struct zone *classzone)
return 1; return 1;
} }
/*
* The following two are not meant for general usage. They are here as
* prototypes for the discontig memory code.
*/
struct page;
extern void calculate_totalpages (pg_data_t *pgdat, unsigned long *zones_size,
unsigned long *zholes_size);
extern void free_area_init_core(pg_data_t *pgdat, unsigned long *zones_size,
unsigned long *zholes_size);
void get_zone_counts(unsigned long *active, unsigned long *inactive); void get_zone_counts(unsigned long *active, unsigned long *inactive);
extern void build_all_zonelists(void); void build_all_zonelists(void);
extern pg_data_t contig_page_data;
/** /**
* for_each_pgdat - helper macro to iterate over all nodes * for_each_pgdat - helper macro to iterate over all nodes
...@@ -260,11 +249,10 @@ static inline struct zone *next_zone(struct zone *zone) ...@@ -260,11 +249,10 @@ static inline struct zone *next_zone(struct zone *zone)
#define numa_node_id() (__cpu_to_node(smp_processor_id())) #define numa_node_id() (__cpu_to_node(smp_processor_id()))
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
extern struct pglist_data contig_page_data;
#define NODE_DATA(nid) (&contig_page_data) #define NODE_DATA(nid) (&contig_page_data)
#define NODE_MEM_MAP(nid) mem_map #define NODE_MEM_MAP(nid) mem_map
#define MAX_NR_NODES 1 #define MAX_NR_NODES 1
#else /* CONFIG_DISCONTIGMEM */ #else /* CONFIG_DISCONTIGMEM */
#include <asm/mmzone.h> #include <asm/mmzone.h>
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
# Makefile for the linux memory manager. # Makefile for the linux memory manager.
# #
export-objs := shmem.o filemap.o mempool.o page_alloc.o \ export-objs := shmem.o filemap.o mempool.o page_alloc.o page-writeback.o
page-writeback.o
obj-y := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \ obj-y := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \
vmalloc.o slab.o bootmem.o swap.o vmscan.o page_io.o \ vmalloc.o slab.o bootmem.o swap.o vmscan.o page_io.o \
page_alloc.o swap_state.o swapfile.o numa.o oom_kill.o \ page_alloc.o swap_state.o swapfile.o oom_kill.o \
shmem.o highmem.o mempool.o msync.o mincore.o readahead.o \ shmem.o highmem.o mempool.o msync.o mincore.o readahead.o \
pdflush.o page-writeback.o rmap.o madvise.o vcache.o \ pdflush.o page-writeback.o rmap.o madvise.o vcache.o \
truncate.o truncate.o
......
/*
* Written by Kanoj Sarcar, SGI, Aug 1999
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/mmzone.h>
#include <linux/spinlock.h>
int numnodes = 1; /* Initialized for UMA platforms */
#ifndef CONFIG_DISCONTIGMEM
static bootmem_data_t contig_bootmem_data;
pg_data_t contig_page_data = { .bdata = &contig_bootmem_data };
/*
* This is meant to be invoked by platforms whose physical memory starts
* at a considerably higher value than 0. Examples are Super-H, ARM, m68k.
* Should be invoked with paramters (0, 0, unsigned long *[], start_paddr).
*/
void __init free_area_init_node(int nid, pg_data_t *pgdat, struct page *pmap,
unsigned long *zones_size, unsigned long node_start_pfn,
unsigned long *zholes_size)
{
unsigned long size;
pgdat = &contig_page_data;
contig_page_data.node_id = 0;
contig_page_data.node_start_pfn = node_start_pfn;
calculate_totalpages (&contig_page_data, zones_size, zholes_size);
if (pmap == (struct page *)0) {
size = (pgdat->node_size + 1) * sizeof(struct page);
pmap = (struct page *) alloc_bootmem_node(pgdat, size);
}
contig_page_data.node_mem_map = pmap;
free_area_init_core(&contig_page_data, zones_size, zholes_size);
mem_map = contig_page_data.node_mem_map;
}
#else /* CONFIG_DISCONTIGMEM */
#define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1))
/*
* Nodes can be initialized parallely, in no particular order.
*/
void __init free_area_init_node(int nid, pg_data_t *pgdat, struct page *pmap,
unsigned long *zones_size, unsigned long node_start_pfn,
unsigned long *zholes_size)
{
int i;
unsigned long size;
pgdat->node_id = nid;
pgdat->node_start_pfn = node_start_pfn;
calculate_totalpages (pgdat, zones_size, zholes_size);
if (pmap == (struct page *)0) {
size = (pgdat->node_size + 1) * sizeof(struct page);
pmap = (struct page *) alloc_bootmem_node(pgdat, size);
}
pgdat->node_mem_map = pmap;
free_area_init_core(pgdat, zones_size, zholes_size);
/*
* Get space for the valid bitmap.
*/
size = 0;
for (i = 0; i < MAX_NR_ZONES; i++)
size += zones_size[i];
size = LONG_ALIGN((size + 7) >> 3);
pgdat->valid_addr_bitmap = (unsigned long *)alloc_bootmem_node(pgdat, size);
memset(pgdat->valid_addr_bitmap, 0, size);
}
#endif /* CONFIG_DISCONTIGMEM */
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/slab.h> #include <linux/slab.h>
struct pglist_data *pgdat_list;
unsigned long totalram_pages; unsigned long totalram_pages;
unsigned long totalhigh_pages; unsigned long totalhigh_pages;
int nr_swap_pages; int nr_swap_pages;
pg_data_t *pgdat_list; int numnodes = 1;
/* /*
* Used by page_zone() to look up the address of the struct zone whose * Used by page_zone() to look up the address of the struct zone whose
...@@ -778,23 +780,6 @@ void __init build_all_zonelists(void) ...@@ -778,23 +780,6 @@ void __init build_all_zonelists(void)
build_zonelists(NODE_DATA(i)); build_zonelists(NODE_DATA(i));
} }
void __init calculate_totalpages (pg_data_t *pgdat, unsigned long *zones_size,
unsigned long *zholes_size)
{
unsigned long realtotalpages, totalpages = 0;
int i;
for (i = 0; i < MAX_NR_ZONES; i++)
totalpages += zones_size[i];
pgdat->node_size = totalpages;
realtotalpages = totalpages;
if (zholes_size)
for (i = 0; i < MAX_NR_ZONES; i++)
realtotalpages -= zholes_size[i];
printk("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
}
/* /*
* Helper functions to size the waitqueue hash table. * Helper functions to size the waitqueue hash table.
* Essentially these want to choose hash table sizes sufficiently * Essentially these want to choose hash table sizes sufficiently
...@@ -839,13 +824,46 @@ static inline unsigned long wait_table_bits(unsigned long size) ...@@ -839,13 +824,46 @@ static inline unsigned long wait_table_bits(unsigned long size)
#define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1))
static void __init calculate_zone_totalpages(struct pglist_data *pgdat,
unsigned long *zones_size, unsigned long *zholes_size)
{
unsigned long realtotalpages, totalpages = 0;
int i;
for (i = 0; i < MAX_NR_ZONES; i++)
totalpages += zones_size[i];
pgdat->node_size = totalpages;
realtotalpages = totalpages;
if (zholes_size)
for (i = 0; i < MAX_NR_ZONES; i++)
realtotalpages -= zholes_size[i];
printk("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
}
/*
* Get space for the valid bitmap.
*/
static void __init calculate_zone_bitmap(struct pglist_data *pgdat,
unsigned long *zones_size)
{
unsigned long size = 0;
int i;
for (i = 0; i < MAX_NR_ZONES; i++)
size += zones_size[i];
size = LONG_ALIGN((size + 7) >> 3);
pgdat->valid_addr_bitmap = (unsigned long *)alloc_bootmem_node(pgdat, size);
memset(pgdat->valid_addr_bitmap, 0, size);
}
/* /*
* Set up the zone data structures: * Set up the zone data structures:
* - mark all pages reserved * - mark all pages reserved
* - mark all memory queues empty * - mark all memory queues empty
* - clear the memory bitmaps * - clear the memory bitmaps
*/ */
void __init free_area_init_core(pg_data_t *pgdat, static void __init free_area_init_core(struct pglist_data *pgdat,
unsigned long *zones_size, unsigned long *zholes_size) unsigned long *zones_size, unsigned long *zholes_size)
{ {
unsigned long i, j; unsigned long i, j;
...@@ -980,7 +998,30 @@ void __init free_area_init_core(pg_data_t *pgdat, ...@@ -980,7 +998,30 @@ void __init free_area_init_core(pg_data_t *pgdat,
} }
} }
void __init free_area_init_node(int nid, struct pglist_data *pgdat,
struct page *node_mem_map, unsigned long *zones_size,
unsigned long node_start_pfn, unsigned long *zholes_size)
{
unsigned long size;
pgdat->node_id = nid;
pgdat->node_start_pfn = node_start_pfn;
calculate_zone_totalpages(pgdat, zones_size, zholes_size);
if (!node_mem_map) {
size = (pgdat->node_size + 1) * sizeof(struct page);
node_mem_map = alloc_bootmem_node(pgdat, size);
}
pgdat->node_mem_map = node_mem_map;
free_area_init_core(pgdat, zones_size, zholes_size);
calculate_zone_bitmap(pgdat, zones_size);
}
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
static bootmem_data_t contig_bootmem_data;
struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data };
void __init free_area_init(unsigned long *zones_size) void __init free_area_init(unsigned long *zones_size)
{ {
free_area_init_node(0, &contig_page_data, NULL, zones_size, 0, NULL); free_area_init_node(0, &contig_page_data, NULL, zones_size, 0, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment