Commit e2f5e334 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] discontigmem code cleanup #2

Patch from Martin Bligh

"This mainly just rips out some magic extra structures in the boot time
 code to determine node sizes, and counts in pages instead of bytes.
 Oh, and I put the code that allocates pgdat into allocage_pgdat,
 instead of find_max_pfn_node, which seems like an incongruous home for
 it.

 No functionality changes, nothing touched outside i386 discontigmem ...
 just makes code cleaner and more readable.  Tested on 16-way NUMA-Q."
parent 79a96230
......@@ -29,8 +29,11 @@
#include <linux/mmzone.h>
#include <asm/numaq.h>
u64 nodes_mem_start[MAX_NUMNODES];
u64 nodes_mem_size[MAX_NUMNODES];
/* These are needed before the pgdat's are created */
unsigned long node_start_pfn[MAX_NUMNODES];
unsigned long node_end_pfn[MAX_NUMNODES];
#define MB_TO_PAGES(addr) ((addr) << (20 - PAGE_SHIFT))
/*
* Function: smp_dump_qct()
......@@ -46,17 +49,16 @@ static void __init smp_dump_qct(void)
struct sys_cfg_data *scd =
(struct sys_cfg_data *)__va(SYS_CFG_DATA_PRIV_ADDR);
#define MB_TO_B(addr) ((addr) << 20)
numnodes = 0;
for(node = 0; node < MAX_NUMNODES; node++) {
if(scd->quads_present31_0 & (1 << node)) {
numnodes++;
eq = &scd->eq[node];
/* Convert to bytes */
nodes_mem_start[node] = MB_TO_B((u64)eq->hi_shrd_mem_start -
(u64)eq->priv_mem_size);
nodes_mem_size[node] = MB_TO_B((u64)eq->hi_shrd_mem_size +
(u64)eq->priv_mem_size);
/* Convert to pages */
node_start_pfn[node] = MB_TO_PAGES(
eq->hi_shrd_mem_start - eq->priv_mem_size);
node_end_pfn[node] = MB_TO_PAGES(
eq->hi_shrd_mem_start + eq->hi_shrd_mem_size);
}
}
}
......
......@@ -34,20 +34,14 @@
#include <asm/e820.h>
#include <asm/setup.h>
struct pfns {
unsigned long start_pfn;
unsigned long max_pfn;
};
struct pglist_data *node_data[MAX_NUMNODES];
bootmem_data_t plat_node_bdata;
struct pfns plat_node_bootpfns[MAX_NUMNODES];
bootmem_data_t node0_bdata;
extern unsigned long find_max_low_pfn(void);
extern void find_max_pfn(void);
extern void one_highpage_init(struct page *, int, int);
extern u64 nodes_mem_start[], nodes_mem_size[];
extern unsigned long node_start_pfn[], node_end_pfn[];
extern struct e820map e820;
extern char _end;
extern unsigned long highend_pfn, highstart_pfn;
......@@ -60,22 +54,22 @@ extern unsigned long totalhigh_pages;
*/
static void __init find_max_pfn_node(int nid)
{
unsigned long node_datasz;
unsigned long start, end;
start = plat_node_bootpfns[nid].start_pfn = PFN_UP(nodes_mem_start[nid]);
end = PFN_DOWN(nodes_mem_start[nid]) + PFN_DOWN(nodes_mem_size[nid]);
if (start >= end) {
if (node_start_pfn[nid] >= node_end_pfn[nid])
BUG();
}
if (end > max_pfn) {
end = max_pfn;
}
plat_node_bootpfns[nid].max_pfn = end;
if (node_end_pfn[nid] > max_pfn)
node_end_pfn[nid] = max_pfn;
}
/*
* Allocate memory for the pg_data_t via a crude pre-bootmem method
* We ought to relocate these onto their own node later on during boot.
*/
static void __init allocate_pgdat(int nid)
{
unsigned long node_datasz;
node_datasz = PFN_UP(sizeof(struct pglist_data));
NODE_DATA(nid) = (struct pglist_data *)(__va(min_low_pfn << PAGE_SHIFT));
NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT));
min_low_pfn += node_datasz;
}
......@@ -147,12 +141,11 @@ unsigned long __init setup_memory(void)
pages_to_mb(system_max_low_pfn));
for (nid = 0; nid < numnodes; nid++)
{
allocate_pgdat(nid);
for (nid = 0; nid < numnodes; nid++)
find_max_pfn_node(nid);
}
NODE_DATA(0)->bdata = &plat_node_bdata;
NODE_DATA(0)->bdata = &node0_bdata;
/*
* Initialize the boot-time allocator (with low memory only):
......@@ -231,8 +224,8 @@ void __init zone_sizes_init(void)
unsigned int max_dma;
unsigned long low = max_low_pfn;
unsigned long high = plat_node_bootpfns[nid].max_pfn;
unsigned long start = plat_node_bootpfns[nid].start_pfn;
unsigned long start = node_start_pfn[nid];
unsigned long high = node_end_pfn[nid];
max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
......
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