diff options
Diffstat (limited to 'mm/allocpercpu.c')
| -rw-r--r-- | mm/allocpercpu.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c index dfdee6a47359..df34ceae0c67 100644 --- a/mm/allocpercpu.c +++ b/mm/allocpercpu.c | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | */ | 5 | */ |
| 6 | #include <linux/mm.h> | 6 | #include <linux/mm.h> |
| 7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 8 | #include <linux/bootmem.h> | ||
| 9 | #include <asm/sections.h> | ||
| 8 | 10 | ||
| 9 | #ifndef cache_line_size | 11 | #ifndef cache_line_size |
| 10 | #define cache_line_size() L1_CACHE_BYTES | 12 | #define cache_line_size() L1_CACHE_BYTES |
| @@ -147,3 +149,29 @@ void free_percpu(void *__pdata) | |||
| 147 | kfree(__percpu_disguise(__pdata)); | 149 | kfree(__percpu_disguise(__pdata)); |
| 148 | } | 150 | } |
| 149 | EXPORT_SYMBOL_GPL(free_percpu); | 151 | EXPORT_SYMBOL_GPL(free_percpu); |
| 152 | |||
| 153 | /* | ||
| 154 | * Generic percpu area setup. | ||
| 155 | */ | ||
| 156 | #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA | ||
| 157 | unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; | ||
| 158 | |||
| 159 | EXPORT_SYMBOL(__per_cpu_offset); | ||
| 160 | |||
| 161 | void __init setup_per_cpu_areas(void) | ||
| 162 | { | ||
| 163 | unsigned long size, i; | ||
| 164 | char *ptr; | ||
| 165 | unsigned long nr_possible_cpus = num_possible_cpus(); | ||
| 166 | |||
| 167 | /* Copy section for each CPU (we discard the original) */ | ||
| 168 | size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE); | ||
| 169 | ptr = alloc_bootmem_pages(size * nr_possible_cpus); | ||
| 170 | |||
| 171 | for_each_possible_cpu(i) { | ||
| 172 | __per_cpu_offset[i] = ptr - __per_cpu_start; | ||
| 173 | memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); | ||
| 174 | ptr += size; | ||
| 175 | } | ||
| 176 | } | ||
| 177 | #endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */ | ||
