]> err.no Git - linux-2.6/commitdiff
clean up duplicated alloc/free_thread_info
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Fri, 25 Jul 2008 08:45:40 +0000 (01:45 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 25 Jul 2008 17:53:28 +0000 (10:53 -0700)
We duplicate alloc/free_thread_info defines on many platforms (the
majority uses __get_free_pages/free_pages).  This patch defines common
defines and removes these duplicated defines.
__HAVE_ARCH_THREAD_INFO_ALLOCATOR is introduced for platforms that do
something different.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23 files changed:
include/asm-alpha/thread_info.h
include/asm-arm/thread_info.h
include/asm-avr32/thread_info.h
include/asm-blackfin/thread_info.h
include/asm-cris/thread_info.h
include/asm-frv/thread_info.h
include/asm-h8300/thread_info.h
include/asm-ia64/thread_info.h
include/asm-m32r/thread_info.h
include/asm-m68k/thread_info.h
include/asm-m68knommu/thread_info.h
include/asm-mips/thread_info.h
include/asm-mn10300/thread_info.h
include/asm-parisc/thread_info.h
include/asm-powerpc/thread_info.h
include/asm-s390/thread_info.h
include/asm-sh/thread_info.h
include/asm-sparc/thread_info_32.h
include/asm-sparc/thread_info_64.h
include/asm-um/thread_info.h
include/asm-x86/thread_info.h
include/asm-xtensa/thread_info.h
kernel/fork.c

index fb3185196298326ee265f2ef87cb148795896a01..15fda434442428660e3d896661ec11c9f134e71e 100644 (file)
@@ -50,10 +50,8 @@ register struct thread_info *__current_thread_info __asm__("$8");
 #define current_thread_info()  __current_thread_info
 
 /* Thread information allocation.  */
+#define THREAD_SIZE_ORDER 1
 #define THREAD_SIZE (2*PAGE_SIZE)
-#define alloc_thread_info(tsk) \
-  ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
-#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
 
 #endif /* __ASSEMBLY__ */
 
index f5a6647863114ccfe5fa8f88a8bab88ce29b48aa..d4be2d64616087a4ebf3bf2427d399314c6584b3 100644 (file)
@@ -97,19 +97,6 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
 }
 
-/* thread information allocation */
-#ifdef CONFIG_DEBUG_STACK_USAGE
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, \
-               THREAD_SIZE_ORDER))
-#else
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
-#endif
-
-#define free_thread_info(info) \
-       free_pages((unsigned long)info, THREAD_SIZE_ORDER);
-
 #define thread_saved_pc(tsk)   \
        ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc)))
 #define thread_saved_fp(tsk)   \
index df68631b7b27f98f63e579a3a20940a544f84f6a..294b25f9323dda6a4885de1a6b874b4a6a3bb825 100644 (file)
@@ -61,10 +61,6 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)addr;
 }
 
-/* thread information allocation */
-#define alloc_thread_info(ti) \
-       ((struct thread_info *) __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
-#define free_thread_info(ti) free_pages((unsigned long)(ti), 1)
 #define get_thread_info(ti) get_task_struct((ti)->task)
 #define put_thread_info(ti) put_task_struct((ti)->task)
 
index bc2fe5accf20a7f4c55f5b45c640e7e025a29ec1..642769329d12b12fde86d7fb99620a20a98f39ad 100644 (file)
@@ -42,6 +42,7 @@
 /*
  * Size of kernel stack for each process. This must be a power of 2...
  */
+#define THREAD_SIZE_ORDER      1
 #define THREAD_SIZE            8192    /* 2 pages */
 
 #ifndef __ASSEMBLY__
@@ -94,10 +95,6 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1));
 }
 
-/* thread information allocation */
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-                               __get_free_pages(GFP_KERNEL, 1))
-#define free_thread_info(ti)   free_pages((unsigned long) (ti), 1)
 #endif                         /* __ASSEMBLY__ */
 
 /*
index 784668ab0fa29dfdb251302f623993c9ceb19d65..7efe1000f99d23e18b0825d7b8f4c7ebc52df53d 100644 (file)
@@ -11,6 +11,8 @@
 
 #ifdef __KERNEL__
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 #ifndef __ASSEMBLY__
 #include <asm/types.h>
 #include <asm/processor.h>
index 348b8f1df17eef8593183fe565925d4c1b15467f..b7ac6bf2844c395c3179d733102e13ca0e8001fa 100644 (file)
@@ -82,6 +82,8 @@ register struct thread_info *__current_thread_info asm("gr15");
 
 #define current_thread_info() ({ __current_thread_info; })
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(tsk)                                 \
index 27bb95e2944c013d8024b58893d17f3585a39c53..aafd4d322ec3e2e8c6767aac9ea125587ff4b322 100644 (file)
@@ -49,6 +49,7 @@ struct thread_info {
 /*
  * Size of kernel stack for each process. This must be a power of 2...
  */
+#define THREAD_SIZE_ORDER      1
 #define THREAD_SIZE            8192    /* 2 pages */
 
 
