2 #include <linux/kernel.h>
3 #include <linux/sched.h>
5 #if THREAD_SHIFT < PAGE_SHIFT
6 static struct kmem_cache *thread_info_cache;
8 struct thread_info *alloc_thread_info(struct task_struct *tsk)
10 struct thread_info *ti;
12 ti = kmem_cache_alloc(thread_info_cache, GFP_KERNEL);
13 if (unlikely(ti == NULL))
15 #ifdef CONFIG_DEBUG_STACK_USAGE
16 memset(ti, 0, THREAD_SIZE);
21 void free_thread_info(struct thread_info *ti)
23 kmem_cache_free(thread_info_cache, ti);
26 void thread_info_cache_init(void)
28 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
29 THREAD_SIZE, SLAB_PANIC, NULL);
32 struct thread_info *alloc_thread_info(struct task_struct *tsk)
34 #ifdef CONFIG_DEBUG_STACK_USAGE
35 gfp_t mask = GFP_KERNEL | __GFP_ZERO;
37 gfp_t mask = GFP_KERNEL;
39 return (struct thread_info *)__get_free_pages(mask, THREAD_SIZE_ORDER);
42 void free_thread_info(struct thread_info *ti)
44 free_pages((unsigned long)ti, THREAD_SIZE_ORDER);
46 #endif /* THREAD_SHIFT < PAGE_SHIFT */