diff options
Diffstat (limited to 'arch/i386/kernel/srat.c')
-rw-r--r-- | arch/i386/kernel/srat.c | 97 |
1 files changed, 2 insertions, 95 deletions
diff --git a/arch/i386/kernel/srat.c b/arch/i386/kernel/srat.c index 83db411b3aa7..32413122c4c2 100644 --- a/arch/i386/kernel/srat.c +++ b/arch/i386/kernel/srat.c | |||
@@ -54,8 +54,6 @@ struct node_memory_chunk_s { | |||
54 | static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS]; | 54 | static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS]; |
55 | 55 | ||
56 | static int num_memory_chunks; /* total number of memory chunks */ | 56 | static int num_memory_chunks; /* total number of memory chunks */ |
57 | static int zholes_size_init; | ||
58 | static unsigned long zholes_size[MAX_NUMNODES * MAX_NR_ZONES]; | ||
59 | 57 | ||
60 | extern void * boot_ioremap(unsigned long, unsigned long); | 58 | extern void * boot_ioremap(unsigned long, unsigned long); |
61 | 59 | ||
@@ -135,47 +133,6 @@ static void __init parse_memory_affinity_structure (char *sratp) | |||
135 | "enabled and removable" : "enabled" ) ); | 133 | "enabled and removable" : "enabled" ) ); |
136 | } | 134 | } |
137 | 135 | ||
138 | /* Take a chunk of pages from page frame cstart to cend and count the number | ||
139 | * of pages in each zone, returned via zones[]. | ||
140 | */ | ||
141 | static __init void chunk_to_zones(unsigned long cstart, unsigned long cend, | ||
142 | unsigned long *zones) | ||
143 | { | ||
144 | unsigned long max_dma; | ||
145 | extern unsigned long max_low_pfn; | ||
146 | |||
147 | int z; | ||
148 | unsigned long rend; | ||
149 | |||
150 | /* FIXME: MAX_DMA_ADDRESS and max_low_pfn are trying to provide | ||
151 | * similarly scoped information and should be handled in a consistant | ||
152 | * manner. | ||
153 | */ | ||
154 | max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; | ||
155 | |||
156 | /* Split the hole into the zones in which it falls. Repeatedly | ||
157 | * take the segment in which the remaining hole starts, round it | ||
158 | * to the end of that zone. | ||
159 | */ | ||
160 | memset(zones, 0, MAX_NR_ZONES * sizeof(long)); | ||
161 | while (cstart < cend) { | ||
162 | if (cstart < max_dma) { | ||
163 | z = ZONE_DMA; | ||
164 | rend = (cend < max_dma)? cend : max_dma; | ||
165 | |||
166 | } else if (cstart < max_low_pfn) { | ||
167 | z = ZONE_NORMAL; | ||
168 | rend = (cend < max_low_pfn)? cend : max_low_pfn; | ||
169 | |||
170 | } else { | ||
171 | z = ZONE_HIGHMEM; | ||
172 | rend = cend; | ||
173 | } | ||
174 | zones[z] += rend - cstart; | ||
175 | cstart = rend; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | /* | 136 | /* |
180 | * The SRAT table always lists ascending addresses, so can always | 137 | * The SRAT table always lists ascending addresses, so can always |
181 | * assume that the first "start" address that you see is the real | 138 | * assume that the first "start" address that you see is the real |
@@ -220,7 +177,6 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | |||
220 | 177 | ||
221 | memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */ | 178 | memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */ |
222 | memset(node_memory_chunk, 0, sizeof(node_memory_chunk)); | 179 | memset(node_memory_chunk, 0, sizeof(node_memory_chunk)); |
223 | memset(zholes_size, 0, sizeof(zholes_size)); | ||
224 | 180 | ||
225 | num_memory_chunks = 0; | 181 | num_memory_chunks = 0; |
226 | while (p < end) { | 182 | while (p < end) { |
@@ -284,6 +240,7 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp) | |||
284 | printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n", | 240 | printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n", |
285 | j, chunk->nid, chunk->start_pfn, chunk->end_pfn); | 241 | j, chunk->nid, chunk->start_pfn, chunk->end_pfn); |
286 | node_read_chunk(chunk->nid, chunk); | 242 | node_read_chunk(chunk->nid, chunk); |
243 | add_active_range(chunk->nid, chunk->start_pfn, chunk->end_pfn); | ||
287 | } | 244 | } |
288 | 245 | ||
289 | for_each_online_node(nid) { | 246 | for_each_online_node(nid) { |
@@ -392,57 +349,7 @@ int __init get_memcfg_from_srat(void) | |||
392 | return acpi20_parse_srat((struct acpi_table_srat *)header); | 349 | return acpi20_parse_srat((struct acpi_table_srat *)header); |
393 | } | 350 | } |
394 | out_err: | 351 | out_err: |
352 | remove_all_active_ranges(); | ||
395 | printk("failed to get NUMA memory information from SRAT table\n"); | 353 | printk("failed to get NUMA memory information from SRAT table\n"); |
396 | return 0; | 354 | return 0; |
397 | } | 355 | } |
398 | |||
399 | /* For each node run the memory list to determine whether there are | ||
400 | * any memory holes. For each hole determine which ZONE they fall | ||
401 | * into. | ||
402 | * | ||
403 | * NOTE#1: this requires knowledge of the zone boundries and so | ||
404 | * _cannot_ be performed before those are calculated in setup_memory. | ||
405 | * | ||
406 | * NOTE#2: we rely on the fact that the memory chunks are ordered by | ||
407 | * start pfn number during setup. | ||
408 | */ | ||
409 | static void __init get_zholes_init(void) | ||
410 | { | ||
411 | int nid; | ||
412 | int c; | ||
413 | int first; | ||
414 | unsigned long end = 0; | ||
415 | |||
416 | for_each_online_node(nid) { | ||
417 | first = 1; | ||
418 | for (c = 0; c < num_memory_chunks; c++){ | ||
419 | if (node_memory_chunk[c].nid == nid) { | ||
420 | if (first) { | ||
421 | end = node_memory_chunk[c].end_pfn; | ||
422 | first = 0; | ||
423 | |||
424 | } else { | ||
425 | /* Record any gap between this chunk | ||
426 | * and the previous chunk on this node | ||
427 | * against the zones it spans. | ||
428 | */ | ||
429 | chunk_to_zones(end, | ||
430 | node_memory_chunk[c].start_pfn, | ||
431 | &zholes_size[nid * MAX_NR_ZONES]); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | |||
438 | unsigned long * __init get_zholes_size(int nid) | ||
439 | { | ||
440 | if (!zholes_size_init) { | ||
441 | zholes_size_init++; | ||
442 | get_zholes_init(); | ||
443 | } | ||
444 | if (nid >= MAX_NUMNODES || !node_online(nid)) | ||
445 | printk("%s: nid = %d is invalid/offline. num_online_nodes = %d", | ||
446 | __FUNCTION__, nid, num_online_nodes()); | ||
447 | return &zholes_size[nid * MAX_NR_ZONES]; | ||
448 | } | ||