diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 20:31:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-22 20:31:36 -0400 |
| commit | 0fc0531e0a2174377a86fd6953ecaa00287d8f70 (patch) | |
| tree | afe56978729300df96b002a064c9de927fadcfab /include | |
| parent | 91b745016c12d440386c40fb76ab69c8e08cbc06 (diff) | |
| parent | 9329ba9704f6bd51a735982e0d4a3eed72c3294f (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: update comments to reflect that percpu allocations are always zero-filled
percpu: Optimize __get_cpu_var()
x86, percpu: Optimize this_cpu_ptr
percpu: clear memory allocated with the km allocator
percpu: fix build breakage on s390 and cleanup build configuration tests
percpu: use percpu allocator on UP too
percpu: reduce PCPU_MIN_UNIT_SIZE to 32k
vmalloc: pcpu_get/free_vm_areas() aren't needed on UP
Fixed up trivial conflicts in include/linux/percpu.h
Diffstat (limited to 'include')
| -rw-r--r-- | include/asm-generic/percpu.h | 14 | ||||
| -rw-r--r-- | include/linux/percpu.h | 31 | ||||
| -rw-r--r-- | include/linux/vmalloc.h | 2 |
3 files changed, 17 insertions, 30 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 08923b684768..d17784ea37ff 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h | |||
| @@ -55,14 +55,18 @@ extern unsigned long __per_cpu_offset[NR_CPUS]; | |||
| 55 | */ | 55 | */ |
| 56 | #define per_cpu(var, cpu) \ | 56 | #define per_cpu(var, cpu) \ |
| 57 | (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) | 57 | (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) |
| 58 | #define __get_cpu_var(var) \ | ||
| 59 | (*SHIFT_PERCPU_PTR(&(var), my_cpu_offset)) | ||
| 60 | #define __raw_get_cpu_var(var) \ | ||
| 61 | (*SHIFT_PERCPU_PTR(&(var), __my_cpu_offset)) | ||
| 62 | 58 | ||
| 63 | #define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset) | 59 | #ifndef __this_cpu_ptr |
| 64 | #define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) | 60 | #define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) |
| 61 | #endif | ||
| 62 | #ifdef CONFIG_DEBUG_PREEMPT | ||
| 63 | #define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset) | ||
| 64 | #else | ||
| 65 | #define this_cpu_ptr(ptr) __this_cpu_ptr(ptr) | ||
| 66 | #endif | ||
| 65 | 67 | ||
| 68 | #define __get_cpu_var(var) (*this_cpu_ptr(&(var))) | ||
| 69 | #define __raw_get_cpu_var(var) (*__this_cpu_ptr(&(var))) | ||
| 66 | 70 | ||
| 67 | #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA | 71 | #ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA |
| 68 | extern void setup_per_cpu_areas(void); | 72 | extern void setup_per_cpu_areas(void); |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 0eb50832aa00..5095b834a6fb 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
| @@ -48,10 +48,8 @@ | |||
| 48 | preempt_enable(); \ | 48 | preempt_enable(); \ |
| 49 | } while (0) | 49 | } while (0) |
| 50 | 50 | ||
| 51 | #ifdef CONFIG_SMP | ||
| 52 | |||
| 53 | /* minimum unit size, also is the maximum supported allocation size */ | 51 | /* minimum unit size, also is the maximum supported allocation size */ |
| 54 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) | 52 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10) |
| 55 | 53 | ||
| 56 | /* | 54 | /* |
| 57 | * Percpu allocator can serve percpu allocations before slab is | 55 | * Percpu allocator can serve percpu allocations before slab is |
| @@ -146,37 +144,20 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size, | |||
| 146 | * dynamically allocated. Non-atomic access to the current CPU's | 144 | * dynamically allocated. Non-atomic access to the current CPU's |
| 147 | * version should probably be combined with get_cpu()/put_cpu(). | 145 | * version should probably be combined with get_cpu()/put_cpu(). |
| 148 | */ | 146 | */ |
| 147 | #ifdef CONFIG_SMP | ||
| 149 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) | 148 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) |
| 149 | #else | ||
| 150 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); }) | ||
| 151 | #endif | ||
| 150 | 152 | ||
| 151 | extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); | 153 | extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); |
| 152 | extern bool is_kernel_percpu_address(unsigned long addr); | 154 | extern bool is_kernel_percpu_address(unsigned long addr); |
| 153 | 155 | ||
| 154 | #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA | 156 | #if !defined(CONFIG_SMP) || !defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) |
| 155 | extern void __init setup_per_cpu_areas(void); | 157 | extern void __init setup_per_cpu_areas(void); |
| 156 | #endif | 158 | #endif |
| 157 | extern void __init percpu_init_late(void); | 159 | extern void __init percpu_init_late(void); |
| 158 | 160 | ||
| 159 | #else /* CONFIG_SMP */ | ||
| 160 | |||
| 161 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); }) | ||
| 162 | |||
| 163 | /* can't distinguish from other static vars, always false */ | ||
| 164 | static inline bool is_kernel_percpu_address(unsigned long addr) | ||
| 165 | { | ||
| 166 | return false; | ||
| 167 | } | ||
| 168 | |||
| 169 | static inline void __init setup_per_cpu_areas(void) { } | ||
| 170 | |||
| 171 | static inline void __init percpu_init_late(void) { } | ||
| 172 | |||
| 173 | static inline void *pcpu_lpage_remapped(void *kaddr) | ||
| 174 | { | ||
| 175 | return NULL; | ||
| 176 | } | ||
| 177 | |||
| 178 | #endif /* CONFIG_SMP */ | ||
| 179 | |||
| 180 | extern void __percpu *__alloc_percpu(size_t size, size_t align); | 161 | extern void __percpu *__alloc_percpu(size_t size, size_t align); |
| 181 | extern void free_percpu(void __percpu *__pdata); | 162 | extern void free_percpu(void __percpu *__pdata); |
| 182 | extern phys_addr_t per_cpu_ptr_to_phys(void *addr); | 163 | extern phys_addr_t per_cpu_ptr_to_phys(void *addr); |
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 01c2145118dc..63a4fe6d51bd 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h | |||
| @@ -117,10 +117,12 @@ extern rwlock_t vmlist_lock; | |||
| 117 | extern struct vm_struct *vmlist; | 117 | extern struct vm_struct *vmlist; |
| 118 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); | 118 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); |
| 119 | 119 | ||
| 120 | #ifdef CONFIG_SMP | ||
| 120 | struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, | 121 | struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, |
| 121 | const size_t *sizes, int nr_vms, | 122 | const size_t *sizes, int nr_vms, |
| 122 | size_t align, gfp_t gfp_mask); | 123 | size_t align, gfp_t gfp_mask); |
| 123 | 124 | ||
| 124 | void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms); | 125 | void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms); |
| 126 | #endif | ||
| 125 | 127 | ||
| 126 | #endif /* _LINUX_VMALLOC_H */ | 128 | #endif /* _LINUX_VMALLOC_H */ |
