]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - arch/ia64/mm/numa.c
Pull model-name into release branch
[mirror_ubuntu-hirsute-kernel.git] / arch / ia64 / mm / numa.c
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 <efocht@ess.nec.de>
11 */
12
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>
18 #include <linux/bootmem.h>
19 #include <asm/mmzone.h>
20 #include <asm/numa.h>
21
22
23 /*
24 * The following structures are usually initialized by ACPI or
25 * similar mechanisms and describe the NUMA characteristics of the machine.
26 */
27 int num_node_memblks;
28 struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
29 struct node_cpuid_s node_cpuid[NR_CPUS];
30 /*
31 * This is a matrix with "distances" between nodes, they should be
32 * proportional to the memory access latency ratios.
33 */
34 u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
35
36 /* Identify which cnode a physical address resides on */
37 int
38 paddr_to_nid(unsigned long paddr)
39 {
40 int i;
41
42 for (i = 0; i < num_node_memblks; i++)
43 if (paddr >= node_memblk[i].start_paddr &&
44 paddr < node_memblk[i].start_paddr + node_memblk[i].size)
45 break;
46
47 return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0);
48 }
49
50 #if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA)
51 /*
52 * Because of holes evaluate on section limits.
53 * If the section of memory exists, then return the node where the section
54 * resides. Otherwise return node 0 as the default. This is used by
55 * SPARSEMEM to allocate the SPARSEMEM sectionmap on the NUMA node where
56 * the section resides.
57 */
58 int early_pfn_to_nid(unsigned long pfn)
59 {
60 int i, section = pfn >> PFN_SECTION_SHIFT, ssec, esec;
61
62 for (i = 0; i < num_node_memblks; i++) {
63 ssec = node_memblk[i].start_paddr >> PA_SECTION_SHIFT;
64 esec = (node_memblk[i].start_paddr + node_memblk[i].size +
65 ((1L << PA_SECTION_SHIFT) - 1)) >> PA_SECTION_SHIFT;
66 if (section >= ssec && section < esec)
67 return node_memblk[i].nid;
68 }
69
70 return 0;
71 }
72 #endif