aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/process.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2010-01-12 05:01:11 -0500
committerPaul Mundt <lethal@linux-sh.org>2010-01-12 05:01:11 -0500
commitcbf6b1ba7ae12b3f7cb6b0d060b88d44649f9eda (patch)
tree267582b42611b11c6a01681855d190bacf488b01 /arch/sh/kernel/process.c
parent70e068eef97d05c97c3512f82352f39fdadfa8cb (diff)
sh: Always provide thread_info allocators.
Presently the thread_info allocators are special cased, depending on THREAD_SHIFT < PAGE_SHIFT. This provides a sensible definition for them regardless of configuration, in preparation for extended CPU state. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/process.c')
-rw-r--r--arch/sh/kernel/process.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
new file mode 100644
index 000000000000..b2bda83baeef
--- /dev/null
+++ b/arch/sh/kernel/process.c
@@ -0,0 +1,47 @@
1#include <linux/mm.h>
2#include <linux/kernel.h>
3#include <linux/sched.h>
4
5#if THREAD_SHIFT < PAGE_SHIFT
6static struct kmem_cache *thread_info_cache;
7
8struct thread_info *alloc_thread_info(struct task_struct *tsk)
9{
10 struct thread_info *ti;
11
12 ti = kmem_cache_alloc(thread_info_cache, GFP_KERNEL);
13 if (unlikely(ti == NULL))
14 return NULL;
15#ifdef CONFIG_DEBUG_STACK_USAGE
16 memset(ti, 0, THREAD_SIZE);
17#endif
18 return ti;
19}
20
21void free_thread_info(struct thread_info *ti)
22{
23 kmem_cache_free(thread_info_cache, ti);
24}
25
26void thread_info_cache_init(void)
27{
28 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
29 THREAD_SIZE, 0, NULL);
30 BUG_ON(thread_info_cache == NULL);
31}
32#else
33struct thread_info *alloc_thread_info(struct task_struct *tsk)
34{
35#ifdef CONFIG_DEBUG_STACK_USAGE
36 gfp_t mask = GFP_KERNEL | __GFP_ZERO;
37#else
38 gfp_t mask = GFP_KERNEL;
39#endif
40 return (struct thread_info *)__get_free_pages(mask, THREAD_SIZE_ORDER);
41}
42
43void free_thread_info(struct thread_info *ti)
44{
45 free_pages((unsigned long)ti, THREAD_SIZE_ORDER);
46}
47#endif /* THREAD_SHIFT < PAGE_SHIFT */