diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-18 22:41:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-18 22:41:05 -0400 |
commit | 77f312a96dd1e01c49ccd872265e70a8346b53cc (patch) | |
tree | 7e6d1114dfaf0eb4732c97ad18819f23e4ebef09 /mm | |
parent | dc8ed71eeb8adce08d3070f4130e12ee540baa59 (diff) | |
parent | 142d44b0dd6741a64a7bdbe029110e7c1dcf1d23 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
percpu: use the right flag for get_vm_area()
percpu, sparc64: fix sparse possible cpu map handling
init: set nr_cpu_ids before setup_per_cpu_areas()
Diffstat (limited to 'mm')
-rw-r--r-- | mm/percpu.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/mm/percpu.c b/mm/percpu.c index b70f2acd8853..5fe37842e0ea 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
@@ -8,12 +8,12 @@ | |||
8 | * | 8 | * |
9 | * This is percpu allocator which can handle both static and dynamic | 9 | * This is percpu allocator which can handle both static and dynamic |
10 | * areas. Percpu areas are allocated in chunks in vmalloc area. Each | 10 | * areas. Percpu areas are allocated in chunks in vmalloc area. Each |
11 | * chunk is consisted of num_possible_cpus() units and the first chunk | 11 | * chunk is consisted of nr_cpu_ids units and the first chunk is used |
12 | * is used for static percpu variables in the kernel image (special | 12 | * for static percpu variables in the kernel image (special boot time |
13 | * boot time alloc/init handling necessary as these areas need to be | 13 | * alloc/init handling necessary as these areas need to be brought up |
14 | * brought up before allocation services are running). Unit grows as | 14 | * before allocation services are running). Unit grows as necessary |
15 | * necessary and all units grow or shrink in unison. When a chunk is | 15 | * and all units grow or shrink in unison. When a chunk is filled up, |
16 | * filled up, another chunk is allocated. ie. in vmalloc area | 16 | * another chunk is allocated. ie. in vmalloc area |
17 | * | 17 | * |
18 | * c0 c1 c2 | 18 | * c0 c1 c2 |
19 | * ------------------- ------------------- ------------ | 19 | * ------------------- ------------------- ------------ |
@@ -558,7 +558,7 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme) | |||
558 | static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end, | 558 | static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end, |
559 | bool flush_tlb) | 559 | bool flush_tlb) |
560 | { | 560 | { |
561 | unsigned int last = num_possible_cpus() - 1; | 561 | unsigned int last = nr_cpu_ids - 1; |
562 | unsigned int cpu; | 562 | unsigned int cpu; |
563 | 563 | ||
564 | /* unmap must not be done on immutable chunk */ | 564 | /* unmap must not be done on immutable chunk */ |
@@ -643,7 +643,7 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size, | |||
643 | */ | 643 | */ |
644 | static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end) | 644 | static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end) |
645 | { | 645 | { |
646 | unsigned int last = num_possible_cpus() - 1; | 646 | unsigned int last = nr_cpu_ids - 1; |
647 | unsigned int cpu; | 647 | unsigned int cpu; |
648 | int err; | 648 | int err; |
649 | 649 | ||
@@ -749,7 +749,7 @@ static struct pcpu_chunk *alloc_pcpu_chunk(void) | |||
749 | chunk->map[chunk->map_used++] = pcpu_unit_size; | 749 | chunk->map[chunk->map_used++] = pcpu_unit_size; |
750 | chunk->page = chunk->page_ar; | 750 | chunk->page = chunk->page_ar; |
751 | 751 | ||
752 | chunk->vm = get_vm_area(pcpu_chunk_size, GFP_KERNEL); | 752 | chunk->vm = get_vm_area(pcpu_chunk_size, VM_ALLOC); |
753 | if (!chunk->vm) { | 753 | if (!chunk->vm) { |
754 | free_pcpu_chunk(chunk); | 754 | free_pcpu_chunk(chunk); |
755 | return NULL; | 755 | return NULL; |
@@ -1067,9 +1067,9 @@ size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn, | |||
1067 | PFN_UP(size_sum)); | 1067 | PFN_UP(size_sum)); |
1068 | 1068 | ||
1069 | pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT; | 1069 | pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT; |
1070 | pcpu_chunk_size = num_possible_cpus() * pcpu_unit_size; | 1070 | pcpu_chunk_size = nr_cpu_ids * pcpu_unit_size; |
1071 | pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) | 1071 | pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) |
1072 | + num_possible_cpus() * pcpu_unit_pages * sizeof(struct page *); | 1072 | + nr_cpu_ids * pcpu_unit_pages * sizeof(struct page *); |
1073 | 1073 | ||
1074 | if (dyn_size < 0) | 1074 | if (dyn_size < 0) |
1075 | dyn_size = pcpu_unit_size - static_size - reserved_size; | 1075 | dyn_size = pcpu_unit_size - static_size - reserved_size; |
@@ -1248,7 +1248,7 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size, | |||
1248 | } else | 1248 | } else |
1249 | pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE); | 1249 | pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE); |
1250 | 1250 | ||
1251 | chunk_size = pcpue_unit_size * num_possible_cpus(); | 1251 | chunk_size = pcpue_unit_size * nr_cpu_ids; |
1252 | 1252 | ||
1253 | pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE, | 1253 | pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE, |
1254 | __pa(MAX_DMA_ADDRESS)); | 1254 | __pa(MAX_DMA_ADDRESS)); |
@@ -1259,12 +1259,15 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size, | |||
1259 | } | 1259 | } |
1260 | 1260 | ||
1261 | /* return the leftover and copy */ | 1261 | /* return the leftover and copy */ |
1262 | for_each_possible_cpu(cpu) { | 1262 | for (cpu = 0; cpu < nr_cpu_ids; cpu++) { |
1263 | void *ptr = pcpue_ptr + cpu * pcpue_unit_size; | 1263 | void *ptr = pcpue_ptr + cpu * pcpue_unit_size; |
1264 | 1264 | ||
1265 | free_bootmem(__pa(ptr + pcpue_size), | 1265 | if (cpu_possible(cpu)) { |
1266 | pcpue_unit_size - pcpue_size); | 1266 | free_bootmem(__pa(ptr + pcpue_size), |
1267 | memcpy(ptr, __per_cpu_load, static_size); | 1267 | pcpue_unit_size - pcpue_size); |
1268 | memcpy(ptr, __per_cpu_load, static_size); | ||
1269 | } else | ||
1270 | free_bootmem(__pa(ptr), pcpue_unit_size); | ||
1268 | } | 1271 | } |
1269 | 1272 | ||
1270 | /* we're ready, commit */ | 1273 | /* we're ready, commit */ |