2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Written by: Patricia Gaughen <gone@us.ibm.com>, IBM Corporation
|
|
|
|
* August 2002: added remote node KVA remap - Martin J. Bligh
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, IBM Corp.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
|
|
|
* NON INFRINGEMENT. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/bootmem.h>
|
2010-08-25 20:39:17 +00:00
|
|
|
#include <linux/memblock.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/mmzone.h>
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/initrd.h>
|
|
|
|
#include <linux/nodemask.h>
|
2005-06-23 07:08:33 +00:00
|
|
|
#include <linux/module.h>
|
2005-06-25 21:58:01 +00:00
|
|
|
#include <linux/kexec.h>
|
2006-03-27 09:16:04 +00:00
|
|
|
#include <linux/pfn.h>
|
2007-05-16 01:45:49 +00:00
|
|
|
#include <linux/swap.h>
|
2008-01-30 12:33:25 +00:00
|
|
|
#include <linux/acpi.h>
|
2005-06-25 21:58:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/e820.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/mmzone.h>
|
2008-03-17 19:08:17 +00:00
|
|
|
#include <asm/bios_ebda.h>
|
2008-06-02 04:06:31 +00:00
|
|
|
#include <asm/proto.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-06 22:17:45 +00:00
|
|
|
struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
|
2005-06-23 07:08:33 +00:00
|
|
|
EXPORT_SYMBOL(node_data);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
2006-06-30 16:29:51 +00:00
|
|
|
* numa interface - we expect the numa architecture specific code to have
|
2005-04-16 22:20:36 +00:00
|
|
|
* populated the following initialisation.
|
|
|
|
*
|
|
|
|
* 1) node_online_map - the map of all nodes configured (online) in the system
|
2005-06-23 07:07:57 +00:00
|
|
|
* 2) node_start_pfn - the starting page frame number for a node
|
2005-04-16 22:20:36 +00:00
|
|
|
* 3) node_end_pfn - the ending page fram number for a node
|
|
|
|
*/
|
2005-09-06 22:17:45 +00:00
|
|
|
unsigned long node_start_pfn[MAX_NUMNODES] __read_mostly;
|
|
|
|
unsigned long node_end_pfn[MAX_NUMNODES] __read_mostly;
|
2005-06-23 07:07:57 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-06-23 07:07:57 +00:00
|
|
|
#ifdef CONFIG_DISCONTIGMEM
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2005-06-23 07:07:57 +00:00
|
|
|
* 4) physnode_map - the mapping between a pfn and owning node
|
2005-04-16 22:20:36 +00:00
|
|
|
* physnode_map keeps track of the physical memory layout of a generic
|
2008-06-01 05:51:51 +00:00
|
|
|
* numa node on a 64Mb break (each element of the array will
|
|
|
|
* represent 64Mb of memory and will be marked by the node id. so,
|
2005-04-16 22:20:36 +00:00
|
|
|
* if the first gig is on node 0, and the second gig is on node 1
|
|
|
|
* physnode_map will contain:
|
|
|
|
*
|
2008-06-01 05:51:51 +00:00
|
|
|
* physnode_map[0-15] = 0;
|
|
|
|
* physnode_map[16-31] = 1;
|
|
|
|
* physnode_map[32- ] = -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-09-06 22:17:45 +00:00
|
|
|
s8 physnode_map[MAX_ELEMENTS] __read_mostly = { [0 ... (MAX_ELEMENTS - 1)] = -1};
|
2005-06-23 07:08:33 +00:00
|
|
|
EXPORT_SYMBOL(physnode_map);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
void memory_present(int nid, unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
unsigned long pfn;
|
|
|
|
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_INFO "Node: %d, start_pfn: %lx, end_pfn: %lx\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
nid, start, end);
|
|
|
|
printk(KERN_DEBUG " Setting physnode_map array to node %d for pfns:\n", nid);
|
|
|
|
printk(KERN_DEBUG " ");
|
|
|
|
for (pfn = start; pfn < end; pfn += PAGES_PER_ELEMENT) {
|
|
|
|
physnode_map[pfn / PAGES_PER_ELEMENT] = nid;
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_CONT "%lx ", pfn);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-06-01 05:51:51 +00:00
|
|
|
printk(KERN_CONT "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long node_memmap_size_bytes(int nid, unsigned long start_pfn,
|
|
|
|
unsigned long end_pfn)
|
|
|
|
{
|
|
|
|
unsigned long nr_pages = end_pfn - start_pfn;
|
|
|
|
|
|
|
|
if (!nr_pages)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (nr_pages + 1) * sizeof(struct page);
|
|
|
|
}
|
2005-06-23 07:07:57 +00:00
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
extern unsigned long find_max_low_pfn(void);
|
|
|
|
extern unsigned long highend_pfn, highstart_pfn;
|
|
|
|
|
|
|
|
#define LARGE_PAGE_BYTES (PTRS_PER_PTE * PAGE_SIZE)
|
|
|
|
|
2011-04-04 22:23:53 +00:00
|
|
|
static unsigned long node_remap_size[MAX_NUMNODES];
|
2007-10-17 16:04:36 +00:00
|
|
|
static void *node_remap_start_vaddr[MAX_NUMNODES];
|
2005-04-16 22:20:36 +00:00
|
|
|
void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
|
|
|
|
|
2011-01-23 13:37:39 +00:00
|
|
|
int __cpuinit numa_cpu_node(int cpu)
|
|
|
|
{
|
|
|
|
return apic->x86_32_numa_cpu_node(cpu);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* FLAT - support for basic PC memory model with discontig enabled, essentially
|
|
|
|
* a single node with all available processors in it with a flat
|
|
|
|
* memory map.
|
|
|
|
*/
|
|
|
|
int __init get_memcfg_numa_flat(void)
|
|
|
|
{
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_DEBUG "NUMA - single node, flat memory mode\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
node_start_pfn[0] = 0;
|
|
|
|
node_end_pfn[0] = max_pfn;
|
2010-08-25 20:39:17 +00:00
|
|
|
memblock_x86_register_active_regions(0, 0, max_pfn);
|
2005-04-16 22:20:36 +00:00
|
|
|
memory_present(0, 0, max_pfn);
|
|
|
|
|
|
|
|
/* Indicate there is one node available. */
|
|
|
|
nodes_clear(node_online_map);
|
|
|
|
node_set_online(0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the highest page frame number we have available for the node
|
|
|
|
*/
|
2008-04-16 00:29:42 +00:00
|
|
|
static void __init propagate_e820_map_node(int nid)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if (node_end_pfn[nid] > max_pfn)
|
|
|
|
node_end_pfn[nid] = max_pfn;
|
|
|
|
/*
|
|
|
|
* if a user has given mem=XXXX, then we need to make sure
|
|
|
|
* that the node _starts_ before that, too, not just ends
|
|
|
|
*/
|
|
|
|
if (node_start_pfn[nid] > max_pfn)
|
|
|
|
node_start_pfn[nid] = max_pfn;
|
2006-10-03 21:34:58 +00:00
|
|
|
BUG_ON(node_start_pfn[nid] > node_end_pfn[nid]);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate memory for the pg_data_t for this node via a crude pre-bootmem
|
|
|
|
* method. For node zero take this from the bottom of memory, for
|
|
|
|
* subsequent nodes place them at node_remap_start_vaddr which contains
|
|
|
|
* node local data in physically node local memory. See setup_memory()
|
|
|
|
* for details.
|
|
|
|
*/
|
|
|
|
static void __init allocate_pgdat(int nid)
|
|
|
|
{
|
2008-07-01 01:34:58 +00:00
|
|
|
char buf[16];
|
|
|
|
|
2011-04-04 22:23:57 +00:00
|
|
|
NODE_DATA(nid) = alloc_remap(nid, ALIGN(sizeof(pg_data_t), PAGE_SIZE));
|
|
|
|
if (!NODE_DATA(nid)) {
|
2008-05-29 19:57:22 +00:00
|
|
|
unsigned long pgdat_phys;
|
2010-08-25 20:39:17 +00:00
|
|
|
pgdat_phys = memblock_find_in_range(min_low_pfn<<PAGE_SHIFT,
|
2008-07-01 01:34:58 +00:00
|
|
|
max_pfn_mapped<<PAGE_SHIFT,
|
2008-06-02 06:53:50 +00:00
|
|
|
sizeof(pg_data_t),
|
2008-05-29 19:57:22 +00:00
|
|
|
PAGE_SIZE);
|
|
|
|
NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(pgdat_phys>>PAGE_SHIFT));
|
2008-07-01 01:34:58 +00:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
sprintf(buf, "NODE_DATA %d", nid);
|
2010-08-25 20:39:17 +00:00
|
|
|
memblock_x86_reserve_range(pgdat_phys, pgdat_phys + sizeof(pg_data_t), buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-06-01 20:15:22 +00:00
|
|
|
printk(KERN_DEBUG "allocate_pgdat: node %d NODE_DATA %08lx\n",
|
|
|
|
nid, (unsigned long)NODE_DATA(nid));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-30 12:33:25 +00:00
|
|
|
/*
|
2008-05-20 10:01:08 +00:00
|
|
|
* In the DISCONTIGMEM and SPARSEMEM memory model, a portion of the kernel
|
|
|
|
* virtual address space (KVA) is reserved and portions of nodes are mapped
|
|
|
|
* using it. This is to allow node-local memory to be allocated for
|
|
|
|
* structures that would normally require ZONE_NORMAL. The memory is
|
|
|
|
* allocated with alloc_remap() and callers should be prepared to allocate
|
|
|
|
* from the bootmem allocator instead.
|
2008-01-30 12:33:25 +00:00
|
|
|
*/
|
|
|
|
static unsigned long node_remap_start_pfn[MAX_NUMNODES];
|
|
|
|
static void *node_remap_end_vaddr[MAX_NUMNODES];
|
|
|
|
static void *node_remap_alloc_vaddr[MAX_NUMNODES];
|
|
|
|
static unsigned long node_remap_offset[MAX_NUMNODES];
|
|
|
|
|
2005-06-23 07:07:39 +00:00
|
|
|
void *alloc_remap(int nid, unsigned long size)
|
|
|
|
{
|
|
|
|
void *allocation = node_remap_alloc_vaddr[nid];
|
|
|
|
|
|
|
|
size = ALIGN(size, L1_CACHE_BYTES);
|
|
|
|
|
2011-04-04 22:23:47 +00:00
|
|
|
if (!allocation || (allocation + size) > node_remap_end_vaddr[nid])
|
2009-02-22 00:01:13 +00:00
|
|
|
return NULL;
|
2005-06-23 07:07:39 +00:00
|
|
|
|
|
|
|
node_remap_alloc_vaddr[nid] += size;
|
|
|
|
memset(allocation, 0, size);
|
|
|
|
|
|
|
|
return allocation;
|
|
|
|
}
|
|
|
|
|
2008-11-12 22:22:35 +00:00
|
|
|
#ifdef CONFIG_HIBERNATION
|
|
|
|
/**
|
|
|
|
* resume_map_numa_kva - add KVA mapping to the temporary page tables created
|
|
|
|
* during resume from hibernation
|
|
|
|
* @pgd_base - temporary resume page directory
|
|
|
|
*/
|
|
|
|
void resume_map_numa_kva(pgd_t *pgd_base)
|
|
|
|
{
|
|
|
|
int node;
|
|
|
|
|
|
|
|
for_each_online_node(node) {
|
|
|
|
unsigned long start_va, start_pfn, size, pfn;
|
|
|
|
|
|
|
|
start_va = (unsigned long)node_remap_start_vaddr[node];
|
|
|
|
start_pfn = node_remap_start_pfn[node];
|
|
|
|
size = node_remap_size[node];
|
|
|
|
|
2009-01-07 22:42:41 +00:00
|
|
|
printk(KERN_DEBUG "%s: node %d\n", __func__, node);
|
2008-11-12 22:22:35 +00:00
|
|
|
|
|
|
|
for (pfn = 0; pfn < size; pfn += PTRS_PER_PTE) {
|
|
|
|
unsigned long vaddr = start_va + (pfn << PAGE_SHIFT);
|
|
|
|
pgd_t *pgd = pgd_base + pgd_index(vaddr);
|
|
|
|
pud_t *pud = pud_offset(pgd, vaddr);
|
|
|
|
pmd_t *pmd = pmd_offset(pud, vaddr);
|
|
|
|
|
|
|
|
set_pmd(pmd, pfn_pmd(start_pfn + pfn,
|
|
|
|
PAGE_KERNEL_LARGE_EXEC));
|
|
|
|
|
|
|
|
printk(KERN_DEBUG "%s: %08lx -> pfn %08lx\n",
|
2009-01-07 22:42:41 +00:00
|
|
|
__func__, vaddr, start_pfn + pfn);
|
2008-11-12 22:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-04 22:23:50 +00:00
|
|
|
static __init unsigned long init_alloc_remap(int nid, unsigned long offset)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-04-04 22:23:56 +00:00
|
|
|
unsigned long size, pfn;
|
2011-04-04 22:23:55 +00:00
|
|
|
u64 node_pa, remap_pa;
|
|
|
|
void *remap_va;
|
2011-04-04 22:23:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The acpi/srat node info can show hot-add memroy zones where
|
|
|
|
* memory could be added but not currently present.
|
|
|
|
*/
|
|
|
|
printk(KERN_DEBUG "node %d pfn: [%lx - %lx]\n",
|
|
|
|
nid, node_start_pfn[nid], node_end_pfn[nid]);
|
|
|
|
if (node_start_pfn[nid] > max_pfn)
|
|
|
|
return 0;
|
|
|
|
if (!node_end_pfn[nid])
|
|
|
|
return 0;
|
|
|
|
if (node_end_pfn[nid] > max_pfn)
|
|
|
|
node_end_pfn[nid] = max_pfn;
|
|
|
|
|
2011-04-04 22:23:53 +00:00
|
|
|
/* calculate the necessary space aligned to large page size */
|
|
|
|
size = node_memmap_size_bytes(nid, node_start_pfn[nid],
|
|
|
|
min(node_end_pfn[nid], max_pfn));
|
2011-04-04 22:23:50 +00:00
|
|
|
size += ALIGN(sizeof(pg_data_t), PAGE_SIZE);
|
2011-04-04 22:23:52 +00:00
|
|
|
size = ALIGN(size, LARGE_PAGE_BYTES);
|
2011-04-04 22:23:50 +00:00
|
|
|
|
2011-04-04 22:23:55 +00:00
|
|
|
/* allocate node memory and the lowmem remap area */
|
2011-04-04 22:23:51 +00:00
|
|
|
node_pa = memblock_find_in_range(node_start_pfn[nid] << PAGE_SHIFT,
|
|
|
|
(u64)node_end_pfn[nid] << PAGE_SHIFT,
|
2011-04-04 22:23:52 +00:00
|
|
|
size, LARGE_PAGE_BYTES);
|
2011-04-04 22:23:54 +00:00
|
|
|
if (node_pa == MEMBLOCK_ERROR) {
|
|
|
|
pr_warning("remap_alloc: failed to allocate %lu bytes for node %d\n",
|
|
|
|
size, nid);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-04-04 22:23:55 +00:00
|
|
|
memblock_x86_reserve_range(node_pa, node_pa + size, "KVA RAM");
|
|
|
|
|
|
|
|
remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
|
|
|
|
max_low_pfn << PAGE_SHIFT,
|
|
|
|
size, LARGE_PAGE_BYTES);
|
|
|
|
if (remap_pa == MEMBLOCK_ERROR) {
|
|
|
|
pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n",
|
|
|
|
size, nid);
|
|
|
|
memblock_x86_free_range(node_pa, node_pa + size);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
memblock_x86_reserve_range(remap_pa, remap_pa + size, "KVA PG");
|
|
|
|
remap_va = phys_to_virt(remap_pa);
|
2011-04-04 22:23:50 +00:00
|
|
|
|
2011-04-04 22:23:56 +00:00
|
|
|
/* perform actual remap */
|
|
|
|
for (pfn = 0; pfn < size >> PAGE_SHIFT; pfn += PTRS_PER_PTE)
|
|
|
|
set_pmd_pfn((unsigned long)remap_va + (pfn << PAGE_SHIFT),
|
|
|
|
(node_pa >> PAGE_SHIFT) + pfn,
|
|
|
|
PAGE_KERNEL_LARGE);
|
|
|
|
|
2011-04-04 22:23:55 +00:00
|
|
|
/* initialize remap allocator parameters */
|
|
|
|
node_remap_start_pfn[nid] = node_pa >> PAGE_SHIFT;
|
2011-04-04 22:23:52 +00:00
|
|
|
node_remap_size[nid] = size >> PAGE_SHIFT;
|
2011-04-04 22:23:50 +00:00
|
|
|
node_remap_offset[nid] = offset;
|
|
|
|
|
2011-04-04 22:23:55 +00:00
|
|
|
node_remap_start_vaddr[nid] = remap_va;
|
|
|
|
node_remap_end_vaddr[nid] = remap_va + size;
|
2011-04-04 22:23:57 +00:00
|
|
|
node_remap_alloc_vaddr[nid] = remap_va;
|
2011-04-04 22:23:50 +00:00
|
|
|
|
2011-04-04 22:23:55 +00:00
|
|
|
printk(KERN_DEBUG "remap_alloc: node %d [%08llx-%08llx) -> [%p-%p)\n",
|
|
|
|
nid, node_pa, node_pa + size, remap_va, remap_va + size);
|
2011-04-04 22:23:50 +00:00
|
|
|
|
2011-04-04 22:23:52 +00:00
|
|
|
return size >> PAGE_SHIFT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-02-16 11:13:06 +00:00
|
|
|
void __init initmem_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-04-04 22:23:50 +00:00
|
|
|
unsigned long reserve_pages = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
int nid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When mapping a NUMA machine we allocate the node_mem_map arrays
|
|
|
|
* from node local memory. They are then mapped directly into KVA
|
|
|
|
* between zone normal and vmalloc space. Calculate the size of
|
2007-10-19 23:13:56 +00:00
|
|
|
* this space and use it to adjust the boundary between ZONE_NORMAL
|
2005-04-16 22:20:36 +00:00
|
|
|
* and ZONE_HIGHMEM.
|
|
|
|
*/
|
2008-06-04 02:35:04 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
get_memcfg_numa();
|
2011-01-23 13:37:42 +00:00
|
|
|
numa_init_array();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-04-04 22:23:50 +00:00
|
|
|
for_each_online_node(nid)
|
|
|
|
reserve_pages += init_alloc_remap(nid, reserve_pages);
|
2011-04-04 22:23:55 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
highstart_pfn = highend_pfn = max_pfn;
|
2008-06-23 10:05:30 +00:00
|
|
|
if (max_pfn > max_low_pfn)
|
|
|
|
highstart_pfn = max_low_pfn;
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
|
|
|
|
pages_to_mb(highend_pfn - highstart_pfn));
|
2006-09-26 08:52:31 +00:00
|
|
|
num_physpages = highend_pfn;
|
|
|
|
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
|
|
|
|
#else
|
2008-06-23 10:05:30 +00:00
|
|
|
num_physpages = max_low_pfn;
|
|
|
|
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
|
2008-06-23 10:05:30 +00:00
|
|
|
pages_to_mb(max_low_pfn));
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_DEBUG "max_low_pfn = %lx, highstart_pfn = %lx\n",
|
|
|
|
max_low_pfn, highstart_pfn);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_DEBUG "Low memory ends at vaddr %08lx\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
(ulong) pfn_to_kaddr(max_low_pfn));
|
2011-04-04 22:23:55 +00:00
|
|
|
for_each_online_node(nid)
|
2005-04-16 22:20:36 +00:00
|
|
|
allocate_pgdat(nid);
|
2008-06-24 19:19:41 +00:00
|
|
|
|
2008-06-23 23:41:30 +00:00
|
|
|
printk(KERN_DEBUG "High memory starts at vaddr %08lx\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
(ulong) pfn_to_kaddr(highstart_pfn));
|
|
|
|
for_each_online_node(nid)
|
2008-04-16 00:29:42 +00:00
|
|
|
propagate_e820_map_node(nid);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-04 09:22:35 +00:00
|
|
|
for_each_online_node(nid) {
|
2008-06-24 19:19:41 +00:00
|
|
|
memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
|
2010-02-10 09:20:28 +00:00
|
|
|
NODE_DATA(nid)->node_id = nid;
|
2009-03-04 09:22:35 +00:00
|
|
|
}
|
2008-06-24 19:19:41 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
setup_bootmem_allocator();
|
|
|
|
}
|
|
|
|
|
2006-12-22 09:11:13 +00:00
|
|
|
#ifdef CONFIG_MEMORY_HOTPLUG
|
2007-10-24 16:24:47 +00:00
|
|
|
static int paddr_to_nid(u64 addr)
|
2006-12-22 09:11:13 +00:00
|
|
|
{
|
|
|
|
int nid;
|
|
|
|
unsigned long pfn = PFN_DOWN(addr);
|
|
|
|
|
|
|
|
for_each_node(nid)
|
|
|
|
if (node_start_pfn[nid] <= pfn &&
|
|
|
|
pfn < node_end_pfn[nid])
|
|
|
|
return nid;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function is used to ask node id BEFORE memmap and mem_section's
|
|
|
|
* initialization (pfn_to_nid() can't be used yet).
|
|
|
|
* If _PXM is not defined on ACPI's DSDT, node id must be found by this.
|
|
|
|
*/
|
|
|
|
int memory_add_physaddr_to_nid(u64 addr)
|
|
|
|
{
|
|
|
|
int nid = paddr_to_nid(addr);
|
|
|
|
return (nid >= 0) ? nid : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
|
|
|
|
#endif
|
2008-06-03 08:09:45 +00:00
|
|
|
|