This source file includes following definitions.
- __node_distance
- paddr_to_nid
- __early_pfn_to_nid
- numa_clear_node
- memory_add_physaddr_to_nid
1
2
3
4
5
6
7
8
9
10
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/memblock.h>
19 #include <linux/module.h>
20 #include <asm/mmzone.h>
21 #include <asm/numa.h>
22
23
24
25
26
27
28 int num_node_memblks;
29 struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
30 struct node_cpuid_s node_cpuid[NR_CPUS] =
31 { [0 ... NR_CPUS-1] = { .phys_id = 0, .nid = NUMA_NO_NODE } };
32
33
34
35
36
37 u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
38
39 int __node_distance(int from, int to)
40 {
41 return slit_distance(from, to);
42 }
43 EXPORT_SYMBOL(__node_distance);
44
45
46 int
47 paddr_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 }
58 EXPORT_SYMBOL(paddr_to_nid);
59
60 #if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA)
61
62
63
64
65
66
67
68 int __meminit __early_pfn_to_nid(unsigned long pfn,
69 struct mminit_pfnnid_cache *state)
70 {
71 int i, section = pfn >> PFN_SECTION_SHIFT, ssec, esec;
72
73 if (section >= state->last_start && section < state->last_end)
74 return state->last_nid;
75
76 for (i = 0; i < num_node_memblks; i++) {
77 ssec = node_memblk[i].start_paddr >> PA_SECTION_SHIFT;
78 esec = (node_memblk[i].start_paddr + node_memblk[i].size +
79 ((1L << PA_SECTION_SHIFT) - 1)) >> PA_SECTION_SHIFT;
80 if (section >= ssec && section < esec) {
81 state->last_start = ssec;
82 state->last_end = esec;
83 state->last_nid = node_memblk[i].nid;
84 return node_memblk[i].nid;
85 }
86 }
87
88 return -1;
89 }
90
91 void numa_clear_node(int cpu)
92 {
93 unmap_cpu_from_node(cpu, NUMA_NO_NODE);
94 }
95
96 #ifdef CONFIG_MEMORY_HOTPLUG
97
98
99
100
101
102 int memory_add_physaddr_to_nid(u64 addr)
103 {
104 int nid = paddr_to_nid(addr);
105 if (nid < 0)
106 return 0;
107 return nid;
108 }
109
110 EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
111 #endif
112 #endif