2005-04-16 16:20:36 -06: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>
|
|
|
|
#include <linux/mmzone.h>
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/initrd.h>
|
|
|
|
#include <linux/nodemask.h>
|
2005-06-23 01:08:33 -06:00
|
|
|
#include <linux/module.h>
|
2005-06-25 15:58:01 -06:00
|
|
|
#include <linux/kexec.h>
|
2006-03-27 02:16:04 -07:00
|
|
|
#include <linux/pfn.h>
|
2007-05-15 19:45:49 -06:00
|
|
|
#include <linux/swap.h>
|
2008-01-30 05:33:25 -07:00
|
|
|
#include <linux/acpi.h>
|
2005-06-25 15:58:01 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/e820.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/mmzone.h>
|
2008-03-17 13:08:17 -06:00
|
|
|
#include <asm/bios_ebda.h>
|
2008-06-01 22:06:31 -06:00
|
|
|
#include <asm/proto.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-09-06 16:17:45 -06:00
|
|
|
struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
|
2005-06-23 01:08:33 -06:00
|
|
|
EXPORT_SYMBOL(node_data);
|
2007-10-24 10:24:47 -06:00
|
|
|
static bootmem_data_t node0_bdata;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2006-06-30 10:29:51 -06:00
|
|
|
* numa interface - we expect the numa architecture specific code to have
|
2005-04-16 16:20:36 -06:00
|
|
|
* populated the following initialisation.
|
|
|
|
*
|
|
|
|
* 1) node_online_map - the map of all nodes configured (online) in the system
|
2005-06-23 01:07:57 -06:00
|
|
|
* 2) node_start_pfn - the starting page frame number for a node
|
2005-04-16 16:20:36 -06:00
|
|
|
* 3) node_end_pfn - the ending page fram number for a node
|
|
|
|
*/
|
2005-09-06 16:17:45 -06:00
|
|
|
unsigned long node_start_pfn[MAX_NUMNODES] __read_mostly;
|
|
|
|
unsigned long node_end_pfn[MAX_NUMNODES] __read_mostly;
|
2005-06-23 01:07:57 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-06-23 01:07:57 -06:00
|
|
|
#ifdef CONFIG_DISCONTIGMEM
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2005-06-23 01:07:57 -06:00
|
|
|
* 4) physnode_map - the mapping between a pfn and owning node
|
2005-04-16 16:20:36 -06:00
|
|
|
* physnode_map keeps track of the physical memory layout of a generic
|
2008-05-31 23:51:51 -06: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 16:20:36 -06:00
|
|
|
* if the first gig is on node 0, and the second gig is on node 1
|
|
|
|
* physnode_map will contain:
|
|
|
|
*
|
2008-05-31 23:51:51 -06:00
|
|
|
* physnode_map[0-15] = 0;
|
|
|
|
* physnode_map[16-31] = 1;
|
|
|
|
* physnode_map[32- ] = -1;
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2005-09-06 16:17:45 -06:00
|
|
|
s8 physnode_map[MAX_ELEMENTS] __read_mostly = { [0 ... (MAX_ELEMENTS - 1)] = -1};
|
2005-06-23 01:08:33 -06:00
|
|
|
EXPORT_SYMBOL(physnode_map);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
void memory_present(int nid, unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
unsigned long pfn;
|
|
|
|
|
|
|
|
printk(KERN_INFO "Node: %d, start_pfn: %ld, end_pfn: %ld\n",
|
|
|
|
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-05-31 23:51:51 -06:00
|
|
|
printk(KERN_CONT "%ld ", pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2008-05-31 23:51:51 -06:00
|
|
|
printk(KERN_CONT "\n");
|
2005-04-16 16:20:36 -06: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 01:07:57 -06:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06: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)
|
|
|
|
|
|
|
|
unsigned long node_remap_size[MAX_NUMNODES];
|
2007-10-17 10:04:36 -06:00
|
|
|
static void *node_remap_start_vaddr[MAX_NUMNODES];
|
2005-04-16 16:20:36 -06:00
|
|
|
void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
|
|
|
|
|
2006-09-26 00:31:03 -06:00
|
|
|
static unsigned long kva_start_pfn;
|
|
|
|
static unsigned long kva_pages;
|
2005-04-16 16:20:36 -06: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)
|
|
|
|
{
|
|
|
|
printk("NUMA - single node, flat memory mode\n");
|
|
|
|
|
|
|
|
node_start_pfn[0] = 0;
|
|
|
|
node_end_pfn[0] = max_pfn;
|
2008-06-03 20:35:04 -06:00
|
|
|
e820_register_active_regions(0, 0, max_pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
memory_present(0, 0, max_pfn);
|
2008-05-31 23:53:47 -06:00
|
|
|
node_remap_size[0] = node_memmap_size_bytes(0, 0, max_pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* 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-15 18:29:42 -06:00
|
|
|
static void __init propagate_e820_map_node(int nid)
|
2005-04-16 16:20:36 -06: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 15:34:58 -06:00
|
|
|
BUG_ON(node_start_pfn[nid] > node_end_pfn[nid]);
|
2005-04-16 16:20:36 -06: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-05-20 04:01:19 -06:00
|
|
|
if (nid && node_has_online_mem(nid) && node_remap_start_vaddr[nid])
|
2005-04-16 16:20:36 -06:00
|
|
|
NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid];
|
|
|
|
else {
|
2008-05-29 13:57:22 -06:00
|
|
|
unsigned long pgdat_phys;
|
|
|
|
pgdat_phys = find_e820_area(min_low_pfn<<PAGE_SHIFT,
|
2008-06-02 00:53:50 -06:00
|
|
|
(nid ? max_low_pfn:max_pfn_mapped)<<PAGE_SHIFT,
|
|
|
|
sizeof(pg_data_t),
|
2008-05-29 13:57:22 -06:00
|
|
|
PAGE_SIZE);
|
|
|
|
NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(pgdat_phys>>PAGE_SHIFT));
|
|
|
|
reserve_early(pgdat_phys, pgdat_phys + sizeof(pg_data_t),
|
|
|
|
"NODE_DATA");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2008-06-01 14:15:22 -06:00
|
|
|
printk(KERN_DEBUG "allocate_pgdat: node %d NODE_DATA %08lx\n",
|
|
|
|
nid, (unsigned long)NODE_DATA(nid));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2008-01-30 05:33:25 -07:00
|
|
|
/*
|
2008-05-20 04:01:08 -06: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 05:33:25 -07: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 01:07:39 -06:00
|
|
|
void *alloc_remap(int nid, unsigned long size)
|
|
|
|
{
|
|
|
|
void *allocation = node_remap_alloc_vaddr[nid];
|
|
|
|
|
|
|
|
size = ALIGN(size, L1_CACHE_BYTES);
|
|
|
|
|
|
|
|
if (!allocation || (allocation + size) >= node_remap_end_vaddr[nid])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
node_remap_alloc_vaddr[nid] += size;
|
|
|
|
memset(allocation, 0, size);
|
|
|
|
|
|
|
|
return allocation;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
void __init remap_numa_kva(void)
|
|
|
|
{
|
|
|
|
void *vaddr;
|
|
|
|
unsigned long pfn;
|
|
|
|
int node;
|
|
|
|
|
|
|
|
for_each_online_node(node) {
|
2008-06-01 14:15:22 -06:00
|
|
|
printk(KERN_DEBUG "remap_numa_kva: node %d\n", node);
|
2005-04-16 16:20:36 -06:00
|
|
|
for (pfn=0; pfn < node_remap_size[node]; pfn += PTRS_PER_PTE) {
|
|
|
|
vaddr = node_remap_start_vaddr[node]+(pfn<<PAGE_SHIFT);
|
2008-06-01 14:15:22 -06:00
|
|
|
printk(KERN_DEBUG "remap_numa_kva: %08lx to pfn %08lx\n",
|
|
|
|
(unsigned long)vaddr,
|
|
|
|
node_remap_start_pfn[node] + pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
set_pmd_pfn((ulong) vaddr,
|
|
|
|
node_remap_start_pfn[node] + pfn,
|
|
|
|
PAGE_KERNEL_LARGE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long calculate_numa_remap_pages(void)
|
|
|
|
{
|
|
|
|
int nid;
|
|
|
|
unsigned long size, reserve_pages = 0;
|
|
|
|
|
|
|
|
for_each_online_node(nid) {
|
2008-06-13 20:08:52 -06:00
|
|
|
u64 node_kva_target;
|
|
|
|
u64 node_kva_final;
|
2006-09-27 02:49:51 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* The acpi/srat node info can show hot-add memroy zones
|
|
|
|
* where memory could be added but not currently present.
|
|
|
|
*/
|
2008-06-06 19:53:33 -06:00
|
|
|
printk("node %d pfn: [%lx - %lx]\n",
|
|
|
|
nid, node_start_pfn[nid], node_end_pfn[nid]);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (node_start_pfn[nid] > max_pfn)
|
|
|
|
continue;
|
2008-06-06 19:53:33 -06:00
|
|
|
if (!node_end_pfn[nid])
|
|
|
|
continue;
|
2005-04-16 16:20:36 -06:00
|
|
|
if (node_end_pfn[nid] > max_pfn)
|
|
|
|
node_end_pfn[nid] = max_pfn;
|
|
|
|
|
|
|
|
/* ensure the remap includes space for the pgdat. */
|
|
|
|
size = node_remap_size[nid] + sizeof(pg_data_t);
|
|
|
|
|
|
|
|
/* convert size to large (pmd size) pages, rounding up */
|
|
|
|
size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES;
|
|
|
|
/* now the roundup is correct, convert to PAGE_SIZE pages */
|
|
|
|
size = size * PTRS_PER_PTE;
|
2005-06-23 01:07:41 -06:00
|
|
|
|
2008-06-13 20:08:52 -06:00
|
|
|
node_kva_target = round_down(node_end_pfn[nid] - size,
|
2008-06-06 19:53:33 -06:00
|
|
|
PTRS_PER_PTE);
|
2008-06-13 20:08:52 -06:00
|
|
|
node_kva_target <<= PAGE_SHIFT;
|
2008-06-06 19:53:33 -06:00
|
|
|
do {
|
2008-06-13 20:08:52 -06:00
|
|
|
node_kva_final = find_e820_area(node_kva_target,
|
2008-06-06 19:53:33 -06:00
|
|
|
((u64)node_end_pfn[nid])<<PAGE_SHIFT,
|
|
|
|
((u64)size)<<PAGE_SHIFT,
|
|
|
|
LARGE_PAGE_BYTES);
|
2008-06-13 20:08:52 -06:00
|
|
|
node_kva_target -= LARGE_PAGE_BYTES;
|
|
|
|
} while (node_kva_final == -1ULL &&
|
|
|
|
(node_kva_target>>PAGE_SHIFT) > (node_start_pfn[nid]));
|
2008-06-06 19:53:33 -06:00
|
|
|
|
2008-06-13 20:08:52 -06:00
|
|
|
if (node_kva_final == -1ULL)
|
2008-06-06 19:53:33 -06:00
|
|
|
panic("Can not get kva ram\n");
|
2005-06-23 01:07:41 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
node_remap_size[nid] = size;
|
|
|
|
node_remap_offset[nid] = reserve_pages;
|
2005-06-23 01:07:39 -06:00
|
|
|
reserve_pages += size;
|
2008-06-13 20:08:52 -06:00
|
|
|
printk("Reserving %ld pages of KVA for lmem_map of node %d at %llx\n",
|
|
|
|
size, nid, node_kva_final>>PAGE_SHIFT);
|
2008-06-06 19:53:33 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* prevent kva address below max_low_pfn want it on system
|
|
|
|
* with less memory later.
|
|
|
|
* layout will be: KVA address , KVA RAM
|
2008-06-13 20:08:52 -06:00
|
|
|
*
|
|
|
|
* we are supposed to only record the one less then max_low_pfn
|
|
|
|
* but we could have some hole in high memory, and it will only
|
|
|
|
* check page_is_ram(pfn) && !page_is_reserved_early(pfn) to decide
|
|
|
|
* to use it as free.
|
|
|
|
* So reserve_early here, hope we don't run out of that array
|
2008-06-06 19:53:33 -06:00
|
|
|
*/
|
2008-06-13 20:08:52 -06:00
|
|
|
reserve_early(node_kva_final,
|
|
|
|
node_kva_final+(((u64)size)<<PAGE_SHIFT),
|
|
|
|
"KVA RAM");
|
2005-08-07 10:42:50 -06:00
|
|
|
|
2008-06-13 20:08:52 -06:00
|
|
|
node_remap_start_pfn[nid] = node_kva_final>>PAGE_SHIFT;
|
|
|
|
remove_active_range(nid, node_remap_start_pfn[nid],
|
|
|
|
node_remap_start_pfn[nid] + size);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
printk("Reserving total of %ld pages for numa KVA remap\n",
|
|
|
|
reserve_pages);
|
|
|
|
return reserve_pages;
|
|
|
|
}
|
|
|
|
|
2008-01-30 05:33:25 -07:00
|
|
|
static void init_remap_allocator(int nid)
|
|
|
|
{
|
|
|
|
node_remap_start_vaddr[nid] = pfn_to_kaddr(
|
|
|
|
kva_start_pfn + node_remap_offset[nid]);
|
|
|
|
node_remap_end_vaddr[nid] = node_remap_start_vaddr[nid] +
|
|
|
|
(node_remap_size[nid] * PAGE_SIZE);
|
|
|
|
node_remap_alloc_vaddr[nid] = node_remap_start_vaddr[nid] +
|
|
|
|
ALIGN(sizeof(pg_data_t), PAGE_SIZE);
|
|
|
|
|
|
|
|
printk ("node %d will remap to vaddr %08lx - %08lx\n", nid,
|
|
|
|
(ulong) node_remap_start_vaddr[nid],
|
2008-06-01 14:15:22 -06:00
|
|
|
(ulong) node_remap_end_vaddr[nid]);
|
2008-01-30 05:33:25 -07:00
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
extern void setup_bootmem_allocator(void);
|
|
|
|
unsigned long __init setup_memory(void)
|
|
|
|
{
|
|
|
|
int nid;
|
|
|
|
unsigned long system_start_pfn, system_max_low_pfn;
|
2008-06-03 20:32:30 -06:00
|
|
|
long kva_target_pfn;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 17:13:56 -06:00
|
|
|
* this space and use it to adjust the boundary between ZONE_NORMAL
|
2005-04-16 16:20:36 -06:00
|
|
|
* and ZONE_HIGHMEM.
|
|
|
|
*/
|
2008-06-03 20:35:04 -06:00
|
|
|
|
|
|
|
/* call find_max_low_pfn at first, it could update max_pfn */
|
|
|
|
system_max_low_pfn = max_low_pfn = find_max_low_pfn();
|
|
|
|
|
|
|
|
remove_all_active_ranges();
|
2005-04-16 16:20:36 -06:00
|
|
|
get_memcfg_numa();
|
|
|
|
|
2008-06-01 22:06:31 -06:00
|
|
|
kva_pages = round_up(calculate_numa_remap_pages(), PTRS_PER_PTE);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* partially used pages are not usable - thus round upwards */
|
|
|
|
system_start_pfn = min_low_pfn = PFN_UP(init_pg_tables_end);
|
|
|
|
|
2008-06-03 20:32:30 -06:00
|
|
|
kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
|
|
|
|
do {
|
|
|
|
kva_start_pfn = find_e820_area(kva_target_pfn<<PAGE_SHIFT,
|
|
|
|
max_low_pfn<<PAGE_SHIFT,
|
|
|
|
kva_pages<<PAGE_SHIFT,
|
|
|
|
PTRS_PER_PTE<<PAGE_SHIFT) >> PAGE_SHIFT;
|
|
|
|
kva_target_pfn -= PTRS_PER_PTE;
|
|
|
|
} while (kva_start_pfn == -1UL && kva_target_pfn > min_low_pfn);
|
2008-01-30 05:32:54 -07:00
|
|
|
|
2008-06-03 20:32:30 -06:00
|
|
|
if (kva_start_pfn == -1UL)
|
|
|
|
panic("Can not get kva space\n");
|
2006-09-26 00:31:03 -06:00
|
|
|
|
|
|
|
printk("kva_start_pfn ~ %ld find_max_low_pfn() ~ %ld\n",
|
|
|
|
kva_start_pfn, max_low_pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
printk("max_pfn = %ld\n", max_pfn);
|
2008-05-29 13:58:37 -06:00
|
|
|
|
|
|
|
/* avoid clash with initrd */
|
|
|
|
reserve_early(kva_start_pfn<<PAGE_SHIFT,
|
|
|
|
(kva_start_pfn + kva_pages)<<PAGE_SHIFT,
|
|
|
|
"KVA PG");
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
highstart_pfn = highend_pfn = max_pfn;
|
|
|
|
if (max_pfn > system_max_low_pfn)
|
|
|
|
highstart_pfn = system_max_low_pfn;
|
|
|
|
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
|
|
|
|
pages_to_mb(highend_pfn - highstart_pfn));
|
2006-09-26 02:52:31 -06:00
|
|
|
num_physpages = highend_pfn;
|
|
|
|
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
|
|
|
|
#else
|
|
|
|
num_physpages = system_max_low_pfn;
|
|
|
|
high_memory = (void *) __va(system_max_low_pfn * PAGE_SIZE - 1) + 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
|
|
|
printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
|
|
|
|
pages_to_mb(system_max_low_pfn));
|
|
|
|
printk("min_low_pfn = %ld, max_low_pfn = %ld, highstart_pfn = %ld\n",
|
|
|
|
min_low_pfn, max_low_pfn, highstart_pfn);
|
|
|
|
|
|
|
|
printk("Low memory ends at vaddr %08lx\n",
|
|
|
|
(ulong) pfn_to_kaddr(max_low_pfn));
|
|
|
|
for_each_online_node(nid) {
|
2008-01-30 05:33:25 -07:00
|
|
|
init_remap_allocator(nid);
|
2005-06-23 01:07:39 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
allocate_pgdat(nid);
|
|
|
|
}
|
|
|
|
printk("High memory starts at vaddr %08lx\n",
|
|
|
|
(ulong) pfn_to_kaddr(highstart_pfn));
|
|
|
|
for_each_online_node(nid)
|
2008-04-15 18:29:42 -06:00
|
|
|
propagate_e820_map_node(nid);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
memset(NODE_DATA(0), 0, sizeof(struct pglist_data));
|
|
|
|
NODE_DATA(0)->bdata = &node0_bdata;
|
|
|
|
setup_bootmem_allocator();
|
|
|
|
return max_low_pfn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init zone_sizes_init(void)
|
|
|
|
{
|
2006-10-11 02:20:39 -06:00
|
|
|
unsigned long max_zone_pfns[MAX_NR_ZONES];
|
|
|
|
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
|
|
|
|
max_zone_pfns[ZONE_DMA] =
|
|
|
|
virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
|
|
|
|
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
|
2007-05-15 19:45:49 -06:00
|
|
|
#ifdef CONFIG_HIGHMEM
|
2006-10-11 02:20:39 -06:00
|
|
|
max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
|
2007-05-15 19:45:49 -06:00
|
|
|
#endif
|
2006-09-27 02:49:51 -06:00
|
|
|
|
|
|
|
free_area_init_nodes(max_zone_pfns);
|
2005-04-16 16:20:36 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-16 17:11:08 -06:00
|
|
|
void __init set_highmem_pages_init(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
struct zone *zone;
|
2008-06-14 19:32:52 -06:00
|
|
|
int nid;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
for_each_zone(zone) {
|
2008-06-14 19:32:52 -06:00
|
|
|
unsigned long zone_start_pfn, zone_end_pfn;
|
2005-06-23 01:07:57 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!is_highmem(zone))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
zone_start_pfn = zone->zone_start_pfn;
|
2005-06-23 01:07:57 -06:00
|
|
|
zone_end_pfn = zone_start_pfn + zone->spanned_pages;
|
|
|
|
|
2008-06-14 19:32:52 -06:00
|
|
|
nid = zone_to_nid(zone);
|
2005-06-23 01:07:57 -06:00
|
|
|
printk("Initializing %s for node %d (%08lx:%08lx)\n",
|
2008-06-14 19:32:52 -06:00
|
|
|
zone->name, nid, zone_start_pfn, zone_end_pfn);
|
|
|
|
|
|
|
|
add_highpages_with_active_regions(nid, zone_start_pfn,
|
2008-06-16 17:11:08 -06:00
|
|
|
zone_end_pfn);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
totalram_pages += totalhigh_pages;
|
|
|
|
#endif
|
|
|
|
}
|
2006-12-22 02:11:13 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_MEMORY_HOTPLUG
|
2007-10-24 10:24:47 -06:00
|
|
|
static int paddr_to_nid(u64 addr)
|
2006-12-22 02:11:13 -07: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 02:09:45 -06:00
|
|
|
|
2008-06-03 03:36:56 -06:00
|
|
|
#if defined(CONFIG_ACPI_NUMA) && !defined(CONFIG_HAVE_ARCH_PARSE_SRAT)
|
2008-06-03 02:09:45 -06:00
|
|
|
/*
|
|
|
|
* Dummy on 32-bit, for now:
|
|
|
|
*/
|
|
|
|
void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
|
|
|
|
{
|
|
|
|
}
|
2008-06-03 02:11:07 -06:00
|
|
|
|
|
|
|
void __init
|
|
|
|
acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
|
|
|
|
{
|
|
|
|
}
|
2008-06-03 04:39:43 -06:00
|
|
|
|
|
|
|
void __init acpi_numa_arch_fixup(void)
|
|
|
|
{
|
|
|
|
}
|
2008-06-03 02:09:45 -06:00
|
|
|
#endif
|