diff options
author | Zhen Lei <thunder.leizhen@huawei.com> | 2016-09-01 02:55:00 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2016-09-09 09:59:09 -0400 |
commit | 7af3a0a992524ffddc342cd1481cc4dcb3f1da71 (patch) | |
tree | 0fe00c78d4f47e6b2c3ddd15cd25413fd51695ee /arch/arm64/mm | |
parent | f11c7bacd5941fcfc5e9dd3bb0362e8a2eec4722 (diff) |
arm64/numa: support HAVE_SETUP_PER_CPU_AREA
To make each percpu area allocated from its local numa node. Without this
patch, all percpu areas will be allocated from the node which cpu0 belongs
to.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/mm')
-rw-r--r-- | arch/arm64/mm/numa.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c index 0e75b537de0c..087064d5dcc1 100644 --- a/arch/arm64/mm/numa.c +++ b/arch/arm64/mm/numa.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/of.h> | 26 | #include <linux/of.h> |
27 | 27 | ||
28 | #include <asm/acpi.h> | 28 | #include <asm/acpi.h> |
29 | #include <asm/sections.h> | ||
29 | 30 | ||
30 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; | 31 | struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; |
31 | EXPORT_SYMBOL(node_data); | 32 | EXPORT_SYMBOL(node_data); |
@@ -131,6 +132,57 @@ void __init early_map_cpu_to_node(unsigned int cpu, int nid) | |||
131 | cpu_to_node_map[cpu] = nid; | 132 | cpu_to_node_map[cpu] = nid; |
132 | } | 133 | } |
133 | 134 | ||
135 | #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA | ||
136 | unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; | ||
137 | EXPORT_SYMBOL(__per_cpu_offset); | ||
138 | |||
139 | static int __init early_cpu_to_node(int cpu) | ||
140 | { | ||
141 | return cpu_to_node_map[cpu]; | ||
142 | } | ||
143 | |||
144 | static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) | ||
145 | { | ||
146 | return node_distance(from, to); | ||
147 | } | ||
148 | |||
149 | static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, | ||
150 | size_t align) | ||
151 | { | ||
152 | int nid = early_cpu_to_node(cpu); | ||
153 | |||
154 | return memblock_virt_alloc_try_nid(size, align, | ||
155 | __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); | ||
156 | } | ||
157 | |||
158 | static void __init pcpu_fc_free(void *ptr, size_t size) | ||
159 | { | ||
160 | memblock_free_early(__pa(ptr), size); | ||
161 | } | ||
162 | |||
163 | void __init setup_per_cpu_areas(void) | ||
164 | { | ||
165 | unsigned long delta; | ||
166 | unsigned int cpu; | ||
167 | int rc; | ||
168 | |||
169 | /* | ||
170 | * Always reserve area for module percpu variables. That's | ||
171 | * what the legacy allocator did. | ||
172 | */ | ||
173 | rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE, | ||
174 | PERCPU_DYNAMIC_RESERVE, PAGE_SIZE, | ||
175 | pcpu_cpu_distance, | ||
176 | pcpu_fc_alloc, pcpu_fc_free); | ||
177 | if (rc < 0) | ||
178 | panic("Failed to initialize percpu areas."); | ||
179 | |||
180 | delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start; | ||
181 | for_each_possible_cpu(cpu) | ||
182 | __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu]; | ||
183 | } | ||
184 | #endif | ||
185 | |||
134 | /** | 186 | /** |
135 | * numa_add_memblk - Set node id to memblk | 187 | * numa_add_memblk - Set node id to memblk |
136 | * @nid: NUMA node ID of the new memblk | 188 | * @nid: NUMA node ID of the new memblk |