diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2012-05-05 11:05:41 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2012-05-08 08:08:44 -0400 |
commit | 0d15d74a1ead10673b5b1db66d4c90552769096c (patch) | |
tree | d8eadc48f0aa1ec04172a66b2bcf78d3cb7a0ba1 /kernel/fork.c | |
parent | 67ba5293f705eb1d1b98710e5ccb0f615936a6fc (diff) |
fork: Provide kmemcache based thread_info allocator
Several architectures have their own kmemcache based thread allocator
because THREAD_SIZE is smaller than PAGE_SIZE. Add it to the core code
conditionally on THREAD_SIZE < PAGE_SIZE so the private copies can go.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20120505150141.491002124@linutronix.de
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 2dfad0269674..7590bd6e8dff 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -132,6 +132,11 @@ static inline void free_task_struct(struct task_struct *tsk) | |||
132 | 132 | ||
133 | void __weak arch_release_thread_info(struct thread_info *ti) { } | 133 | void __weak arch_release_thread_info(struct thread_info *ti) { } |
134 | 134 | ||
135 | /* | ||
136 | * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a | ||
137 | * kmemcache based allocator. | ||
138 | */ | ||
139 | # if THREAD_SIZE >= PAGE_SIZE | ||
135 | static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, | 140 | static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, |
136 | int node) | 141 | int node) |
137 | { | 142 | { |
@@ -146,6 +151,28 @@ static inline void free_thread_info(struct thread_info *ti) | |||
146 | arch_release_thread_info(ti); | 151 | arch_release_thread_info(ti); |
147 | free_pages((unsigned long)ti, THREAD_SIZE_ORDER); | 152 | free_pages((unsigned long)ti, THREAD_SIZE_ORDER); |
148 | } | 153 | } |
154 | # else | ||
155 | static struct kmem_cache *thread_info_cache; | ||
156 | |||
157 | static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, | ||
158 | int node) | ||
159 | { | ||
160 | return kmem_cache_alloc_node(thread_info_cache, THREADINFO_GFP, node); | ||
161 | } | ||
162 | |||
163 | static void free_thread_info(struct thread_info *ti) | ||
164 | { | ||
165 | arch_release_thread_info(ti); | ||
166 | kmem_cache_free(thread_info_cache, ti); | ||
167 | } | ||
168 | |||
169 | void thread_info_cache_init(void) | ||
170 | { | ||
171 | thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE, | ||
172 | THREAD_SIZE, 0, NULL); | ||
173 | BUG_ON(thread_info_cache == NULL); | ||
174 | } | ||
175 | # endif | ||
149 | #endif | 176 | #endif |
150 | 177 | ||
151 | /* SLAB cache for signal_struct structures (tsk->signal) */ | 178 | /* SLAB cache for signal_struct structures (tsk->signal) */ |