diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-15 12:39:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-15 12:39:44 -0400 |
commit | ada3fa15057205b7d3f727bba5cd26b5912e350f (patch) | |
tree | 60962fc9e4021b92f484d1a58e72cd3906d4f3db /include | |
parent | 2f82af08fcc7dc01a7e98a49a5995a77e32a2925 (diff) | |
parent | 5579fd7e6aed8860ea0c8e3f11897493153b10ad (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: (46 commits)
powerpc64: convert to dynamic percpu allocator
sparc64: use embedding percpu first chunk allocator
percpu: kill lpage first chunk allocator
x86,percpu: use embedding for 64bit NUMA and page for 32bit NUMA
percpu: update embedding first chunk allocator to handle sparse units
percpu: use group information to allocate vmap areas sparsely
vmalloc: implement pcpu_get_vm_areas()
vmalloc: separate out insert_vmalloc_vm()
percpu: add chunk->base_addr
percpu: add pcpu_unit_offsets[]
percpu: introduce pcpu_alloc_info and pcpu_group_info
percpu: move pcpu_lpage_build_unit_map() and pcpul_lpage_dump_cfg() upward
percpu: add @align to pcpu_fc_alloc_fn_t
percpu: make @dyn_size mandatory for pcpu_setup_first_chunk()
percpu: drop @static_size from first chunk allocators
percpu: generalize first chunk allocator selection
percpu: build first chunk allocators selectively
percpu: rename 4k first chunk allocator to page
percpu: improve boot messages
percpu: fix pcpu_reclaim() locking
...
Fix trivial conflict as by Tejun Heo in kernel/sched.c
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 24 | ||||
-rw-r--r-- | include/linux/percpu-defs.h | 66 | ||||
-rw-r--r-- | include/linux/percpu.h | 88 | ||||
-rw-r--r-- | include/linux/vmalloc.h | 6 |
4 files changed, 157 insertions, 27 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 6ad76bf5fb40..a43223af98b6 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -33,13 +33,10 @@ | |||
33 | * BSS_SECTION(0, 0, 0) | 33 | * BSS_SECTION(0, 0, 0) |
34 | * _end = .; | 34 | * _end = .; |
35 | * | 35 | * |
36 | * /DISCARD/ : { | ||
37 | * EXIT_TEXT | ||
38 | * EXIT_DATA | ||
39 | * EXIT_CALL | ||
40 | * } | ||
41 | * STABS_DEBUG | 36 | * STABS_DEBUG |
42 | * DWARF_DEBUG | 37 | * DWARF_DEBUG |
38 | * | ||
39 | * DISCARDS // must be the last | ||
43 | * } | 40 | * } |
44 | * | 41 | * |
45 | * [__init_begin, __init_end] is the init section that may be freed after init | 42 | * [__init_begin, __init_end] is the init section that may be freed after init |
@@ -626,6 +623,23 @@ | |||
626 | #define INIT_RAM_FS | 623 | #define INIT_RAM_FS |
627 | #endif | 624 | #endif |
628 | 625 | ||
626 | /* | ||
627 | * Default discarded sections. | ||
628 | * | ||
629 | * Some archs want to discard exit text/data at runtime rather than | ||
630 | * link time due to cross-section references such as alt instructions, | ||
631 | * bug table, eh_frame, etc. DISCARDS must be the last of output | ||
632 | * section definitions so that such archs put those in earlier section | ||
633 | * definitions. | ||
634 | */ | ||
635 | #define DISCARDS \ | ||
636 | /DISCARD/ : { \ | ||
637 | EXIT_TEXT \ | ||
638 | EXIT_DATA \ | ||
639 | EXIT_CALL \ | ||
640 | *(.discard) \ | ||
641 | } | ||
642 | |||
629 | /** | 643 | /** |
630 | * PERCPU_VADDR - define output section for percpu area | 644 | * PERCPU_VADDR - define output section for percpu area |
631 | * @vaddr: explicit base address (optional) | 645 | * @vaddr: explicit base address (optional) |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 0761491b3eec..9bd03193ecd4 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
@@ -10,22 +10,70 @@ | |||
10 | /* | 10 | /* |
11 | * Base implementations of per-CPU variable declarations and definitions, where | 11 | * Base implementations of per-CPU variable declarations and definitions, where |
12 | * the section in which the variable is to be placed is provided by the | 12 | * the section in which the variable is to be placed is provided by the |
13 | * 'section' argument. This may be used to affect the parameters governing the | 13 | * 'sec' argument. This may be used to affect the parameters governing the |
14 | * variable's storage. | 14 | * variable's storage. |
15 | * | 15 | * |
16 | * NOTE! The sections for the DECLARE and for the DEFINE must match, lest | 16 | * NOTE! The sections for the DECLARE and for the DEFINE must match, lest |
17 | * linkage errors occur due the compiler generating the wrong code to access | 17 | * linkage errors occur due the compiler generating the wrong code to access |
18 | * that section. | 18 | * that section. |
19 | */ | 19 | */ |
20 | #define DECLARE_PER_CPU_SECTION(type, name, section) \ | 20 | #define __PCPU_ATTRS(sec) \ |
21 | extern \ | 21 | __attribute__((section(PER_CPU_BASE_SECTION sec))) \ |
22 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | 22 | PER_CPU_ATTRIBUTES |
23 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | 23 | |
24 | 24 | #define __PCPU_DUMMY_ATTRS \ | |
25 | #define DEFINE_PER_CPU_SECTION(type, name, section) \ | 25 | __attribute__((section(".discard"), unused)) |
26 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ | 26 | |
27 | PER_CPU_ATTRIBUTES PER_CPU_DEF_ATTRIBUTES \ | 27 | /* |
28 | * s390 and alpha modules require percpu variables to be defined as | ||
29 | * weak to force the compiler to generate GOT based external | ||
30 | * references for them. This is necessary because percpu sections | ||
31 | * will be located outside of the usually addressable area. | ||
32 | * | ||
33 | * This definition puts the following two extra restrictions when | ||
34 | * defining percpu variables. | ||
35 | * | ||
36 | * 1. The symbol must be globally unique, even the static ones. | ||
37 | * 2. Static percpu variables cannot be defined inside a function. | ||
38 | * | ||
39 | * Archs which need weak percpu definitions should define | ||
40 | * ARCH_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary. | ||
41 | * | ||
42 | * To ensure that the generic code observes the above two | ||
43 | * restrictions, if CONFIG_DEBUG_FORCE_WEAK_PER_CPU is set weak | ||
44 | * definition is used for all cases. | ||
45 | */ | ||
46 | #if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PER_CPU) | ||
47 | /* | ||
48 | * __pcpu_scope_* dummy variable is used to enforce scope. It | ||
49 | * receives the static modifier when it's used in front of | ||
50 | * DEFINE_PER_CPU() and will trigger build failure if | ||
51 | * DECLARE_PER_CPU() is used for the same variable. | ||
52 | * | ||
53 | * __pcpu_unique_* dummy variable is used to enforce symbol uniqueness | ||
54 | * such that hidden weak symbol collision, which will cause unrelated | ||
55 | * variables to share the same address, can be detected during build. | ||
56 | */ | ||
57 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | ||
58 | extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | ||
59 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | ||
60 | |||
61 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | ||
62 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | ||
63 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | ||
64 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ | ||
65 | __typeof__(type) per_cpu__##name | ||
66 | #else | ||
67 | /* | ||
68 | * Normal declaration and definition macros. | ||
69 | */ | ||
70 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | ||
71 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | ||
72 | |||
73 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | ||
74 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ | ||
28 | __typeof__(type) per_cpu__##name | 75 | __typeof__(type) per_cpu__##name |
76 | #endif | ||
29 | 77 | ||
30 | /* | 78 | /* |
31 | * Variant on the per-CPU variable declaration/definition theme used for | 79 | * Variant on the per-CPU variable declaration/definition theme used for |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 26fd9d12f050..878836ca999c 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | #ifdef CONFIG_SMP | 35 | #ifdef CONFIG_SMP |
36 | 36 | ||
37 | #ifdef CONFIG_HAVE_DYNAMIC_PER_CPU_AREA | 37 | #ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA |
38 | 38 | ||
39 | /* minimum unit size, also is the maximum supported allocation size */ | 39 | /* minimum unit size, also is the maximum supported allocation size */ |
40 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) | 40 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) |
@@ -57,19 +57,70 @@ | |||
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | extern void *pcpu_base_addr; | 59 | extern void *pcpu_base_addr; |
60 | extern const unsigned long *pcpu_unit_offsets; | ||
60 | 61 | ||
61 | typedef struct page * (*pcpu_get_page_fn_t)(unsigned int cpu, int pageno); | 62 | struct pcpu_group_info { |
62 | typedef void (*pcpu_populate_pte_fn_t)(unsigned long addr); | 63 | int nr_units; /* aligned # of units */ |
64 | unsigned long base_offset; /* base address offset */ | ||
65 | unsigned int *cpu_map; /* unit->cpu map, empty | ||
66 | * entries contain NR_CPUS */ | ||
67 | }; | ||
68 | |||
69 | struct pcpu_alloc_info { | ||
70 | size_t static_size; | ||
71 | size_t reserved_size; | ||
72 | size_t dyn_size; | ||
73 | size_t unit_size; | ||
74 | size_t atom_size; | ||
75 | size_t alloc_size; | ||
76 | size_t __ai_size; /* internal, don't use */ | ||
77 | int nr_groups; /* 0 if grouping unnecessary */ | ||
78 | struct pcpu_group_info groups[]; | ||
79 | }; | ||
63 | 80 | ||
64 | extern size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn, | 81 | enum pcpu_fc { |
65 | size_t static_size, size_t reserved_size, | 82 | PCPU_FC_AUTO, |
66 | ssize_t dyn_size, ssize_t unit_size, | 83 | PCPU_FC_EMBED, |
67 | void *base_addr, | 84 | PCPU_FC_PAGE, |
68 | pcpu_populate_pte_fn_t populate_pte_fn); | ||
69 | 85 | ||
70 | extern ssize_t __init pcpu_embed_first_chunk( | 86 | PCPU_FC_NR, |
71 | size_t static_size, size_t reserved_size, | 87 | }; |
72 | ssize_t dyn_size, ssize_t unit_size); | 88 | extern const char *pcpu_fc_names[PCPU_FC_NR]; |
89 | |||
90 | extern enum pcpu_fc pcpu_chosen_fc; | ||
91 | |||
92 | typedef void * (*pcpu_fc_alloc_fn_t)(unsigned int cpu, size_t size, | ||
93 | size_t align); | ||
94 | typedef void (*pcpu_fc_free_fn_t)(void *ptr, size_t size); | ||
95 | typedef void (*pcpu_fc_populate_pte_fn_t)(unsigned long addr); | ||
96 | typedef int (pcpu_fc_cpu_distance_fn_t)(unsigned int from, unsigned int to); | ||
97 | |||
98 | extern struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, | ||
99 | int nr_units); | ||
100 | extern void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai); | ||
101 | |||
102 | extern struct pcpu_alloc_info * __init pcpu_build_alloc_info( | ||
103 | size_t reserved_size, ssize_t dyn_size, | ||
104 | size_t atom_size, | ||
105 | pcpu_fc_cpu_distance_fn_t cpu_distance_fn); | ||
106 | |||
107 | extern int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, | ||
108 | void *base_addr); | ||
109 | |||
110 | #ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK | ||
111 | extern int __init pcpu_embed_first_chunk(size_t reserved_size, ssize_t dyn_size, | ||
112 | size_t atom_size, | ||
113 | pcpu_fc_cpu_distance_fn_t cpu_distance_fn, | ||
114 | pcpu_fc_alloc_fn_t alloc_fn, | ||
115 | pcpu_fc_free_fn_t free_fn); | ||
116 | #endif | ||
117 | |||
118 | #ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK | ||
119 | extern int __init pcpu_page_first_chunk(size_t reserved_size, | ||
120 | pcpu_fc_alloc_fn_t alloc_fn, | ||
121 | pcpu_fc_free_fn_t free_fn, | ||
122 | pcpu_fc_populate_pte_fn_t populate_pte_fn); | ||
123 | #endif | ||
73 | 124 | ||
74 | /* | 125 | /* |
75 | * Use this to get to a cpu's version of the per-cpu object | 126 | * Use this to get to a cpu's version of the per-cpu object |
@@ -80,7 +131,7 @@ extern ssize_t __init pcpu_embed_first_chunk( | |||
80 | 131 | ||
81 | extern void *__alloc_reserved_percpu(size_t size, size_t align); | 132 | extern void *__alloc_reserved_percpu(size_t size, size_t align); |
82 | 133 | ||
83 | #else /* CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ | 134 | #else /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */ |
84 | 135 | ||
85 | struct percpu_data { | 136 | struct percpu_data { |
86 | void *ptrs[1]; | 137 | void *ptrs[1]; |
@@ -99,11 +150,15 @@ struct percpu_data { | |||
99 | (__typeof__(ptr))__p->ptrs[(cpu)]; \ | 150 | (__typeof__(ptr))__p->ptrs[(cpu)]; \ |
100 | }) | 151 | }) |
101 | 152 | ||
102 | #endif /* CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ | 153 | #endif /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */ |
103 | 154 | ||
104 | extern void *__alloc_percpu(size_t size, size_t align); | 155 | extern void *__alloc_percpu(size_t size, size_t align); |
105 | extern void free_percpu(void *__pdata); | 156 | extern void free_percpu(void *__pdata); |
106 | 157 | ||
158 | #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA | ||
159 | extern void __init setup_per_cpu_areas(void); | ||
160 | #endif | ||
161 | |||
107 | #else /* CONFIG_SMP */ | 162 | #else /* CONFIG_SMP */ |
108 | 163 | ||
109 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) | 164 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) |
@@ -124,6 +179,13 @@ static inline void free_percpu(void *p) | |||
124 | kfree(p); | 179 | kfree(p); |
125 | } | 180 | } |
126 | 181 | ||
182 | static inline void __init setup_per_cpu_areas(void) { } | ||
183 | |||
184 | static inline void *pcpu_lpage_remapped(void *kaddr) | ||
185 | { | ||
186 | return NULL; | ||
187 | } | ||
188 | |||
127 | #endif /* CONFIG_SMP */ | 189 | #endif /* CONFIG_SMP */ |
128 | 190 | ||
129 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ | 191 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ |
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index a43ebec3a7b9..227c2a585e4f 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h | |||
@@ -115,4 +115,10 @@ extern rwlock_t vmlist_lock; | |||
115 | extern struct vm_struct *vmlist; | 115 | extern struct vm_struct *vmlist; |
116 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); | 116 | extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); |
117 | 117 | ||
118 | struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, | ||
119 | const size_t *sizes, int nr_vms, | ||
120 | size_t align, gfp_t gfp_mask); | ||
121 | |||
122 | void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms); | ||
123 | |||
118 | #endif /* _LINUX_VMALLOC_H */ | 124 | #endif /* _LINUX_VMALLOC_H */ |