提交 3560e249 编写于 作者: J Johannes Weiner 提交者: Linus Torvalds

bootmem: replace node_boot_start in struct bootmem_data

Almost all users of this field need a PFN instead of a physical address,
so replace node_boot_start with node_min_pfn.

[Lee.Schermerhorn@hp.com: fix spurious BUG_ON() in mark_bootmem()]
Signed-off-by: NJohannes Weiner <hannes@saeureba.de>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: NLee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 75a56cfe
...@@ -304,7 +304,7 @@ void __init paging_init(void) ...@@ -304,7 +304,7 @@ void __init paging_init(void)
for_each_online_node(nid) { for_each_online_node(nid) {
bootmem_data_t *bdata = &bootmem_node_data[nid]; bootmem_data_t *bdata = &bootmem_node_data[nid];
unsigned long start_pfn = bdata->node_boot_start >> PAGE_SHIFT; unsigned long start_pfn = bdata->node_min_pfn;
unsigned long end_pfn = bdata->node_low_pfn; unsigned long end_pfn = bdata->node_low_pfn;
if (dma_local_pfn >= end_pfn - start_pfn) if (dma_local_pfn >= end_pfn - start_pfn)
......
...@@ -182,7 +182,7 @@ void __init omapfb_reserve_sdram(void) ...@@ -182,7 +182,7 @@ void __init omapfb_reserve_sdram(void)
return; return;
bdata = NODE_DATA(0)->bdata; bdata = NODE_DATA(0)->bdata;
sdram_start = bdata->node_boot_start; sdram_start = bdata->node_min_pfn << PAGE_SHIFT;
sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start; sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start;
reserved = 0; reserved = 0;
for (i = 0; ; i++) { for (i = 0; ; i++) {
...@@ -340,5 +340,3 @@ unsigned long omapfb_reserve_sram(unsigned long sram_pstart, ...@@ -340,5 +340,3 @@ unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
#endif #endif
...@@ -119,8 +119,7 @@ void __init paging_init(void) ...@@ -119,8 +119,7 @@ void __init paging_init(void)
unsigned long zones_size[MAX_NR_ZONES]; unsigned long zones_size[MAX_NR_ZONES];
unsigned long low, start_pfn; unsigned long low, start_pfn;
start_pfn = pgdat->bdata->node_boot_start; start_pfn = pgdat->bdata->node_min_pfn;
start_pfn >>= PAGE_SHIFT;
low = pgdat->bdata->node_low_pfn; low = pgdat->bdata->node_low_pfn;
memset(zones_size, 0, sizeof(zones_size)); memset(zones_size, 0, sizeof(zones_size));
......
...@@ -74,17 +74,17 @@ pg_data_t *pgdat_list[MAX_NUMNODES]; ...@@ -74,17 +74,17 @@ pg_data_t *pgdat_list[MAX_NUMNODES];
static int __init build_node_maps(unsigned long start, unsigned long len, static int __init build_node_maps(unsigned long start, unsigned long len,
int node) int node)
{ {
unsigned long cstart, epfn, end = start + len; unsigned long spfn, epfn, end = start + len;
struct bootmem_data *bdp = &bootmem_node_data[node]; struct bootmem_data *bdp = &bootmem_node_data[node];
epfn = GRANULEROUNDUP(end) >> PAGE_SHIFT; epfn = GRANULEROUNDUP(end) >> PAGE_SHIFT;
cstart = GRANULEROUNDDOWN(start); spfn = GRANULEROUNDDOWN(start) >> PAGE_SHIFT;
if (!bdp->node_low_pfn) { if (!bdp->node_low_pfn) {
bdp->node_boot_start = cstart; bdp->node_min_pfn = spfn;
bdp->node_low_pfn = epfn; bdp->node_low_pfn = epfn;
} else { } else {
bdp->node_boot_start = min(cstart, bdp->node_boot_start); bdp->node_min_pfn = min(spfn, bdp->node_min_pfn);
bdp->node_low_pfn = max(epfn, bdp->node_low_pfn); bdp->node_low_pfn = max(epfn, bdp->node_low_pfn);
} }
...@@ -221,20 +221,21 @@ static void __init fill_pernode(int node, unsigned long pernode, ...@@ -221,20 +221,21 @@ static void __init fill_pernode(int node, unsigned long pernode,
static int __init find_pernode_space(unsigned long start, unsigned long len, static int __init find_pernode_space(unsigned long start, unsigned long len,
int node) int node)
{ {
unsigned long epfn; unsigned long spfn, epfn;
unsigned long pernodesize = 0, pernode, pages, mapsize; unsigned long pernodesize = 0, pernode, pages, mapsize;
struct bootmem_data *bdp = &bootmem_node_data[node]; struct bootmem_data *bdp = &bootmem_node_data[node];
spfn = start >> PAGE_SHIFT;
epfn = (start + len) >> PAGE_SHIFT; epfn = (start + len) >> PAGE_SHIFT;
pages = bdp->node_low_pfn - (bdp->node_boot_start >> PAGE_SHIFT); pages = bdp->node_low_pfn - bdp->node_min_pfn;
mapsize = bootmem_bootmap_pages(pages) << PAGE_SHIFT; mapsize = bootmem_bootmap_pages(pages) << PAGE_SHIFT;
/* /*
* Make sure this memory falls within this node's usable memory * Make sure this memory falls within this node's usable memory
* since we may have thrown some away in build_maps(). * since we may have thrown some away in build_maps().
*/ */
if (start < bdp->node_boot_start || epfn > bdp->node_low_pfn) if (spfn < bdp->node_min_pfn || epfn > bdp->node_low_pfn)
return 0; return 0;
/* Don't setup this node's local space twice... */ /* Don't setup this node's local space twice... */
...@@ -296,7 +297,7 @@ static void __init reserve_pernode_space(void) ...@@ -296,7 +297,7 @@ static void __init reserve_pernode_space(void)
bdp = pdp->bdata; bdp = pdp->bdata;
/* First the bootmem_map itself */ /* First the bootmem_map itself */
pages = bdp->node_low_pfn - (bdp->node_boot_start>>PAGE_SHIFT); pages = bdp->node_low_pfn - bdp->node_min_pfn;
size = bootmem_bootmap_pages(pages) << PAGE_SHIFT; size = bootmem_bootmap_pages(pages) << PAGE_SHIFT;
base = __pa(bdp->node_bootmem_map); base = __pa(bdp->node_bootmem_map);
reserve_bootmem_node(pdp, base, size, BOOTMEM_DEFAULT); reserve_bootmem_node(pdp, base, size, BOOTMEM_DEFAULT);
...@@ -466,7 +467,7 @@ void __init find_memory(void) ...@@ -466,7 +467,7 @@ void __init find_memory(void)
init_bootmem_node(pgdat_list[node], init_bootmem_node(pgdat_list[node],
map>>PAGE_SHIFT, map>>PAGE_SHIFT,
bdp->node_boot_start>>PAGE_SHIFT, bdp->node_min_pfn,
bdp->node_low_pfn); bdp->node_low_pfn);
} }
......
...@@ -123,8 +123,7 @@ unsigned long __init setup_memory(void) ...@@ -123,8 +123,7 @@ unsigned long __init setup_memory(void)
return max_low_pfn; return max_low_pfn;
} }
#define START_PFN(nid) \ #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
(NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT)
#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
unsigned long __init zone_sizes_init(void) unsigned long __init zone_sizes_init(void)
......
...@@ -93,8 +93,7 @@ void free_initrd_mem(unsigned long, unsigned long); ...@@ -93,8 +93,7 @@ void free_initrd_mem(unsigned long, unsigned long);
#endif #endif
/* It'd be good if these lines were in the standard header file. */ /* It'd be good if these lines were in the standard header file. */
#define START_PFN(nid) \ #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
(NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT)
#define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
...@@ -252,4 +251,3 @@ void free_initrd_mem(unsigned long start, unsigned long end) ...@@ -252,4 +251,3 @@ void free_initrd_mem(unsigned long start, unsigned long end)
printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10); printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
} }
#endif #endif
...@@ -67,8 +67,8 @@ void __init paging_init(void) ...@@ -67,8 +67,8 @@ void __init paging_init(void)
/* declare the sizes of the RAM zones (only use the normal zone) */ /* declare the sizes of the RAM zones (only use the normal zone) */
zones_size[ZONE_NORMAL] = zones_size[ZONE_NORMAL] =
(contig_page_data.bdata->node_low_pfn) - contig_page_data.bdata->node_low_pfn -
(contig_page_data.bdata->node_boot_start >> PAGE_SHIFT); contig_page_data.bdata->node_min_pfn;
/* pass the memory from the bootmem allocator to the main allocator */ /* pass the memory from the bootmem allocator to the main allocator */
free_area_init(zones_size); free_area_init(zones_size);
...@@ -87,7 +87,7 @@ void __init mem_init(void) ...@@ -87,7 +87,7 @@ void __init mem_init(void)
if (!mem_map) if (!mem_map)
BUG(); BUG();
#define START_PFN (contig_page_data.bdata->node_boot_start >> PAGE_SHIFT) #define START_PFN (contig_page_data.bdata->node_min_pfn)
#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn) #define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn)
max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN; max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
......
...@@ -191,7 +191,7 @@ void __init paging_init(void) ...@@ -191,7 +191,7 @@ void __init paging_init(void)
pg_data_t *pgdat = NODE_DATA(nid); pg_data_t *pgdat = NODE_DATA(nid);
unsigned long low, start_pfn; unsigned long low, start_pfn;
start_pfn = pgdat->bdata->node_boot_start >> PAGE_SHIFT; start_pfn = pgdat->bdata->node_min_pfn;
low = pgdat->bdata->node_low_pfn; low = pgdat->bdata->node_low_pfn;
if (max_zone_pfns[ZONE_NORMAL] < low) if (max_zone_pfns[ZONE_NORMAL] < low)
......
...@@ -28,7 +28,7 @@ extern unsigned long saved_max_pfn; ...@@ -28,7 +28,7 @@ extern unsigned long saved_max_pfn;
* memory pages (including holes) on the node. * memory pages (including holes) on the node.
*/ */
typedef struct bootmem_data { typedef struct bootmem_data {
unsigned long node_boot_start; unsigned long node_min_pfn;
unsigned long node_low_pfn; unsigned long node_low_pfn;
void *node_bootmem_map; void *node_bootmem_map;
unsigned long last_end_off; unsigned long last_end_off;
......
...@@ -80,7 +80,7 @@ static void __init link_bootmem(bootmem_data_t *bdata) ...@@ -80,7 +80,7 @@ static void __init link_bootmem(bootmem_data_t *bdata)
bootmem_data_t *ent; bootmem_data_t *ent;
ent = list_entry(iter, bootmem_data_t, list); ent = list_entry(iter, bootmem_data_t, list);
if (bdata->node_boot_start < ent->node_boot_start) if (bdata->node_min_pfn < ent->node_min_pfn)
break; break;
} }
list_add_tail(&bdata->list, iter); list_add_tail(&bdata->list, iter);
...@@ -96,7 +96,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata, ...@@ -96,7 +96,7 @@ static unsigned long __init init_bootmem_core(bootmem_data_t *bdata,
mminit_validate_memmodel_limits(&start, &end); mminit_validate_memmodel_limits(&start, &end);
bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart)); bdata->node_bootmem_map = phys_to_virt(PFN_PHYS(mapstart));
bdata->node_boot_start = PFN_PHYS(start); bdata->node_min_pfn = start;
bdata->node_low_pfn = end; bdata->node_low_pfn = end;
link_bootmem(bdata); link_bootmem(bdata);
...@@ -151,7 +151,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) ...@@ -151,7 +151,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
if (!bdata->node_bootmem_map) if (!bdata->node_bootmem_map)
return 0; return 0;
start = PFN_DOWN(bdata->node_boot_start); start = bdata->node_min_pfn;
end = bdata->node_low_pfn; end = bdata->node_low_pfn;
/* /*
...@@ -167,7 +167,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) ...@@ -167,7 +167,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
unsigned long *map, idx, vec; unsigned long *map, idx, vec;
map = bdata->node_bootmem_map; map = bdata->node_bootmem_map;
idx = start - PFN_DOWN(bdata->node_boot_start); idx = start - bdata->node_min_pfn;
vec = ~map[idx / BITS_PER_LONG]; vec = ~map[idx / BITS_PER_LONG];
if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) { if (aligned && vec == ~0UL && start + BITS_PER_LONG < end) {
...@@ -192,7 +192,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) ...@@ -192,7 +192,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
} }
page = virt_to_page(bdata->node_bootmem_map); page = virt_to_page(bdata->node_bootmem_map);
pages = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start); pages = bdata->node_low_pfn - bdata->node_min_pfn;
pages = bootmem_bootmap_pages(pages); pages = bootmem_bootmap_pages(pages);
count += pages; count += pages;
while (pages--) while (pages--)
...@@ -231,8 +231,8 @@ static void __init __free(bootmem_data_t *bdata, ...@@ -231,8 +231,8 @@ static void __init __free(bootmem_data_t *bdata,
unsigned long idx; unsigned long idx;
bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data, bdebug("nid=%td start=%lx end=%lx\n", bdata - bootmem_node_data,
sidx + PFN_DOWN(bdata->node_boot_start), sidx + bdata->node_min_pfn,
eidx + PFN_DOWN(bdata->node_boot_start)); eidx + bdata->node_min_pfn);
if (bdata->hint_idx > sidx) if (bdata->hint_idx > sidx)
bdata->hint_idx = sidx; bdata->hint_idx = sidx;
...@@ -250,8 +250,8 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx, ...@@ -250,8 +250,8 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
bdebug("nid=%td start=%lx end=%lx flags=%x\n", bdebug("nid=%td start=%lx end=%lx flags=%x\n",
bdata - bootmem_node_data, bdata - bootmem_node_data,
sidx + PFN_DOWN(bdata->node_boot_start), sidx + bdata->node_min_pfn,
eidx + PFN_DOWN(bdata->node_boot_start), eidx + bdata->node_min_pfn,
flags); flags);
for (idx = sidx; idx < eidx; idx++) for (idx = sidx; idx < eidx; idx++)
...@@ -261,7 +261,7 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx, ...@@ -261,7 +261,7 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
return -EBUSY; return -EBUSY;
} }
bdebug("silent double reserve of PFN %lx\n", bdebug("silent double reserve of PFN %lx\n",
idx + PFN_DOWN(bdata->node_boot_start)); idx + bdata->node_min_pfn);
} }
return 0; return 0;
} }
...@@ -275,11 +275,11 @@ static int __init mark_bootmem_node(bootmem_data_t *bdata, ...@@ -275,11 +275,11 @@ static int __init mark_bootmem_node(bootmem_data_t *bdata,
bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n", bdebug("nid=%td start=%lx end=%lx reserve=%d flags=%x\n",
bdata - bootmem_node_data, start, end, reserve, flags); bdata - bootmem_node_data, start, end, reserve, flags);
BUG_ON(start < PFN_DOWN(bdata->node_boot_start)); BUG_ON(start < bdata->node_min_pfn);
BUG_ON(end > bdata->node_low_pfn); BUG_ON(end > bdata->node_low_pfn);
sidx = start - PFN_DOWN(bdata->node_boot_start); sidx = start - bdata->node_min_pfn;
eidx = end - PFN_DOWN(bdata->node_boot_start); eidx = end - bdata->node_min_pfn;
if (reserve) if (reserve)
return __reserve(bdata, sidx, eidx, flags); return __reserve(bdata, sidx, eidx, flags);
...@@ -299,7 +299,8 @@ static int __init mark_bootmem(unsigned long start, unsigned long end, ...@@ -299,7 +299,8 @@ static int __init mark_bootmem(unsigned long start, unsigned long end,
int err; int err;
unsigned long max; unsigned long max;
if (pos < PFN_DOWN(bdata->node_boot_start)) { if (pos < bdata->node_min_pfn ||
pos >= bdata->node_low_pfn) {
BUG_ON(pos != start); BUG_ON(pos != start);
continue; continue;
} }
...@@ -422,7 +423,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata, ...@@ -422,7 +423,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT, bdata - bootmem_node_data, size, PAGE_ALIGN(size) >> PAGE_SHIFT,
align, goal, limit); align, goal, limit);
min = PFN_DOWN(bdata->node_boot_start); min = bdata->node_min_pfn;
max = bdata->node_low_pfn; max = bdata->node_low_pfn;
goal >>= PAGE_SHIFT; goal >>= PAGE_SHIFT;
...@@ -440,8 +441,8 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata, ...@@ -440,8 +441,8 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
else else
start = ALIGN(min, step); start = ALIGN(min, step);
sidx = start - PFN_DOWN(bdata->node_boot_start); sidx = start - bdata->node_min_pfn;;
midx = max - PFN_DOWN(bdata->node_boot_start); midx = max - bdata->node_min_pfn;
if (bdata->hint_idx > sidx) { if (bdata->hint_idx > sidx) {
/* /*
...@@ -491,7 +492,8 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata, ...@@ -491,7 +492,8 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
PFN_UP(end_off), BOOTMEM_EXCLUSIVE)) PFN_UP(end_off), BOOTMEM_EXCLUSIVE))
BUG(); BUG();
region = phys_to_virt(bdata->node_boot_start + start_off); region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
start_off);
memset(region, 0, size); memset(region, 0, size);
return region; return region;
} }
...@@ -518,7 +520,7 @@ static void * __init ___alloc_bootmem_nopanic(unsigned long size, ...@@ -518,7 +520,7 @@ static void * __init ___alloc_bootmem_nopanic(unsigned long size,
if (goal && bdata->node_low_pfn <= PFN_DOWN(goal)) if (goal && bdata->node_low_pfn <= PFN_DOWN(goal))
continue; continue;
if (limit && bdata->node_boot_start >= limit) if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
break; break;
region = alloc_bootmem_core(bdata, size, align, goal, limit); region = alloc_bootmem_core(bdata, size, align, goal, limit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册