]> Git Repo - linux.git/blame - arch/ia64/mm/numa.c
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / arch / ia64 / mm / numa.c
CommitLineData
1da177e4
LT
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * This file contains NUMA specific variables and functions which can
7 * be split away from DISCONTIGMEM and are used on NUMA machines with
8 * contiguous memory.
9 *
10 * 2002/08/07 Erich Focht <[email protected]>
11 */
12
1da177e4
LT
13#include <linux/cpu.h>
14#include <linux/kernel.h>
15#include <linux/mm.h>
16#include <linux/node.h>
17#include <linux/init.h>
57c8a661 18#include <linux/memblock.h>
8c2676a5 19#include <linux/module.h>
1da177e4
LT
20#include <asm/mmzone.h>
21#include <asm/numa.h>
22
23
24/*
25 * The following structures are usually initialized by ACPI or
26 * similar mechanisms and describe the NUMA characteristics of the machine.
27 */
28int num_node_memblks;
29struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
2c6e6db4 30struct node_cpuid_s node_cpuid[NR_CPUS] =
31 { [0 ... NR_CPUS-1] = { .phys_id = 0, .nid = NUMA_NO_NODE } };
32
1da177e4
LT
33/*
34 * This is a matrix with "distances" between nodes, they should be
35 * proportional to the memory access latency ratios.
36 */
37u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
38
ef78e5ec
MB
39int __node_distance(int from, int to)
40{
41 return slit_distance(from, to);
42}
43EXPORT_SYMBOL(__node_distance);
44
1da177e4
LT
45/* Identify which cnode a physical address resides on */
46int
47paddr_to_nid(unsigned long paddr)
48{
49 int i;
50
51 for (i = 0; i < num_node_memblks; i++)
52 if (paddr >= node_memblk[i].start_paddr &&
53 paddr < node_memblk[i].start_paddr + node_memblk[i].size)
54 break;
55
56 return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0);
57}
2d4b1fa2
BP
58
59#if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA)
60/*
61 * Because of holes evaluate on section limits.
62 * If the section of memory exists, then return the node where the section
63 * resides. Otherwise return node 0 as the default. This is used by
64 * SPARSEMEM to allocate the SPARSEMEM sectionmap on the NUMA node where
65 * the section resides.
66 */
8a942fde
MG
67int __meminit __early_pfn_to_nid(unsigned long pfn,
68 struct mminit_pfnnid_cache *state)
2d4b1fa2
BP
69{
70 int i, section = pfn >> PFN_SECTION_SHIFT, ssec, esec;
7c243c71 71
8a942fde
MG
72 if (section >= state->last_start && section < state->last_end)
73 return state->last_nid;
2d4b1fa2
BP
74
75 for (i = 0; i < num_node_memblks; i++) {
76 ssec = node_memblk[i].start_paddr >> PA_SECTION_SHIFT;
77 esec = (node_memblk[i].start_paddr + node_memblk[i].size +
78 ((1L << PA_SECTION_SHIFT) - 1)) >> PA_SECTION_SHIFT;
7c243c71 79 if (section >= ssec && section < esec) {
8a942fde
MG
80 state->last_start = ssec;
81 state->last_end = esec;
82 state->last_nid = node_memblk[i].nid;
2d4b1fa2 83 return node_memblk[i].nid;
7c243c71 84 }
2d4b1fa2
BP
85 }
86
cc2559bc 87 return -1;
2d4b1fa2 88}
8c2676a5 89
ccce9bb8 90void numa_clear_node(int cpu)
eee46b3d
YW
91{
92 unmap_cpu_from_node(cpu, NUMA_NO_NODE);
93}
94
8c2676a5
KM
95#ifdef CONFIG_MEMORY_HOTPLUG
96/*
97 * SRAT information is stored in node_memblk[], then we can use SRAT
98 * information at memory-hot-add if necessary.
99 */
100
101int memory_add_physaddr_to_nid(u64 addr)
102{
103 int nid = paddr_to_nid(addr);
104 if (nid < 0)
105 return 0;
106 return nid;
107}
108
109EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
110#endif
2d4b1fa2 111#endif
This page took 0.770918 seconds and 4 git commands to generate.