@@ -65,10 +66,6 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
-/* thread information allocation */
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-                               __get_free_pages(GFP_KERNEL, 1))
-#define free_thread_info(ti)   free_pages((unsigned long) (ti), 1)
 #endif /* __ASSEMBLY__ */
 
 /*
index 2422ac61658a6bb16f465c26acf8c58df1735c6e..7c60fcdd2efdb6f6f79615b051f18c755c4ff69e 100644 (file)
@@ -54,6 +54,8 @@ struct thread_info {
        },                                      \
 }
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 #ifndef ASM_OFFSETS_C
 /* how to get the thread information struct from C */
 #define current_thread_info()  ((struct thread_info *) ((char *) current + IA64_TASK_SIZE))
index 1effcd0f5e631502eab4eb005e4393a146b14858..8589d462df27e366863974619b5cf293e0b9213c 100644 (file)
@@ -94,6 +94,8 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(tsk)                                 \
index d635a375248896149ba6a14fcfc7392ca62873f0..abc002798a2b07a9fcb502ab0f93c1c7f502ef50 100644 (file)
@@ -25,13 +25,7 @@ struct thread_info {
 }
 
 /* THREAD_SIZE should be 8k, so handle differently for 4k and 8k machines */
-#if PAGE_SHIFT == 13 /* 8k machines */
-#define alloc_thread_info(tsk)   ((struct thread_info *)__get_free_pages(GFP_KERNEL,0))
-#define free_thread_info(ti)  free_pages((unsigned long)(ti),0)
-#else /* otherwise assume 4k pages */
-#define alloc_thread_info(tsk)   ((struct thread_info *)__get_free_pages(GFP_KERNEL,1))
-#define free_thread_info(ti)  free_pages((unsigned long)(ti),1)
-#endif /* PAGE_SHIFT == 13 */
+#define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
 
 #define init_thread_info       (init_task.thread.info)
 #define init_stack             (init_thread_union.stack)
index 95996d978bedcf0d9adc3dd27e1e99f121b79881..0c9bc095f3f0bc3cae753f788f72786a67b96512 100644 (file)
@@ -71,10 +71,6 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
-/* thread information allocation */
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-                               __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER))
-#define free_thread_info(ti)   free_pages((unsigned long) (ti), THREAD_SIZE_ORDER)
 #endif /* __ASSEMBLY__ */
 
 #define        PREEMPT_ACTIVE  0x4000000
index b2772df1a1bd6270a84da3e9d2fcfc5d0ae06ab8..bb3060699df29f437facbb5631fd44985ca9e69e 100644 (file)
@@ -82,6 +82,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
 #define THREAD_MASK (THREAD_SIZE - 1UL)
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(tsk)                                 \
 ({                                                             \
index e397e719278544b530dd72a3740e8ce06e65da85..78a3881f3c1250f39eea83dc80a320c826ed650d 100644 (file)
@@ -112,6 +112,8 @@ static inline unsigned long current_stack_pointer(void)
        return sp;
 }
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
index 2d9c7500867b599ade220a0a086d8d055057c675..9f812741c3553d41a45e8dada845c7bb57fef86a 100644 (file)
@@ -34,15 +34,11 @@ struct thread_info {
 
 /* thread information allocation */
 
-#define THREAD_ORDER            2
+#define THREAD_SIZE_ORDER            2
 /* Be sure to hunt all references to this down when you change the size of
  * the kernel stack */
-#define THREAD_SIZE             (PAGE_SIZE << THREAD_ORDER)
-#define THREAD_SHIFT            (PAGE_SHIFT + THREAD_ORDER)
-
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-                       __get_free_pages(GFP_KERNEL, THREAD_ORDER))
-#define free_thread_info(ti)    free_pages((unsigned long) (ti), THREAD_ORDER)
+#define THREAD_SIZE             (PAGE_SIZE << THREAD_SIZE_ORDER)
+#define THREAD_SHIFT            (PAGE_SHIFT + THREAD_SIZE_ORDER)
 
 /* how to get the thread information struct from C */
 #define current_thread_info()  ((struct thread_info *)mfctl(30))
index b705c2a7651a929a42780163d6bd303a412f998b..a9db562df69a3590d5a51257631dc99930ed9a77 100644 (file)
@@ -66,20 +66,12 @@ struct thread_info {
 
 #if THREAD_SHIFT >= PAGE_SHIFT
 
-#define THREAD_ORDER   (THREAD_SHIFT - PAGE_SHIFT)
-
-#ifdef CONFIG_DEBUG_STACK_USAGE
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *)__get_free_pages(GFP_KERNEL | \
-               __GFP_ZERO, THREAD_ORDER))
-#else
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_ORDER))
-#endif
-#define free_thread_info(ti)   free_pages((unsigned long)ti, THREAD_ORDER)
+#define THREAD_SIZE_ORDER      (THREAD_SHIFT - PAGE_SHIFT)
 
 #else /* THREAD_SHIFT < PAGE_SHIFT */
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 extern struct thread_info *alloc_thread_info(struct task_struct *tsk);
 extern void free_thread_info(struct thread_info *ti);
 
