#include <linux/init.h>
#include <linux/bootmem.h>
#include <linux/mman.h>
+#include <linux/nodemask.h>
#include <linux/initrd.h>
#include <asm/mach-types.h>
DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
-extern char _stext, _text, _etext, _end, __init_begin, __init_end;
+extern void _stext, _text, _etext, __data_start, _end, __init_begin, __init_end;
extern unsigned long phys_initrd_start;
extern unsigned long phys_initrd_size;
show_free_areas();
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
- for (node = 0; node < numnodes; node++) {
+ for_each_online_node(node) {
struct page *page, *end;
page = NODE_MEM_MAP(node);
node = mi->bank[i].node;
- if (node >= numnodes) {
- numnodes = node + 1;
-
- /*
- * Make sure we haven't exceeded the maximum number
- * of nodes that we have in this configuration. If
- * we have, we're in trouble. (maybe we ought to
- * limit, instead of bugging?)
- */
- if (numnodes > MAX_NUMNODES)
- BUG();
- }
+ /*
+ * Make sure we haven't exceeded the maximum number of nodes
+ * that we have in this configuration. If we have, we're in
+ * trouble. (maybe we ought to limit, instead of bugging?)
+ */
+ if (node >= MAX_NUMNODES)
+ BUG();
+ node_set_online(node);
/*
* Get the start and end pfns for this bank
* Calculate the number of pages we require to
* store the bootmem bitmaps.
*/
- for (i = 0; i < numnodes; i++) {
+ for_each_online_node(i) {
if (np[i].end == 0)
continue;
* Register the kernel text and data with bootmem.
* Note that this can only be in node 0.
*/
+#ifdef CONFIG_XIP_KERNEL
+ reserve_bootmem_node(pgdat, __pa(&__data_start), &_end - &__data_start);
+#else
reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext);
+#endif
/*
* Reserve the page tables. These are already in use,
* (we could also do with rolling bootmem_init and paging_init
* into one generic "memory_init" type function).
*/
- np += numnodes - 1;
- for (node = numnodes - 1; node >= 0; node--, np--) {
+ np += num_online_nodes() - 1;
+ for (node = num_online_nodes() - 1; node >= 0; node--, np--) {
/*
* If there are no pages in this node, ignore it.
* Note that node 0 must always have some pages.
*/
- if (np->end == 0) {
+ if (np->end == 0 || !node_online(node)) {
if (node == 0)
BUG();
continue;
/*
* initialise the zones within each node
*/
- for (node = 0; node < numnodes; node++) {
+ for_each_online_node(node) {
unsigned long zone_size[MAX_NR_ZONES];
unsigned long zhole_size[MAX_NR_ZONES];
struct bootmem_data *bdata;
int i, node;
codepages = &_etext - &_text;
- datapages = &_end - &_etext;
+ datapages = &_end - &__data_start;
initpages = &__init_end - &__init_begin;
#ifndef CONFIG_DISCONTIGMEM
create_memmap_holes(&meminfo);
/* this will put all unused low memory onto the freelists */
- for (node = 0; node < numnodes; node++) {
+ for_each_online_node(node) {
pg_data_t *pgdat = NODE_DATA(node);
if (pgdat->node_spanned_pages != 0)