index 99bbed99a3b2d288d17a7154c174dd7de514c390..91a8f93ad355fcfd2e69a710bbc9efb2bba685f0 100644 (file)
@@ -78,10 +78,7 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)((*(unsigned long *) __LC_KERNEL_STACK)-THREAD_SIZE);
 }
 
-/* thread information allocation */
-#define alloc_thread_info(tsk) ((struct thread_info *) \
-       __get_free_pages(GFP_KERNEL,THREAD_ORDER))
-#define free_thread_info(ti) free_pages((unsigned long) (ti),THREAD_ORDER)
+#define THREAD_SIZE_ORDER THREAD_ORDER
 
 #endif
 
index c50e5d35fe84fefe26978011966a5d39f3d2ac7b..5131e390752510be5e0cae412c033530b616874e 100644 (file)
@@ -92,6 +92,8 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 /* thread information allocation */
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(ti)  kzalloc(THREAD_SIZE, GFP_KERNEL)
index 91b9f5888c855defa112d38ec20761a6664f1875..2cf9db0440556005d3b5eef8847184238e79dc97 100644 (file)
@@ -86,6 +86,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define THREAD_INFO_ORDER  1
 #endif
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info, void)
 #define alloc_thread_info(tsk) BTFIXUP_CALL(alloc_thread_info)()
 
index c6d2e6c7f844cf43a88a852c388519b70b8fc91d..960969d5ad06f46bcca53ef7b06a406713744403 100644 (file)
@@ -155,6 +155,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define __THREAD_INFO_ORDER    0
 #endif /* PAGE_SHIFT == 13 */
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 #ifdef CONFIG_DEBUG_STACK_USAGE
 #define alloc_thread_info(tsk)                                 \
 ({                                                             \
index 356b83e2c22edf07c357e91c46469ad762968fb2..e07e72846c7a339544e859d4295eba4452891197 100644 (file)
@@ -53,21 +53,7 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
-#ifdef CONFIG_DEBUG_STACK_USAGE
-
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, \
-                                                CONFIG_KERNEL_STACK_ORDER))
-#else
-
-/* thread information allocation */
-#define alloc_thread_info(tsk) \
-       ((struct thread_info *) __get_free_pages(GFP_KERNEL, \
-                                                CONFIG_KERNEL_STACK_ORDER))
-#endif
-
-#define free_thread_info(ti) \
-       free_pages((unsigned long)(ti),CONFIG_KERNEL_STACK_ORDER)
+#define THREAD_SIZE_ORDER CONFIG_KERNEL_STACK_ORDER
 
 #endif
 
index 3f2de10509884c9ff917b9653855ca34cce45a06..da0a675adf94a1a753792d1bca54c45d4fe3bed4 100644 (file)
@@ -152,6 +152,8 @@ struct thread_info {
 #define THREAD_FLAGS GFP_KERNEL
 #endif
 
+#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+
 #define alloc_thread_info(tsk)                                         \
        ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER))
 
index a2c640682ed94f05f030a6b07b968456b7a294ac..7e4131dd546c5d62655b12fc89460a5e44b31a82 100644 (file)
@@ -111,10 +111,6 @@ static inline struct thread_info *current_thread_info(void)
        return ti;
 }
 
-/* thread information allocation */
-#define alloc_thread_info(tsk) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
-#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
-
 #else /* !__ASSEMBLY__ */
 
 /* how to get the thread information struct from ASM */
@@ -160,6 +156,7 @@ static inline struct thread_info *current_thread_info(void)
 #define TS_USEDFPU             0x0001  /* FPU was used by this task this quantum (SMP) */
 
 #define THREAD_SIZE 8192       //(2*PAGE_SIZE)
+#define THREAD_SIZE_ORDER 1
 
 #endif /* __KERNEL__ */
 #endif /* _XTENSA_THREAD_INFO */
index 552c8d8e77ad5e3fb43f606081c57023bb25e4c6..5a5d6fef341dd0d58cb6bde2d3b1602970ef6a0d 100644 (file)
@@ -93,6 +93,23 @@ int nr_processes(void)
 static struct kmem_cache *task_struct_cachep;
 #endif
 
+#ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR
+static inline struct thread_info *alloc_thread_info(struct task_struct *tsk)
+{
+#ifdef CONFIG_DEBUG_STACK_USAGE
+       gfp_t mask = GFP_KERNEL | __GFP_ZERO;
+#else
+       gfp_t mask = GFP_KERNEL;
+#endif
+       return (struct thread_info *)__get_free_pages(mask, THREAD_SIZE_ORDER);
+}
+
+static inline void free_thread_info(struct thread_info *ti)
+{
+       free_pages((unsigned long)ti, THREAD_SIZE_ORDER);
+}
+#endif
+
 /* SLAB cache for signal_struct structures (tsk->signal) */
 static struct kmem_cache *signal_cachep;