fork: Move most archs to generic threadinfo/taskstruct allocators
cover fork: Move most archs to generic threadinfo/taskstruct allocators
We have a lot of duplicate implementations of the threadinfo and task struct allocator around in arch/*. This series consolidates them.
Applies on top of
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp/hotplug
Thanks,
tglx
--- arch/Kconfig | 8 +++ arch/c6x/include/asm/thread_info.h | 17 ------- arch/cris/include/asm/processor.h | 5 -- arch/cris/include/asm/thread_info.h | 6 -- arch/frv/include/asm/thread_info.h | 13 ------ arch/hexagon/include/asm/thread_info.h | 8 --- arch/hexagon/kernel/process.c | 37 ----------------- arch/ia64/Kconfig | 2 arch/ia64/include/asm/thread_info.h | 3 - arch/m32r/include/asm/thread_info.h | 17 ------- arch/mips/include/asm/thread_info.h | 12 ----- arch/mn10300/include/asm/thread_info.h | 17 +------ arch/mn10300/kernel/kgdb.c | 3 - arch/powerpc/include/asm/thread_info.h | 13 ------ arch/powerpc/kernel/process.c | 31 -------------- arch/score/include/asm/thread_info.h | 10 +--- arch/sh/include/asm/thread_info.h | 11 ----- arch/sh/kernel/process.c | 46 --------------------- arch/sparc/Kconfig | 1 arch/sparc/include/asm/thread_info_32.h | 2 arch/sparc/include/asm/thread_info_64.h | 25 ----------- arch/tile/include/asm/thread_info.h | 6 -- arch/tile/kernel/process.c | 23 ---------- arch/x86/include/asm/boot.h | 2 arch/x86/include/asm/page_32_types.h | 4 - arch/x86/include/asm/page_64_types.h | 4 - arch/x86/include/asm/thread_info.h | 21 --------- arch/x86/kernel/irq_32.c | 8 +-- arch/x86/kernel/process.c | 5 -- include/linux/thread_info.h | 6 ++ kernel/fork.c | 69 ++++++++++++++++++++++---------- 31 files changed, 100 insertions(+), 335 deletions(-)
PATCH 1/18 fork: Remove the weak insanity
We error out when compiling with gcc4.1.[01] as it miscompiles __weak. The workaround with magic defines is not longer necessary. Make it __weak again.
--- arch/sh/include/asm/thread_info.h | 1 - arch/x86/include/asm/thread_info.h | 1 - kernel/fork.c | 8 +------- 3 files changed, 1 insertion(+), 9 deletions(-)
arch/sh/include/asm/thread_info.h +0 -1
@@ -98,7 +98,6 @@ static inline struct thread_info *currenextern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node);extern void free_thread_info (struct thread_info *ti);extern void arch_task_cache_init (void ); -#define arch_task_cache_init arch_task_cache_initextern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src);extern void init_thread_xstate (void );
arch/x86/include/asm/thread_info.h +0 -1
@@ -284,6 +284,5 @@ static inline bool is_ia32_task(void)extern void arch_task_cache_init (void );extern void free_thread_info (struct thread_info *ti);extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); -#define arch_task_cache_init arch_task_cache_init#endif #endif /* _ASM_X86_THREAD_INFO_H */
kernel/fork.c +1 -7
@@ -203,13 +203,7 @@ void __put_task_struct(struct task_struc }EXPORT_SYMBOL_GPL (__put_task_struct); -/* -* macro override instead of weak attribute alias, to workaround -* gcc 4.1.0 and 4.1.1 bugs with weak attribute and empty functions. -*/ -#ifndef arch_task_cache_init -#define arch_task_cache_init () -#endif +void __init __weak arch_task_cache_init (void ) { }void __init fork_init (unsigned long mempages) {
Re: [patch 01/18] fork: Remove the weak insanity
Quoted 3 lines · Thomas Gleixner
We error out when compiling with gcc4.1.[01] as it miscompiles
__weak. The workaround with magic defines is not longer necessary. Make it__weakagain.
The cleanup is much appreciated!
But the magic defines is IMO much better than the CONFIG_ based approach that this patch-set introduces in the last patch.
If you do:
$git grep arch_task_cache_init
Then if you see:
#define arch_task_cache_init arch_task_cache_init
Then you know alrady that this arch will provide a local implementation of arch_task_cache_init().
No need to grep for an ARCH_XXX symbol that you need to look up somewhere else.
Sam
Re: [patch 01/18] fork: Remove the weak insanity
Quoted 14 lines · Sam Ravnborg
Quoted 3 lines · Thomas Gleixner
We error out when compiling with gcc4.1.[01] as it miscompiles
__weak. The workaround with magic defines is not longer necessary. Make it__weakagain.The cleanup is much appreciated!
But the magic defines is IMO much better than the
CONFIG_based approach that this patch-set introduces in the last patch.If you do:
$git grep
arch_task_cache_init
Quoted 8 lines
Then if you see:
#define arch_task_cache_init arch_task_cache_initThen you know alrady that this arch will provide a local implementation of
arch_task_cache_init().
No need to grep for anARCH_XXXsymbol that you need to look up somewhere else.
I'm not following that argument.
Removing that magic define thing does not change anything. The change is:
-#define arch_task_cache_init arch_task_cache_init -#define arch_task_cache_init arch_task_cache_init
-/*
- * macro override instead of weak attribute alias, to workaround
- * gcc 4.1.0 and 4.1.1 bugs with weak attribute and empty functions.
- */
-#ifndef arch_task_cache_init
-#define arch_task_cache_init()
-#endif
+void __init __weak arch_task_cache_init(void) { }
So $git grep arch_task_cache_init still tells you who is overriding arch_task_cache_init () which is:
arch/sh/include/asm/thread_info.h:extern void arch_task_cache_init(void); arch/sh/kernel/process.c:void arch_task_cache_init(void) arch/x86/include/asm/thread_info.h:extern void arch_task_cache_init(void); arch/x86/kernel/process.c:void arch_task_cache_init(void)
What's your problem ?
Now for the last patch in the series:
It merily moves
#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
to a Kconfig based
select ARCH_THREAD_INFO_ALLOCATOR
I'm not seeing any difference except that something which is actually a config switch is moved to the place where it belongs.
Thanks,
tglx
Re: [patch 01/18] fork: Remove the weak insanity
Quoted 29 lines · Thomas Gleixner
Quoted 14 lines · Sam Ravnborg
Quoted 3 lines · Thomas Gleixner
We error out when compiling with gcc4.1.[01] as it miscompiles
__weak. The workaround with magic defines is not longer necessary. Make it__weakagain.The cleanup is much appreciated!
But the magic defines is IMO much better than the
CONFIG_based approach that this patch-set introduces in the last patch.If you do:
$git grep
arch_task_cache_initQuoted 8 lines
Then if you see:
#define arch_task_cache_init arch_task_cache_initThen you know alrady that this arch will provide a local implementation of
arch_task_cache_init().
No need to grep for anARCH_XXXsymbol that you need to look up somewhere else.I'm not following that argument.
Removing that magic define thing does not change anything. The change is:
...
Quoted 10 lines
Now for the last patch in the series:
It merily moves
#define
__HAVE_ARCH_THREAD_INFO_ALLOCATORto a
Kconfigbasedselect
ARCH_THREAD_INFO_ALLOCATOR
The point was that rather than using a Kconfig symbol for this the architecutres that required a dedicated implementation could do the:
#define foo foo
trick.
And the generic implmentation should then do:
#ifndef foo
void foo(int bar)
{
}
#endif
You are right that the archs implmenting foo() will stand out in the grep anyway.
But using the define trick you do not spread it up to the Kconfig level, for individual functions.
Sam
[tip:smp/hotplug] fork: Remove the weak insanity
In reply to Thomas GleixnerCommit-ID: 6c0a9fa62feb7e9fdefa9720bcc03040c9b0b311 Gitweb: http://git.kernel.org/tip/6c0a9fa62feb7e9fdefa9720bcc03040c9b0b311 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:40 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 13:55:20 +0200
fork: Remove the weak insanity
We error out when compiling with gcc4.1.[01] as it miscompiles __weak. The workaround with magic defines is not longer necessary. Make it __weak again.
--- arch/sh/include/asm/thread_info.h | 1 - arch/x86/include/asm/thread_info.h | 1 - kernel/fork.c | 8 +------- 3 files changed, 1 insertions(+), 9 deletions(-)
arch/sh/include/asm/thread_info.h +0 -1
@@ -98,7 +98,6 @@ static inline struct thread_info *current_thread_info(void)extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node);extern void free_thread_info (struct thread_info *ti);extern void arch_task_cache_init (void ); -#define arch_task_cache_init arch_task_cache_initextern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src);extern void init_thread_xstate (void );
arch/x86/include/asm/thread_info.h +0 -1
@@ -284,6 +284,5 @@ static inline bool is_ia32_task(void)extern void arch_task_cache_init (void );extern void free_thread_info (struct thread_info *ti);extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); -#define arch_task_cache_init arch_task_cache_init#endif #endif /* _ASM_X86_THREAD_INFO_H */
kernel/fork.c +1 -7
@@ -203,13 +203,7 @@ void __put_task_struct(struct task_struct *tsk) }EXPORT_SYMBOL_GPL (__put_task_struct); -/* -* macro override instead of weak attribute alias, to workaround -* gcc 4.1.0 and 4.1.1 bugs with weak attribute and empty functions. -*/ -#ifndef arch_task_cache_init -#define arch_task_cache_init () -#endif +void __init __weak arch_task_cache_init (void ) { }void __init fork_init (unsigned long mempages) {
PATCH 2/18 fork: Provide weak arch_release_[task_struct|thread_info] functions
In reply to Thomas GleixnerThese functions allow us to move most of the duplicated thread_info allocators to the core code.
--- kernel/fork.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
kernel/fork.c +17 -4
@@ -112,14 +112,26 @@ int nr_processes(void) }#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR -# define alloc_task_struct_node (node) \ - kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node) -# define free_task_struct (tsk) \ - kmem_cache_free(task_struct_cachep, (tsk))static struct kmem_cache *task_struct_cachep; + +static inline struct task_struct *alloc_task_struct_node (int node) +{ +return kmem_cache_alloc_node (task_struct_cachep,GFP_KERNEL , node); +} + +void __weak arch_release_task_struct (struct task_struct *tsk) { } + +static inline void free_task_struct (struct task_struct *tsk) +{ +arch_release_task_struct (tsk); +kmem_cache_free (task_struct_cachep, tsk); +}#endif #ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR + +void __weak arch_release_thread_info (struct thread_info *ti) { } +static struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) {
@@ -135,6 +147,7 @@ static struct thread_info *alloc_thread_static inline void free_thread_info (struct thread_info *ti) { +arch_release_thread_info (ti);free_pages ((unsigned long )ti,THREAD_SIZE_ORDER ); }#endif
[tip:smp/hotplug] fork: Provide weak arch_release_[ task_struct|thread_info] functions
Commit-ID: 41101809a865dd0be1b56eff46c83fad321870b2 Gitweb: http://git.kernel.org/tip/41101809a865dd0be1b56eff46c83fad321870b2 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:41 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 13:55:20 +0200
fork: Provide weak arch_release_[task_struct|thread_info] functions
These functions allow us to move most of the duplicated thread_info allocators to the core code.
--- kernel/fork.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-)
kernel/fork.c +17 -4
@@ -112,14 +112,26 @@ int nr_processes(void) }#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR -# define alloc_task_struct_node (node) \ - kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node) -# define free_task_struct (tsk) \ - kmem_cache_free(task_struct_cachep, (tsk))static struct kmem_cache *task_struct_cachep; + +static inline struct task_struct *alloc_task_struct_node (int node) +{ +return kmem_cache_alloc_node (task_struct_cachep,GFP_KERNEL , node); +} + +void __weak arch_release_task_struct (struct task_struct *tsk) { } + +static inline void free_task_struct (struct task_struct *tsk) +{ +arch_release_task_struct (tsk); +kmem_cache_free (task_struct_cachep, tsk); +}#endif #ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR + +void __weak arch_release_thread_info (struct thread_info *ti) { } +static struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) {
@@ -131,6 +143,7 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,static inline void free_thread_info (struct thread_info *ti) { +arch_release_thread_info (ti);free_pages ((unsigned long )ti,THREAD_SIZE_ORDER ); }#endif
PATCH 3/18 fork: Move thread info gfp flags to header
In reply to Thomas GleixnerThese flags can be useful for extra allocations outside of the core code.
Add __GFP_NOTRACE to them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.
--- include/linux/thread_info.h | 6 ++++++ kernel/fork.c | 8 ++------ 2 files changed, 8 insertions(+), 6 deletions(-)
include/linux/thread_info.h +6 -0
@@ -54,6 +54,12 @@ extern long do_no_restart_syscall(struct#ifdef __KERNEL__ +#ifdef CONFIG_DEBUG_STACK_USAGE +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACE | __GFP_ZERO) +#else +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACE) +#endif +/* * flag set/clear/test wrappers * - pass TIF_xxxx constants to these functions
kernel/fork.c +2 -6
@@ -135,12 +135,8 @@ void __weak arch_release_thread_info(strstatic struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) { -#ifdef CONFIG_DEBUG_STACK_USAGE -gfp_t mask =GFP_KERNEL | __GFP_ZERO; -#else -gfp_t mask =GFP_KERNEL ; -#endif -struct page *page =alloc_pages_node (node, mask,THREAD_SIZE_ORDER ); +struct page *page =alloc_pages_node (node,THREADINFO_GFP , +THREAD_SIZE_ORDER );return page ?page_address (page) :NULL ; }
Re: [patch 03/18] fork: Move thread info gfp flags to header
Quoted 5 lines · Thomas Gleixner
These flags can be useful for extra allocations outside of the core code.
Add
__GFP_NOTRACEto them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.
This breaks powerpc builds due to __GFP_NOTRACE not being defined. I restarted the test after removing the __GFP_NOTRACE as a testing-only hack, and will let you know how it goes. Also looking into why this builds on 32-bit x86 but not on powerpc.
Thanx, Paul
Quoted 50 lines
Signed-off-by Thomas Gleixner <[email protected]>--- include/linux/thread_info.h | 6 ++++++ kernel/fork.c | 8 ++------ 2 files changed, 8 insertions(+), 6 deletions(-)Index:
tip/include/linux/thread_info.h
===================================================================include/linux/thread_info.h +6
-0@@ -54,6 +54,12 @@ extern long do_no_restart_syscall(struct#ifdef __KERNEL__ +#ifdef CONFIG_DEBUG_STACK_USAGE +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACE | __GFP_ZERO) +#else +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACE) +#endif +/* * flag set/clear/test wrappers * - pass TIF_xxxx constants to these functions Index:
tip/kernel/fork.c
===================================================================kernel/fork.c +2
-7@@ -135,12 +135,8 @@ void __weak arch_release_thread_info(strstatic struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) { -#ifdef CONFIG_DEBUG_STACK_USAGE -gfp_t mask =GFP_KERNEL | __GFP_ZERO; -#else -gfp_t mask =GFP_KERNEL ; -#endif -struct page *page =alloc_pages_node (node, mask,THREAD_SIZE_ORDER ); +struct page *page =alloc_pages_node (node,THREADINFO_GFP , +THREAD_SIZE_ORDER );return page ?page_address (page) :NULL ; } --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 03/18] fork: Move thread info gfp flags to header
Quoted 11 lines · Paul E. McKenney
Quoted 5 lines · Thomas Gleixner
These flags can be useful for extra allocations outside of the core code.
Add
__GFP_NOTRACEto them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.This breaks powerpc builds due to
__GFP_NOTRACEnot being defined. I restarted the test after removing the__GFP_NOTRACEas a testing-only hack, and will let you know how it goes. Also looking into why this builds on 32-bit x86 but not on powerpc.
And the reason that it built on 32-bit x86 was that I mistakenly built only the RCU files, not the whole kernel. So I am guessing that there is something I need to merge into tip/smp/hotplug.
On the other hand, removing the __GFP_NOTRACE allows this patchset to pass modest rcutorture testing on Power. ;-)
Thanx, Paul
Re: [patch 03/18] fork: Move thread info gfp flags to header
In reply to Paul E. McKenneyQuoted 11 lines · Paul E. McKenney
Quoted 5 lines · Thomas Gleixner
These flags can be useful for extra allocations outside of the core code.
Add
__GFP_NOTRACEto them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.This breaks powerpc builds due to
__GFP_NOTRACEnot being defined. I restarted the test after removing the__GFP_NOTRACEas a testing-only hack, and will let you know how it goes. Also looking into why this builds on 32-bit x86 but not on powerpc.
Hrmpf. Seems the idiot I am fatfingered __GFP_NOTRACK to __GFP_NOTRACE and then only tested with the DEBUG stuff disabled......
Re: [patch 03/18] fork: Move thread info gfp flags to header
Quoted 9 lines · Thomas Gleixner
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines · Thomas Gleixner
These flags can be useful for extra allocations outside of the core code.
Add
__GFP_NOTRACEto them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.
Quoted 7 lines
Quoted 4 lines
This breaks powerpc builds due to
__GFP_NOTRACEnot being defined. I restarted the test after removing the__GFP_NOTRACEas a testing-only hack, and will let you know how it goes. Also looking into why this builds on 32-bit x86 but not on powerpc.Hrmpf. Seems the idiot I am fatfingered
__GFP_NOTRACKto__GFP_NOTRACEand then only tested with the DEBUG stuff disabled......
That sounds like something I would do... ;-)
I will rerun with __GFP_NOTRACK.
Thanx, Paul
Re: [patch 03/18] fork: Move thread info gfp flags to header
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines · Thomas Gleixner
Quoted 11 lines · Paul E. McKenney
Quoted 5 lines · Thomas Gleixner
These flags can be useful for extra allocations outside of the core code.
Add
__GFP_NOTRACEto them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.This breaks powerpc builds due to
__GFP_NOTRACEnot being defined. I restarted the test after removing the__GFP_NOTRACEas a testing-only hack, and will let you know how it goes. Also looking into why this builds on 32-bit x86 but not on powerpc.
Quoted 6 lines
Quoted 2 lines
Hrmpf. Seems the idiot I am fatfingered
__GFP_NOTRACKto__GFP_NOTRACEand then only tested with the DEBUG stuff disabled......That sounds like something I would do... ;-)
I will rerun with
__GFP_NOTRACK.
Which passes moderate rcutorture testing on Power.
Thanx, Paul
[tip:smp/hotplug] fork: Move thread info gfp flags to header
In reply to Thomas GleixnerCommit-ID: 2889f60814e15dea644782597d897cdba943564f Gitweb: http://git.kernel.org/tip/2889f60814e15dea644782597d897cdba943564f Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:41 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 13:55:20 +0200
fork: Move thread info gfp flags to header
These flags can be useful for extra allocations outside of the core code.
Add __GFP_NOTRACK to them, so the archs which have kmemcheck do not have to provide extra allocators just for that reason.
--- include/linux/thread_info.h | 6 ++++++ kernel/fork.c | 8 ++------ 2 files changed, 8 insertions(+), 6 deletions(-)
include/linux/thread_info.h +6 -0
@@ -54,6 +54,12 @@ extern long do_no_restart_syscall(struct restart_block *parm);#ifdef __KERNEL__ +#ifdef CONFIG_DEBUG_STACK_USAGE +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) +#else +# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK) +#endif +/* * flag set/clear/test wrappers * - pass TIF_xxxx constants to these functions
kernel/fork.c +2 -6
@@ -123,12 +123,8 @@ static struct kmem_cache *task_struct_cachep;static struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) { -#ifdef CONFIG_DEBUG_STACK_USAGE -gfp_t mask =GFP_KERNEL | __GFP_ZERO; -#else -gfp_t mask =GFP_KERNEL ; -#endif -struct page *page =alloc_pages_node (node, mask,THREAD_SIZE_ORDER ); +struct page *page =alloc_pages_node (node,THREADINFO_GFP , +THREAD_SIZE_ORDER );return page ?page_address (page) :NULL ; }
PATCH 4/18 fork: Provide kmemcache based thread_info allocator
In reply to Thomas GleixnerSeveral 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.
--- kernel/fork.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
kernel/fork.c +27 -0
@@ -132,6 +132,11 @@ static inline void free_task_struct(struvoid __weak arch_release_thread_info (struct thread_info *ti) { } +/* +* Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a +* kmemcache based allocator. +*/ +# if THREAD_SIZE >=PAGE_SIZE static struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) {
@@ -146,6 +151,28 @@ static inline void free_thread_info(struarch_release_thread_info (ti);free_pages ((unsigned long )ti,THREAD_SIZE_ORDER ); } +# else +static struct kmem_cache *thread_info_cache; + +static struct thread_info *alloc_thread_info_node (struct task_struct *tsk, +int node) +{ +return kmem_cache_alloc_node (thread_info_cache,THREADINFO_GFP , node); +} + +static void free_thread_info (struct thread_info *ti) +{ +arch_release_thread_info (ti); +kmem_cache_free (thread_info_cache, ti); +} + +void thread_info_cache_init (void ) +{ + thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , +THREAD_SIZE ,0 ,NULL ); +BUG_ON (thread_info_cache ==NULL ); +} +# endif #endif /* SLAB cache for signal_struct structures (tsk->signal) */
[tip:smp/hotplug] fork: Provide kmemcache based thread_info allocator
Commit-ID: 0d15d74a1ead10673b5b1db66d4c90552769096c Gitweb: http://git.kernel.org/tip/0d15d74a1ead10673b5b1db66d4c90552769096c Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:41 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:44 +0200
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.
--- kernel/fork.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
kernel/fork.c +27 -0
@@ -132,6 +132,11 @@ static inline void free_task_struct(struct task_struct *tsk)void __weak arch_release_thread_info (struct thread_info *ti) { } +/* +* Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a +* kmemcache based allocator. +*/ +# if THREAD_SIZE >=PAGE_SIZE static struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) {
@@ -146,6 +151,28 @@ static inline void free_thread_info(struct thread_info *ti)arch_release_thread_info (ti);free_pages ((unsigned long )ti,THREAD_SIZE_ORDER ); } +# else +static struct kmem_cache *thread_info_cache; + +static struct thread_info *alloc_thread_info_node (struct task_struct *tsk, +int node) +{ +return kmem_cache_alloc_node (thread_info_cache,THREADINFO_GFP , node); +} + +static void free_thread_info (struct thread_info *ti) +{ +arch_release_thread_info (ti); +kmem_cache_free (thread_info_cache, ti); +} + +void thread_info_cache_init (void ) +{ + thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , +THREAD_SIZE ,0 ,NULL ); +BUG_ON (thread_info_cache ==NULL ); +} +# endif #endif /* SLAB cache for signal_struct structures (tsk->signal) */
PATCH 5/18 x86: Use common threadinfo allocator
In reply to Thomas GleixnerThe only difference is the free_thread_info function, which frees xstate.
Use the new arch_release_task_struct() function instead and switch over to the core allocator.
--- arch/x86/include/asm/boot.h | 2 +- arch/x86/include/asm/page_32_types.h | 4 ++-- arch/x86/include/asm/page_64_types.h | 4 ++-- arch/x86/include/asm/thread_info.h | 20 +------------------- arch/x86/kernel/irq_32.c | 8 ++++---- arch/x86/kernel/process.c | 5 ++--- 6 files changed, 12 insertions(+), 31 deletions(-)
arch/x86/include/asm/boot.h +1 -1
@@ -19,7 +19,7 @@#ifdef CONFIG_X86_64 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT#else -#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_ORDER) +#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)#endif #define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
arch/x86/include/asm/page_32_types.h +2 -2
@@ -15,8 +15,8 @@*/ #define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) -#define THREAD_ORDER 1 -#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) +#define THREAD_SIZE_ORDER 1 +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define STACKFAULT_STACK 0#define DOUBLEFAULT_STACK 1
arch/x86/include/asm/page_64_types.h +2 -2
@@ -1,8 +1,8 @@#ifndef _ASM_X86_PAGE_64_DEFS_H#define _ASM_X86_PAGE_64_DEFS_H -#define THREAD_ORDER 1 -#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) +#define THREAD_SIZE_ORDER 1 +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define CURRENT_MASK (~(THREAD_SIZE - 1))#define EXCEPTION_STACK_ORDER 0
arch/x86/include/asm/thread_info.h +1 -19
@@ -155,24 +155,6 @@ struct thread_info {#define PREEMPT_ACTIVE 0x10000000 -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK) -#endif - -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#define alloc_thread_info_node (tsk, node) \ -({ \ - struct page *page = alloc_pages_node(node, THREAD_FLAGS, \ - THREAD_ORDER); \ - struct thread_info *ret = page ? page_address(page) : NULL; \ - \ - ret; \ -}) -#ifdef CONFIG_X86_32 #define STACK_WARN (THREAD_SIZE/8)
@@ -282,7 +264,7 @@ static inline bool is_ia32_task(void)#ifndef __ASSEMBLY__extern void arch_task_cache_init (void ); -extern void free_thread_info (struct thread_info *ti);extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern void arch_release_task_struct (struct task_struct *tsk);#endif #endif /* _ASM_X86_THREAD_INFO_H */
arch/x86/kernel/irq_32.c +4 -4
@@ -127,8 +127,8 @@ void __cpuinit irq_ctx_init(int cpu)return ; irqctx =page_address (alloc_pages_node (cpu_to_node (cpu), -THREAD_FLAGS , -THREAD_ORDER )); +THREADINFO_GFP , +THREAD_SIZE_ORDER ));memset (&irqctx->tinfo,0 ,sizeof (struct thread_info )); irqctx->tinfo.cpu = cpu; irqctx->tinfo.preempt_count =HARDIRQ_OFFSET ;
@@ -137,8 +137,8 @@ void __cpuinit irq_ctx_init(int cpu)per_cpu (hardirq_ctx, cpu) = irqctx; irqctx =page_address (alloc_pages_node (cpu_to_node (cpu), -THREAD_FLAGS , -THREAD_ORDER )); +THREADINFO_GFP , +THREAD_SIZE_ORDER ));memset (&irqctx->tinfo,0 ,sizeof (struct thread_info )); irqctx->tinfo.cpu = cpu; irqctx->tinfo.addr_limit =MAKE_MM_SEG (0 );
arch/x86/kernel/process.c +2 -3
@@ -76,10 +76,9 @@ void free_thread_xstate(struct task_strufpu_free (&tsk->thread.fpu); } -void free_thread_info (struct thread_info *ti) +void arch_release_task_struct (struct task_struct *tsk) { -free_thread_xstate (ti->task); -free_pages ((unsigned long )ti,THREAD_ORDER ); +free_thread_xstate (tsk); }void arch_task_cache_init (void )
[tip:smp/hotplug] x86: Use common threadinfo allocator
Commit-ID: 38e7c572ce7310def003d8bb7c34260f5d8118cb Gitweb: http://git.kernel.org/tip/38e7c572ce7310def003d8bb7c34260f5d8118cb Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:42 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:44 +0200
x86: Use common threadinfo allocator
The only difference is the free_thread_info function, which frees xstate.
Use the new arch_release_task_struct() function instead and switch over to the core allocator.
--- arch/x86/include/asm/boot.h | 2 +- arch/x86/include/asm/page_32_types.h | 4 ++-- arch/x86/include/asm/page_64_types.h | 4 ++-- arch/x86/include/asm/thread_info.h | 20 +------------------- arch/x86/kernel/irq_32.c | 8 ++++---- arch/x86/kernel/process.c | 5 ++--- 6 files changed, 12 insertions(+), 31 deletions(-)
arch/x86/include/asm/boot.h +1 -1
@@ -19,7 +19,7 @@#ifdef CONFIG_X86_64 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT#else -#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_ORDER) +#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)#endif #define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
arch/x86/include/asm/page_32_types.h +2 -2
@@ -15,8 +15,8 @@*/ #define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) -#define THREAD_ORDER 1 -#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) +#define THREAD_SIZE_ORDER 1 +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define STACKFAULT_STACK 0#define DOUBLEFAULT_STACK 1
arch/x86/include/asm/page_64_types.h +2 -2
@@ -1,8 +1,8 @@#ifndef _ASM_X86_PAGE_64_DEFS_H#define _ASM_X86_PAGE_64_DEFS_H -#define THREAD_ORDER 1 -#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) +#define THREAD_SIZE_ORDER 1 +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define CURRENT_MASK (~(THREAD_SIZE - 1))#define EXCEPTION_STACK_ORDER 0
arch/x86/include/asm/thread_info.h +1 -19
@@ -155,24 +155,6 @@ struct thread_info {#define PREEMPT_ACTIVE 0x10000000 -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK) -#endif - -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#define alloc_thread_info_node (tsk, node) \ -({ \ - struct page *page = alloc_pages_node(node, THREAD_FLAGS, \ - THREAD_ORDER); \ - struct thread_info *ret = page ? page_address(page) : NULL; \ - \ - ret; \ -}) -#ifdef CONFIG_X86_32 #define STACK_WARN (THREAD_SIZE/8)
@@ -282,7 +264,7 @@ static inline bool is_ia32_task(void)#ifndef __ASSEMBLY__extern void arch_task_cache_init (void ); -extern void free_thread_info (struct thread_info *ti);extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern void arch_release_task_struct (struct task_struct *tsk);#endif #endif /* _ASM_X86_THREAD_INFO_H */
arch/x86/kernel/irq_32.c +4 -4
@@ -127,8 +127,8 @@ void __cpuinit irq_ctx_init(int cpu)return ; irqctx =page_address (alloc_pages_node (cpu_to_node (cpu), -THREAD_FLAGS , -THREAD_ORDER )); +THREADINFO_GFP , +THREAD_SIZE_ORDER ));memset (&irqctx->tinfo,0 ,sizeof (struct thread_info )); irqctx->tinfo.cpu = cpu; irqctx->tinfo.preempt_count =HARDIRQ_OFFSET ;
@@ -137,8 +137,8 @@ void __cpuinit irq_ctx_init(int cpu)per_cpu (hardirq_ctx, cpu) = irqctx; irqctx =page_address (alloc_pages_node (cpu_to_node (cpu), -THREAD_FLAGS , -THREAD_ORDER )); +THREADINFO_GFP , +THREAD_SIZE_ORDER ));memset (&irqctx->tinfo,0 ,sizeof (struct thread_info )); irqctx->tinfo.cpu = cpu; irqctx->tinfo.addr_limit =MAKE_MM_SEG (0 );
arch/x86/kernel/process.c +2 -3
@@ -76,10 +76,9 @@ void free_thread_xstate(struct task_struct *tsk)fpu_free (&tsk->thread.fpu); } -void free_thread_info (struct thread_info *ti) +void arch_release_task_struct (struct task_struct *tsk) { -free_thread_xstate (ti->task); -free_pages ((unsigned long )ti,THREAD_ORDER ); +free_thread_xstate (tsk); }void arch_task_cache_init (void )
PATCH 6/18 c6x: Use common threadinfo allocator
In reply to Thomas GleixnerThere is no functional difference. __get_free_pages() ends up calling alloc_pages_node().
--- arch/c6x/include/asm/thread_info.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
arch/c6x/include/asm/thread_info.h +2 -15
@@ -20,11 +20,11 @@#ifdef CONFIG_4KSTACKS #define THREAD_SIZE 4096#define THREAD_SHIFT 12 -#define THREAD_ORDER 0 +#define THREAD_SIZE_ORDER 0#else #define THREAD_SIZE 8192#define THREAD_SHIFT 13 -#define THREAD_ORDER 1 +#define THREAD_SIZE_ORDER 1#endif #define THREAD_START_SP (THREAD_SIZE - 8)
@@ -80,19 +80,6 @@ struct thread_info *current_thread_info( return ti; } -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK) -#endif - -#define alloc_thread_info_node (tsk, node) \ - ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER)) - -#define free_thread_info (ti) free_pages((unsigned long) (ti), THREAD_ORDER)#define get_thread_info (ti) get_task_struct((ti)->task)#define put_thread_info (ti) put_task_struct((ti)->task)#endif /* __ASSEMBLY__ */
Re: [patch 06/18] c6x: Use common threadinfo allocator
Quoted 4 lines · Thomas Gleixner
There is no functional difference.
__get_free_pages()ends up callingalloc_pages_node().Signed-off-by Thomas Gleixner <[email protected]>
[tip:smp/hotplug] c6x: Use common threadinfo allocator
In reply to Thomas GleixnerCommit-ID: 7b8fe0570a65486e77823d5fcec9998c2aae9970 Gitweb: http://git.kernel.org/tip/7b8fe0570a65486e77823d5fcec9998c2aae9970 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:42 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:44 +0200
c6x: Use common threadinfo allocator
There is no functional difference. __get_free_pages() ends up calling alloc_pages_node().
--- arch/c6x/include/asm/thread_info.h | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
arch/c6x/include/asm/thread_info.h +2 -15
@@ -20,11 +20,11 @@#ifdef CONFIG_4KSTACKS #define THREAD_SIZE 4096#define THREAD_SHIFT 12 -#define THREAD_ORDER 0 +#define THREAD_SIZE_ORDER 0#else #define THREAD_SIZE 8192#define THREAD_SHIFT 13 -#define THREAD_ORDER 1 +#define THREAD_SIZE_ORDER 1#endif #define THREAD_START_SP (THREAD_SIZE - 8)
@@ -80,19 +80,6 @@ struct thread_info *current_thread_info(void) return ti; } -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK) -#endif - -#define alloc_thread_info_node (tsk, node) \ - ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER)) - -#define free_thread_info (ti) free_pages((unsigned long) (ti), THREAD_ORDER)#define get_thread_info (ti) get_task_struct((ti)->task)#define put_thread_info (ti) put_task_struct((ti)->task)#endif /* __ASSEMBLY__ */
PATCH 7/18 cris: Use common threadinfo allocator
In reply to Thomas GleixnerThere is no functional difference. __get_free_pages() ends up calling alloc_pages_node().
This also allocates only one page which matches THREAD_SIZE instead of an extra page for nothing.
--- arch/cris/include/asm/processor.h | 5 ++--- arch/cris/include/asm/thread_info.h | 6 ------ 2 files changed, 2 insertions(+), 9 deletions(-)
arch/cris/include/asm/processor.h +2 -3
@@ -25,13 +25,12 @@ struct task_struct;*/ #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) -/* THREAD_SIZE is the size of the task_struct/kernel_stack combo. +/* THREAD_SIZE is the size of the thread_info/kernel_stack combo. * normally, the stack is found by doing something like p + THREAD_SIZE * in CRIS, a page is 8192 bytes, which seems like a sane size */ -#define THREAD_SIZE PAGE_SIZE -#define KERNEL_STACK_SIZE PAGE_SIZE +#define THREAD_SIZE_ORDER (0)/* * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
arch/cris/include/asm/thread_info.h +0 -6
@@ -65,12 +65,6 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -/* thread information allocation */ -#define alloc_thread_info_node (tsk, node) \ - ((struct thread_info *) __get_free_pages(GFP_KERNEL, 1)) -#define free_thread_info (ti) free_pages((unsigned long) (ti), 1) -#endif /* !__ASSEMBLY__ */ /*
[tip:smp/hotplug] cris: Use common threadinfo allocator
Commit-ID: 803fc74f06cf3cd23417463ca5a176b41717ec19 Gitweb: http://git.kernel.org/tip/803fc74f06cf3cd23417463ca5a176b41717ec19 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:43 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:44 +0200
cris: Use common threadinfo allocator
There is no functional difference. __get_free_pages() ends up calling alloc_pages_node().
This also allocates only one page which matches THREAD_SIZE instead of an extra page for nothing.
--- arch/cris/include/asm/processor.h | 5 ++--- arch/cris/include/asm/thread_info.h | 6 ------ 2 files changed, 2 insertions(+), 9 deletions(-)
arch/cris/include/asm/processor.h +2 -3
@@ -25,13 +25,12 @@ struct task_struct;*/ #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) -/* THREAD_SIZE is the size of the task_struct/kernel_stack combo. +/* THREAD_SIZE is the size of the thread_info/kernel_stack combo. * normally, the stack is found by doing something like p + THREAD_SIZE * in CRIS, a page is 8192 bytes, which seems like a sane size */ -#define THREAD_SIZE PAGE_SIZE -#define KERNEL_STACK_SIZE PAGE_SIZE +#define THREAD_SIZE_ORDER (0)/* * At user->kernel entry, the pt_regs struct is stacked on the top of the kernel-stack.
arch/cris/include/asm/thread_info.h +0 -6
@@ -65,12 +65,6 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -/* thread information allocation */ -#define alloc_thread_info_node (tsk, node) \ - ((struct thread_info *) __get_free_pages(GFP_KERNEL, 1)) -#define free_thread_info (ti) free_pages((unsigned long) (ti), 1) -#endif /* !__ASSEMBLY__ */ /*
Re: [patch 07/18] cris: Use common threadinfo allocator
In reply to Thomas GleixnerQuoted 7 lines · Thomas Gleixner
There is no functional difference.
__get_free_pages()ends up callingalloc_pages_node().This also allocates only one page which matches
THREAD_SIZEinstead of an extra page for nothing.Signed-off-by Thomas Gleixner <[email protected]>
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]
PATCH 8/18 frv: Use common threadinfo allocator
In reply to Thomas GleixnerThe core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/frv/include/asm/thread_info.h | 13 ------------- 1 file changed, 13 deletions(-)
arch/frv/include/asm/thread_info.h +0 -13
@@ -80,19 +80,6 @@ register struct thread_info *__current_t#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_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#endif /* __ASSEMBLY__ */ /*
[tip:smp/hotplug] frv: Use common threadinfo allocator
Commit-ID: c64872cd0dd5892f4d6f3605ffca36d13e63443d Gitweb: http://git.kernel.org/tip/c64872cd0dd5892f4d6f3605ffca36d13e63443d Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:43 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:44 +0200
frv: Use common threadinfo allocator
The core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/frv/include/asm/thread_info.h | 13 ------------- 1 files changed, 0 insertions(+), 13 deletions(-)
arch/frv/include/asm/thread_info.h +0 -13
@@ -80,19 +80,6 @@ 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_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#endif /* __ASSEMBLY__ */ /*
PATCH 9/18 hexagon: Use common threadinfo allocator
In reply to Thomas GleixnerThe core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/hexagon/include/asm/thread_info.h | 8 ------- arch/hexagon/kernel/process.c | 37 --------------------------------- 2 files changed, 45 deletions(-)
arch/hexagon/include/asm/thread_info.h +0 -8
@@ -31,15 +31,7 @@#define THREAD_SHIFT 12#define THREAD_SIZE (1<<THREAD_SHIFT) - -#if THREAD_SHIFT >=PAGE_SHIFT #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) -#else /* don't use standard allocator */ -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti); -#endif -#ifndef __ASSEMBLY__
arch/hexagon/kernel/process.c +0 -37
@@ -234,43 +234,6 @@ unsigned long get_wchan(struct task_stru }/* -* Borrowed from PowerPC -- basically allow smaller kernel stacks if we -* go crazy with the page sizes. -*/ -#if THREAD_SHIFT <PAGE_SHIFT - -static struct kmem_cache *thread_info_cache; - -struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) -{ -struct thread_info *ti; - - ti =kmem_cache_alloc_node (thread_info_cache,GFP_KERNEL , node); -if (unlikely (ti ==NULL )) -return NULL ; -#ifdef CONFIG_DEBUG_STACK_USAGE -memset (ti,0 ,THREAD_SIZE ); -#endif -return ti; -} - -void free_thread_info (struct thread_info *ti) -{ -kmem_cache_free (thread_info_cache, ti); -} - -/* Weak symbol; called by init/main.c */ - -void thread_info_cache_init (void ) -{ - thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , -THREAD_SIZE ,0 ,NULL ); -BUG_ON (thread_info_cache ==NULL ); -} - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ - -/* * Required placeholder. */ int dump_fpu (struct pt_regs *regs,elf_fpregset_t *fpu)
[tip:smp/hotplug] hexagon: Use common threadinfo allocator
Commit-ID: fe844052bca4355bf1a1b078d3e7727800cf3c73 Gitweb: http://git.kernel.org/tip/fe844052bca4355bf1a1b078d3e7727800cf3c73 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:44 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
hexagon: Use common threadinfo allocator
The core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/hexagon/include/asm/thread_info.h | 8 ------- arch/hexagon/kernel/process.c | 37 -------------------------------- 2 files changed, 0 insertions(+), 45 deletions(-)
arch/hexagon/include/asm/thread_info.h +0 -8
@@ -31,15 +31,7 @@#define THREAD_SHIFT 12#define THREAD_SIZE (1<<THREAD_SHIFT) - -#if THREAD_SHIFT >=PAGE_SHIFT #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) -#else /* don't use standard allocator */ -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti); -#endif -#ifndef __ASSEMBLY__
arch/hexagon/kernel/process.c +0 -37
@@ -234,43 +234,6 @@ unsigned long get_wchan(struct task_struct *p) }/* -* Borrowed from PowerPC -- basically allow smaller kernel stacks if we -* go crazy with the page sizes. -*/ -#if THREAD_SHIFT <PAGE_SHIFT - -static struct kmem_cache *thread_info_cache; - -struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) -{ -struct thread_info *ti; - - ti =kmem_cache_alloc_node (thread_info_cache,GFP_KERNEL , node); -if (unlikely (ti ==NULL )) -return NULL ; -#ifdef CONFIG_DEBUG_STACK_USAGE -memset (ti,0 ,THREAD_SIZE ); -#endif -return ti; -} - -void free_thread_info (struct thread_info *ti) -{ -kmem_cache_free (thread_info_cache, ti); -} - -/* Weak symbol; called by init/main.c */ - -void thread_info_cache_init (void ) -{ - thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , -THREAD_SIZE ,0 ,NULL ); -BUG_ON (thread_info_cache ==NULL ); -} - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ - -/* * Required placeholder. */ int dump_fpu (struct pt_regs *regs,elf_fpregset_t *fpu)
PATCH 10/18 m32r: Use common threadinfo allocator
In reply to Thomas GleixnerNo reason why m32r needs to use kmalloc to allocate 2 pages instead of using the core allocator.
--- arch/m32r/include/asm/thread_info.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
arch/m32r/include/asm/thread_info.h +2 -15
@@ -55,8 +55,8 @@ struct thread_info {#define PREEMPT_ACTIVE 0x10000000 -#define THREAD_SIZE (PAGE_SIZE << 1) - +#define THREAD_SIZE (PAGE_SIZE << 1) +#define THREAD_SIZE_ORDER 1/* * macros/functions for gaining access to the thread information structure */
@@ -92,19 +92,6 @@ static inline struct thread_info *currenreturn ti; } -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#define TI_FLAG_FAULT_CODE_SHIFT 28static inline void set_thread_fault_code (unsigned int val)
[tip:smp/hotplug] m32r: Use common threadinfo allocator
Commit-ID: e6e9c540d5d177e7a40d8b40a3b2386bdefbe5da Gitweb: http://git.kernel.org/tip/e6e9c540d5d177e7a40d8b40a3b2386bdefbe5da Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:44 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
m32r: Use common threadinfo allocator
No reason why m32r needs to use kmalloc to allocate 2 pages instead of using the core allocator.
--- arch/m32r/include/asm/thread_info.h | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
arch/m32r/include/asm/thread_info.h +2 -15
@@ -55,8 +55,8 @@ struct thread_info {#define PREEMPT_ACTIVE 0x10000000 -#define THREAD_SIZE (PAGE_SIZE << 1) - +#define THREAD_SIZE (PAGE_SIZE << 1) +#define THREAD_SIZE_ORDER 1/* * macros/functions for gaining access to the thread information structure */
@@ -92,19 +92,6 @@ 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_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#define TI_FLAG_FAULT_CODE_SHIFT 28static inline void set_thread_fault_code (unsigned int val)
PATCH 11/18 mips: Use common threadinfo allocator
In reply to Thomas GleixnerNo point in using kmalloc for allocating 0, 1 resp. 2 pages for threadinfo.
--- arch/mips/include/asm/thread_info.h | 12 ------------ 1 file changed, 12 deletions(-)
arch/mips/include/asm/thread_info.h +0 -12
@@ -85,18 +85,6 @@ register struct thread_info *__current_t#define STACK_WARN (THREAD_SIZE / 8) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#endif /* !__ASSEMBLY__ */ #define PREEMPT_ACTIVE 0x10000000
[tip:smp/hotplug] mips: Use common threadinfo allocator
Commit-ID: 3194f61de93d4d4fbc2f2ddb25aeded6f9cebaeb Gitweb: http://git.kernel.org/tip/3194f61de93d4d4fbc2f2ddb25aeded6f9cebaeb Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:44 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
mips: Use common threadinfo allocator
No point in using kmalloc for allocating 0, 1 resp. 2 pages for threadinfo.
--- arch/mips/include/asm/thread_info.h | 12 ------------ 1 files changed, 0 insertions(+), 12 deletions(-)
arch/mips/include/asm/thread_info.h +0 -12
@@ -85,18 +85,6 @@ register struct thread_info *__current_thread_info __asm__("$28");#define STACK_WARN (THREAD_SIZE / 8) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif - -#define free_thread_info (info) kfree(info) -#endif /* !__ASSEMBLY__ */ #define PREEMPT_ACTIVE 0x10000000
PATCH 12/18 mn10300: Use common threadinfo allocator
In reply to Thomas GleixnerLet the core code allocate and handle the kgdb cleanup with the arch_release_thread_info() function.
--- arch/mn10300/include/asm/thread_info.h | 17 +++-------------- arch/mn10300/kernel/kgdb.c | 3 +-- 2 files changed, 4 insertions(+), 16 deletions(-)
arch/mn10300/include/asm/thread_info.h +3 -14
@@ -20,8 +20,10 @@#ifdef CONFIG_4KSTACKS #define THREAD_SIZE (4096) +#define THREAD_SIZE_ORDER (0)#else #define THREAD_SIZE (8192) +#define THREAD_SIZE_ORDER (1)#endif #define STACK_WARN (THREAD_SIZE / 8)
@@ -120,21 +122,8 @@ static inline unsigned long current_stacreturn sp; } -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -/* thread information allocation */ -#ifdef CONFIG_DEBUG_STACK_USAGE -#define alloc_thread_info_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif -#ifndef CONFIG_KGDB -#define free_thread_info (ti) kfree((ti)) -#else -extern void free_thread_info (struct thread_info *); +void arch_release_thread_info(struct thread_info *ti)#endif #define get_thread_info (ti) get_task_struct((ti)->task)#define put_thread_info (ti) put_task_struct((ti)->task)
arch/mn10300/kernel/kgdb.c +1 -2
@@ -397,7 +397,7 @@ static bool kgdb_arch_undo_singlestep(st* single-step state is cleared. At this point the breakpoints should have * been removed by __switch_to(). */ -void free_thread_info (struct thread_info *ti) +void arch_release_thread_info (struct thread_info *ti) {if (kgdb_sstep_thread == ti) { kgdb_sstep_thread =NULL ;
@@ -407,7 +407,6 @@ void free_thread_info(struct thread_info* so force immediate reentry */ kgdb_breakpoint (); } -kfree (ti); }/*
[tip:smp/hotplug] mn10300: Use common threadinfo allocator
Commit-ID: c03a6a7ba6f456663e4b254cdde460b24c0852e1 Gitweb: http://git.kernel.org/tip/c03a6a7ba6f456663e4b254cdde460b24c0852e1 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:45 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
mn10300: Use common threadinfo allocator
Let the core code allocate and handle the kgdb cleanup with the arch_release_thread_info() function.
--- arch/mn10300/include/asm/thread_info.h | 17 +++-------------- arch/mn10300/kernel/kgdb.c | 3 +-- 2 files changed, 4 insertions(+), 16 deletions(-)
arch/mn10300/include/asm/thread_info.h +3 -14
@@ -20,8 +20,10 @@#ifdef CONFIG_4KSTACKS #define THREAD_SIZE (4096) +#define THREAD_SIZE_ORDER (0)#else #define THREAD_SIZE (8192) +#define THREAD_SIZE_ORDER (1)#endif #define STACK_WARN (THREAD_SIZE / 8)
@@ -120,21 +122,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_node (tsk, node) \ - kzalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#else -#define alloc_thread_info_node (tsk, node) \ - kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#endif -#ifndef CONFIG_KGDB -#define free_thread_info (ti) kfree((ti)) -#else -extern void free_thread_info (struct thread_info *); +void arch_release_thread_info(struct thread_info *ti)#endif #define get_thread_info (ti) get_task_struct((ti)->task)#define put_thread_info (ti) put_task_struct((ti)->task)
arch/mn10300/kernel/kgdb.c +1 -2
@@ -397,7 +397,7 @@ static bool kgdb_arch_undo_singlestep(struct pt_regs *regs)* single-step state is cleared. At this point the breakpoints should have * been removed by __switch_to(). */ -void free_thread_info (struct thread_info *ti) +void arch_release_thread_info (struct thread_info *ti) {if (kgdb_sstep_thread == ti) { kgdb_sstep_thread =NULL ;
@@ -407,7 +407,6 @@ void free_thread_info(struct thread_info *ti)* so force immediate reentry */ kgdb_breakpoint (); } -kfree (ti); }/*
PATCH 13/18 powerpc: Use common threadinfo allocator
In reply to Thomas GleixnerThe core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/powerpc/include/asm/thread_info.h | 13 ------------- arch/powerpc/kernel/process.c | 31 ------------------------------- 2 files changed, 44 deletions(-)
arch/powerpc/include/asm/thread_info.h +0 -13
@@ -62,21 +62,8 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info)#define init_stack (init_thread_union.stack) -/* thread information allocation */ - -#if THREAD_SHIFT >=PAGE_SHIFT -#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_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti); - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ -/* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info (void ) {
arch/powerpc/kernel/process.c +0 -31
@@ -1252,37 +1252,6 @@ void __ppc64_runlatch_off(void) }#endif /* CONFIG_PPC64 */ -#if THREAD_SHIFT <PAGE_SHIFT - -static struct kmem_cache *thread_info_cache; - -struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) -{ -struct thread_info *ti; - - ti =kmem_cache_alloc_node (thread_info_cache,GFP_KERNEL , node); -if (unlikely (ti ==NULL )) -return NULL ; -#ifdef CONFIG_DEBUG_STACK_USAGE -memset (ti,0 ,THREAD_SIZE ); -#endif -return ti; -} - -void free_thread_info (struct thread_info *ti) -{ -kmem_cache_free (thread_info_cache, ti); -} - -void thread_info_cache_init (void ) -{ - thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , -THREAD_SIZE ,0 ,NULL ); -BUG_ON (thread_info_cache ==NULL ); -} - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ -unsigned long arch_align_stack (unsigned long sp) {if (!(current->personality &ADDR_NO_RANDOMIZE ) && randomize_va_space)
[tip:smp/hotplug] powerpc: Use common threadinfo allocator
Commit-ID: 96c951179736eb59c5f66de2ac85af9e7a6a8b15 Gitweb: http://git.kernel.org/tip/96c951179736eb59c5f66de2ac85af9e7a6a8b15 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:45 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
powerpc: Use common threadinfo allocator
The core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
--- arch/powerpc/include/asm/thread_info.h | 13 ------------- arch/powerpc/kernel/process.c | 31 ------------------------------- 2 files changed, 0 insertions(+), 44 deletions(-)
arch/powerpc/include/asm/thread_info.h +0 -13
@@ -62,21 +62,8 @@ struct thread_info {#define init_thread_info (init_thread_union.thread_info)#define init_stack (init_thread_union.stack) -/* thread information allocation */ - -#if THREAD_SHIFT >=PAGE_SHIFT -#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_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti); - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ -/* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info (void ) {
arch/powerpc/kernel/process.c +0 -31
@@ -1252,37 +1252,6 @@ void __ppc64_runlatch_off(void) }#endif /* CONFIG_PPC64 */ -#if THREAD_SHIFT <PAGE_SHIFT - -static struct kmem_cache *thread_info_cache; - -struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node) -{ -struct thread_info *ti; - - ti =kmem_cache_alloc_node (thread_info_cache,GFP_KERNEL , node); -if (unlikely (ti ==NULL )) -return NULL ; -#ifdef CONFIG_DEBUG_STACK_USAGE -memset (ti,0 ,THREAD_SIZE ); -#endif -return ti; -} - -void free_thread_info (struct thread_info *ti) -{ -kmem_cache_free (thread_info_cache, ti); -} - -void thread_info_cache_init (void ) -{ - thread_info_cache =kmem_cache_create ("thread_info" ,THREAD_SIZE , -THREAD_SIZE ,0 ,NULL ); -BUG_ON (thread_info_cache ==NULL ); -} - -#endif /* THREAD_SHIFT < PAGE_SHIFT */ -unsigned long arch_align_stack (unsigned long sp) {if (!(current->personality &ADDR_NO_RANDOMIZE ) && randomize_va_space)
PATCH 14/18 score: Use common threadinfo allocator
In reply to Thomas GleixnerNo point in using kmalloc for allocating 2 pages.
--- arch/score/include/asm/thread_info.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/score/include/asm/thread_info.h +3 -7
@@ -11,10 +11,9 @@#include <linux/const.h> /* thread information allocation */ -#define THREAD_SIZE_ORDER (1) -#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) -#define THREAD_MASK (THREAD_SIZE - _AC(1,UL)) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR +#define THREAD_SIZE_ORDER (1) +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) +#define THREAD_MASK (THREAD_SIZE - _AC(1,UL))#ifndef __ASSEMBLY__
@@ -71,9 +70,6 @@ struct thread_info { registerstruct thread_info *__current_thread_info __asm__("r28" );#define current_thread_info () __current_thread_info -#define alloc_thread_info_node (tsk, node) kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#define free_thread_info (info) kfree(info) -#endif /* !__ASSEMBLY__ */ #define PREEMPT_ACTIVE 0x10000000
[tip:smp/hotplug] score: Use common threadinfo allocator
Commit-ID: c4e26890ff4cb4e85969b1e8565af4b046ce03b8 Gitweb: http://git.kernel.org/tip/c4e26890ff4cb4e85969b1e8565af4b046ce03b8 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:46 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:46 +0200
score: Use common threadinfo allocator
No point in using kmalloc for allocating 2 pages.
--- arch/score/include/asm/thread_info.h | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
arch/score/include/asm/thread_info.h +3 -7
@@ -11,10 +11,9 @@#include <linux/const.h> /* thread information allocation */ -#define THREAD_SIZE_ORDER (1) -#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) -#define THREAD_MASK (THREAD_SIZE - _AC(1,UL)) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR +#define THREAD_SIZE_ORDER (1) +#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) +#define THREAD_MASK (THREAD_SIZE - _AC(1,UL))#ifndef __ASSEMBLY__
@@ -71,9 +70,6 @@ struct thread_info { registerstruct thread_info *__current_thread_info __asm__("r28" );#define current_thread_info () __current_thread_info -#define alloc_thread_info_node (tsk, node) kmalloc_node(THREAD_SIZE, GFP_KERNEL, node) -#define free_thread_info (info) kfree(info) -#endif /* !__ASSEMBLY__ */ #define PREEMPT_ACTIVE 0x10000000
PATCH 15/18 sh: Use common threadinfo allocator
In reply to Thomas GleixnerThe core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
Deal with the xstate cleanup in the new arch_release_task_struct() function.
--- arch/sh/include/asm/thread_info.h | 10 -------- arch/sh/kernel/process.c | 46 +------------------------------------- 2 files changed, 3 insertions(+), 53 deletions(-)
arch/sh/include/asm/thread_info.h +1 -9
@@ -88,21 +88,13 @@ static inline struct thread_info *curren return ti; } -/* thread information allocation */ -#if THREAD_SHIFT >=PAGE_SHIFT -#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) -#endif - -extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti);extern void arch_task_cache_init (void );extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern void arch_release_task_struct (struct task_struct *tsk);extern void init_thread_xstate (void ); -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -#endif /* __ASSEMBLY__ */ /*
arch/sh/kernel/process.c +2 -44
54 lines not on this page · raw message
[tip:smp/hotplug] sh-use-common-threadinfo-allocator
Commit-ID: df9a7b9b5d1a5ef8cd3474d0cea2c6428542e288 Gitweb: http://git.kernel.org/tip/df9a7b9b5d1a5ef8cd3474d0cea2c6428542e288 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:46 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:45 +0200
sh-use-common-threadinfo-allocator
The core now has a threadinfo allocator which uses a kmemcache when THREAD_SIZE < PAGE_SIZE.
Deal with the xstate cleanup in the new arch_release_task_struct() function.
--- arch/sh/include/asm/thread_info.h | 10 +------- arch/sh/kernel/process.c | 46 +----------------------------------- 2 files changed, 3 insertions(+), 53 deletions(-)
arch/sh/include/asm/thread_info.h +1 -9
@@ -88,21 +88,13 @@ static inline struct thread_info *current_thread_info(void) return ti; } -/* thread information allocation */ -#if THREAD_SHIFT >=PAGE_SHIFT -#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) -#endif - -extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node); -extern void free_thread_info (struct thread_info *ti);extern void arch_task_cache_init (void );extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern void arch_release_task_struct (struct task_struct *tsk);extern void init_thread_xstate (void ); -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -#endif /* __ASSEMBLY__ */ /*
arch/sh/kernel/process.c +2 -44
54 lines not on this page · raw message
PATCH 16/18 sparc: Use common threadinfo allocator
In reply to Thomas GleixnerExaclty the same as the core code.
--- arch/sparc/include/asm/thread_info_64.h | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
arch/sparc/include/asm/thread_info_64.h +2 -23
@@ -138,32 +138,11 @@ register struct thread_info *current_thr/* thread information allocation */ #if PAGE_SHIFT ==13 -#define __THREAD_INFO_ORDER 1 +#define THREAD_SIZE_ORDER 1#else /* PAGE_SHIFT == 13 */ -#define __THREAD_INFO_ORDER 0 +#define THREAD_SIZE_ORDER 0#endif /* PAGE_SHIFT == 13 */ -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL) -#endif - -#define alloc_thread_info_node (tsk, node) \ -({ \ - struct page *page = alloc_pages_node(node, THREAD_FLAGS, \ - __THREAD_INFO_ORDER); \ - struct thread_info *ret; \ - \ - ret = page ? page_address(page) : NULL; \ - ret; \ -}) - -#define free_thread_info (ti) \ - free_pages((unsigned long)(ti),__THREAD_INFO_ORDER) -#define __thread_flag_byte_ptr (ti) \ ((unsigned char *)(&((ti)->flags)))#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
Re: [patch 16/18] sparc: Use common threadinfo allocator
From: Thomas Gleixner <[email protected]>
Date: Sat, 05 May 2012 15:05:47 -0000
Quoted 3 lines
Exaclty the same as the core code.
Signed-off-by Thomas Gleixner <[email protected]>
[tip:smp/hotplug] sparc: Use common threadinfo allocator
In reply to Thomas GleixnerCommit-ID: 66bb4cda55477efeb1be5c2cbd3785a69b088a8a Gitweb: http://git.kernel.org/tip/66bb4cda55477efeb1be5c2cbd3785a69b088a8a Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:47 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:46 +0200
sparc: Use common threadinfo allocator
Exaclty the same as the core code.
--- arch/sparc/include/asm/thread_info_64.h | 25 ++----------------------- 1 files changed, 2 insertions(+), 23 deletions(-)
arch/sparc/include/asm/thread_info_64.h +2 -23
@@ -138,32 +138,11 @@ register struct thread_info *current_thread_info_reg asm("g6");/* thread information allocation */ #if PAGE_SHIFT ==13 -#define __THREAD_INFO_ORDER 1 +#define THREAD_SIZE_ORDER 1#else /* PAGE_SHIFT == 13 */ -#define __THREAD_INFO_ORDER 0 +#define THREAD_SIZE_ORDER 0#endif /* PAGE_SHIFT == 13 */ -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - -#ifdef CONFIG_DEBUG_STACK_USAGE -#define THREAD_FLAGS (GFP_KERNEL | __GFP_ZERO) -#else -#define THREAD_FLAGS (GFP_KERNEL) -#endif - -#define alloc_thread_info_node (tsk, node) \ -({ \ - struct page *page = alloc_pages_node(node, THREAD_FLAGS, \ - __THREAD_INFO_ORDER); \ - struct thread_info *ret; \ - \ - ret = page ? page_address(page) : NULL; \ - ret; \ -}) - -#define free_thread_info (ti) \ - free_pages((unsigned long)(ti),__THREAD_INFO_ORDER) -#define __thread_flag_byte_ptr (ti) \ ((unsigned char *)(&((ti)->flags)))#define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
PATCH 17/18 tile: Use common threadinfo allocator
In reply to Thomas GleixnerUse the core allocator and deal with the extra cleanup in arch_release_thread_info().
--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)
arch/tile/include/asm/thread_info.h +2 -4
@@ -77,16 +77,14 @@ struct thread_info {#ifndef __ASSEMBLY__ +void arch_release_thread_info (struct thread_info *info); +/* How to get the thread information struct from C. */ registerunsigned long stack_pointer __asm__("sp" );#define current_thread_info () \ ((struct thread_info *)(stack_pointer & -THREAD_SIZE)) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -extern struct thread_info *alloc_thread_info_node (struct task_struct *task,int node); -extern void free_thread_info (struct thread_info *info); -/* Sit on a nap instruction until interrupted. */ extern void smp_nap (void );
arch/tile/kernel/process.c +2 -21
@@ -114,27 +114,10 @@ void cpu_idle(void) } } -struct thread_info *alloc_thread_info_node (struct task_struct *task,int node) -{ -struct page *page; -gfp_t flags =GFP_KERNEL ; - -#ifdef CONFIG_DEBUG_STACK_USAGE - flags |= __GFP_ZERO; -#endif - - page =alloc_pages_node (node, flags,THREAD_SIZE_ORDER ); -if (!page) -return NULL ; - -return (struct thread_info *)page_address (page); -} -/* -* Free a thread_info node, and all of its derivative -* data structures. +* Release a thread_info structure */ -void free_thread_info (struct thread_info *info) +void arch_release_thread_info (struct thread_info *info) {struct single_step_state *step_state = info->step_state;
@@ -169,8 +152,6 @@ void free_thread_info(struct thread_info*/ kfree (step_state); } - -free_pages ((unsigned long )info,THREAD_SIZE_ORDER ); }static void save_arch_state (struct thread_struct *t);
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 9 lines · Thomas Gleixner
Use the core allocator and deal with the extra cleanup in
arch_release_thread_info().Signed-off-by Thomas Gleixner <[email protected]>Cc Chris Metcalf <[email protected]>--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)
We have some changes we haven't yet merged upstream that this will likely conflict with.
You may note that we have APIs like homecache_alloc_pages() that take a core or other magic value to indicate what the "home" cache should be on our architecture. This enables significant performance optimizations when you can co-locate the home cache with where most of the core references are coming from.
The additional changes we haven't yet merged are in the area of managing the home cache dynamically. Rather than just setting the home cache at allocation time, we allow it to be modified dynamically: for example, as the process migrates, we migrate the kernel and user stack pages. This is tricky since there are lots of coherence issues to manage, and the changes we have include a variety of changes in the core mm code to handle transitioning the home cache, proper locking, unmapping, hooks in the buddy allocator, blocking other cores while a page is transitioning, etc etc.
But, the relevance to this change is that as part of that code, we use the homecache_alloc_page() method to set the home cache of a kernel stack page to be the core that is running the thread (and then migrate the home cache dynamically after that). Using the new proposed core allocator will mean we lose that hook. We don't need a free hook (when we're using the dynamic mode we are already hooked into the allocator itself), but we do need a way to know when we're allocating a kernel stack page as opposed to any other kind of a page.
The simplest approach is of course just to allow __HAVE_ARCH_THREAD_INFO_ALLOCATOR to continue to be meaningful and use it for tile, but maybe there's some halfway point. For example, that symbol could refer only to the allocate function, and not also imply an arch-specific free function. Or, we could have a new much more focused override that was just "a function to use instead of alloc_pages_node", e.g. provide a weak alloc_threadinfo_pages_node() that just was generically just a call to alloc_pages_node, which architectures could override.
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 29 lines · Chris Metcalf
Quoted 9 lines · Thomas Gleixner
Use the core allocator and deal with the extra cleanup in
arch_release_thread_info().Signed-off-by Thomas Gleixner <[email protected]>Cc Chris Metcalf <[email protected]>--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)We have some changes we haven't yet merged upstream that this will likely conflict with.
You may note that we have APIs like
homecache_alloc_pages()that take a core or other magic value to indicate what the "home" cache should be on our architecture. This enables significant performance optimizations when you can co-locate the home cache with where most of the core references are coming from.The additional changes we haven't yet merged are in the area of managing the home cache dynamically. Rather than just setting the home cache at allocation time, we allow it to be modified dynamically: for example, as the process migrates, we migrate the kernel and user stack pages. This is tricky since there are lots of coherence issues to manage, and the changes we have include a variety of changes in the core mm code to handle transitioning the home cache, proper locking, unmapping, hooks in the buddy allocator, blocking other cores while a page is transitioning, etc etc.
Quoted 8 lines
But, the relevance to this change is that as part of that code, we use the
homecache_alloc_page()method to set the home cache of a kernel stack page to be the core that is running the thread (and then migrate the home cache dynamically after that). Using the new proposed core allocator will mean we lose that hook. We don't need a free hook (when we're using the dynamic mode we are already hooked into the allocator itself), but we do need a way to know when we're allocating a kernel stack page as opposed to any other kind of a page.
What's the difference between a kernel stack page for a given node and a page which is allocated on a given node ?
Quoted 8 lines
The simplest approach is of course just to allow
__HAVE_ARCH_THREAD_INFO_ALLOCATORto continue to be meaningful and use it for tile, but maybe there's some halfway point. For example, that symbol could refer only to the allocate function, and not also imply an arch-specific free function. Or, we could have a new much more focused override that was just "a function to use instead ofalloc_pages_node", e.g. provide a weakalloc_threadinfo_pages_node()that just was generically just a call toalloc_pages_node, which architectures could override.
Again, that would give you what?
If you treat kernel stack pages different to general pages allocated on a node then why not using a special GFP flag for that purpose?
Thanks,
tglx
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 38 lines · Thomas Gleixner
Quoted 28 lines · Chris Metcalf
Quoted 9 lines · Thomas Gleixner
Use the core allocator and deal with the extra cleanup in
arch_release_thread_info().Signed-off-by Thomas Gleixner <[email protected]>Cc Chris Metcalf <[email protected]>--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)We have some changes we haven't yet merged upstream that this will likely conflict with.
You may note that we have APIs like
homecache_alloc_pages()that take a core or other magic value to indicate what the "home" cache should be on our architecture. This enables significant performance optimizations when you can co-locate the home cache with where most of the core references are coming from.The additional changes we haven't yet merged are in the area of managing the home cache dynamically. Rather than just setting the home cache at allocation time, we allow it to be modified dynamically: for example, as the process migrates, we migrate the kernel and user stack pages. This is tricky since there are lots of coherence issues to manage, and the changes we have include a variety of changes in the core mm code to handle transitioning the home cache, proper locking, unmapping, hooks in the buddy allocator, blocking other cores while a page is transitioning, etc etc.
Quoted 8 lines
But, the relevance to this change is that as part of that code, we use the
homecache_alloc_page()method to set the home cache of a kernel stack page to be the core that is running the thread (and then migrate the home cache dynamically after that). Using the new proposed core allocator will mean we lose that hook. We don't need a free hook (when we're using the dynamic mode we are already hooked into the allocator itself), but we do need a way to know when we're allocating a kernel stack page as opposed to any other kind of a page.
Quoted 2 lines
What's the difference between a kernel stack page for a given node and a page which is allocated on a given node ?
No difference except in how it is allocated (and of course how it is used). The task migration code currently knows that the kernel stack should have its home cache migrated; it finds it by VA. In the absence of migration the kernel stack page is not treated differently than any other page_alloc'ed page.
Quoted 9 lines
Quoted 8 lines
The simplest approach is of course just to allow
__HAVE_ARCH_THREAD_INFO_ALLOCATORto continue to be meaningful and use it for tile, but maybe there's some halfway point. For example, that symbol could refer only to the allocate function, and not also imply an arch-specific free function. Or, we could have a new much more focused override that was just "a function to use instead ofalloc_pages_node", e.g. provide a weakalloc_threadinfo_pages_node()that just was generically just a call toalloc_pages_node, which architectures could override.Again, that would give you what?
The advantage is that when you initially allocate the stack page, you can set its home cache appropriately to be on the local cpu, where the new task is likely to run. Otherwise, you could imagine using a suitable hook for when the task starts up to migrate the page at that point, but you miss out on the opportunity to have the allocator return a suitably-cached page up front when the task is created.
Quoted 2 lines
If you treat kernel stack pages different to general pages allocated on a node then why not using a special GFP flag for that purpose?
There are certainly different possible ways to tell the allocator to allocate a page with its cache "here" vs with its cache fully-distributed (and thus less local, and less good for stack or percpu pages). We use a different approach (some per-task data structures that pass homing info to the allocator) but we could probably use GFP_ values instead. But the point is we need to be able to know to do so, and I think the only obvious way is to override something in the threadinfo allocator.
Thanks!
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 30 lines · Chris Metcalf
Quoted 2 lines · Thomas Gleixner
What's the difference between a kernel stack page for a given node and a page which is allocated on a given node ?
No difference except in how it is allocated (and of course how it is used). The task migration code currently knows that the kernel stack should have its home cache migrated; it finds it by VA. In the absence of migration the kernel stack page is not treated differently than any other page_alloc'ed page.
Quoted 9 lines
Quoted 8 lines
The simplest approach is of course just to allow
__HAVE_ARCH_THREAD_INFO_ALLOCATORto continue to be meaningful and use it for tile, but maybe there's some halfway point. For example, that symbol could refer only to the allocate function, and not also imply an arch-specific free function. Or, we could have a new much more focused override that was just "a function to use instead ofalloc_pages_node", e.g. provide a weakalloc_threadinfo_pages_node()that just was generically just a call toalloc_pages_node, which architectures could override.Again, that would give you what?
The advantage is that when you initially allocate the stack page, you can set its home cache appropriately to be on the local cpu, where the new task is likely to run. Otherwise, you could imagine using a suitable hook for when the task starts up to migrate the page at that point, but you miss out on the opportunity to have the allocator return a suitably-cached page up front when the task is created.
Quoted 2 lines
If you treat kernel stack pages different to general pages allocated on a node then why not using a special GFP flag for that purpose?
Quoted 7 lines
There are certainly different possible ways to tell the allocator to allocate a page with its cache "here" vs with its cache fully-distributed (and thus less local, and less good for stack or percpu pages). We use a different approach (some per-task data structures that pass homing info to the allocator) but we could probably use
GFP_values instead. But the point is we need to be able to know to do so, and I think the only obvious way is to override something in the threadinfo allocator.
Wrong. The obvious way is to use the common code and add a special flag to it.
There is nothing wrong to add
#ifndef ARCH_THREADINFO_GFP
#define ARCH_THREADINFO_GFP (0)
#endif
and or ARCH_THREADINFO_GFP to the generic THREADINFO_GFP flags
instead of insisting on a separate allocator function for something which has no fricking reason to be arch specific (IA64 and some weird sparc crap aside)
Thanks,
tglx
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Chris Metcalf
I think the only obvious
way is to override something in the threadinfo allocator.Wrong. The obvious way is to use the common code and add a special flag to it.
Well, that's overriding something in the threadinfo allocator :-)
In all seriousness, adding an arch-specific GFP flag sounds like it should work OK for tile. Thanks!
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
Re: [patch 17/18] tile: Use common threadinfo allocator
Quoted 5 lines · Chris Metcalf
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines · Chris Metcalf
I think the only obvious
way is to override something in the threadinfo allocator.
Quoted 7 lines
Quoted 2 lines
Wrong. The obvious way is to use the common code and add a special flag to it.
Well, that's overriding something in the threadinfo allocator :-)
In all seriousness, adding an arch-specific GFP flag sounds like it should work OK for tile. Thanks!
I pushed out the minimum set of patches into a separate branch, so you can base your work on that and we wont run into merge order dependencies.
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp/threadinfo
The patch below lets you define your extra gfp flag for tile.
Thanks,
tglx
-------->
Subject: threadinfo: Add an optional ARCH gfp flag for the threadinfo allocator
Allows architectures to add their magic gfp flags.
include/linux/thread_info.h +8 -2
@@ -55,11 +55,17 @@ extern long do_no_restart_syscall(struct#ifdef __KERNEL__#ifdef CONFIG_DEBUG_STACK_USAGE -# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) +# define __THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)#else -# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK) +# define __THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK)#endif +#ifndef ARCH_THREAD_INFO_GFP +# define ARCH_THREAD_INFO_GFP (0) +#endif + +#define THREADINFO_GFP (__THREADINFO_GFP | ARCH_THREAD_INFO_GFP) +/* * flag set/clear/test wrappers * - pass TIF_xxxx constants to these functions
[tip:smp/hotplug] tile: Use common threadinfo allocator
In reply to Thomas GleixnerCommit-ID: d909a81b198a397593495508c4a5755fe95552fb Gitweb: http://git.kernel.org/tip/d909a81b198a397593495508c4a5755fe95552fb Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:47 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 13:55:20 +0200
tile: Use common threadinfo allocator
Use the core allocator and deal with the extra cleanup in arch_release_thread_info().
--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)
arch/tile/include/asm/thread_info.h +2 -4
@@ -77,16 +77,14 @@ struct thread_info {#ifndef __ASSEMBLY__ +void arch_release_thread_info (struct thread_info *info); +/* How to get the thread information struct from C. */ registerunsigned long stack_pointer __asm__("sp" );#define current_thread_info () \ ((struct thread_info *)(stack_pointer & -THREAD_SIZE)) -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR -extern struct thread_info *alloc_thread_info_node (struct task_struct *task,int node); -extern void free_thread_info (struct thread_info *info); -/* Sit on a nap instruction until interrupted. */ extern void smp_nap (void );
arch/tile/kernel/process.c +2 -21
@@ -114,27 +114,10 @@ void cpu_idle(void) } } -struct thread_info *alloc_thread_info_node (struct task_struct *task,int node) -{ -struct page *page; -gfp_t flags =GFP_KERNEL ; - -#ifdef CONFIG_DEBUG_STACK_USAGE - flags |= __GFP_ZERO; -#endif - - page =alloc_pages_node (node, flags,THREAD_SIZE_ORDER ); -if (!page) -return NULL ; - -return (struct thread_info *)page_address (page); -} -/* -* Free a thread_info node, and all of its derivative -* data structures. +* Release a thread_info structure */ -void free_thread_info (struct thread_info *info) +void arch_release_thread_info (struct thread_info *info) {struct single_step_state *step_state = info->step_state;
@@ -169,8 +152,6 @@ void free_thread_info(struct thread_info *info)*/ kfree (step_state); } - -free_pages ((unsigned long )info,THREAD_SIZE_ORDER ); }static void save_arch_state (struct thread_struct *t);
Chris Metcalf
Acked-byRe: [tip:smp/hotplug] tile: Use common threadinfo allocator
Quoted 12 lines · tip-bot for Thomas Gleixner
Commit-ID: d909a81b198a397593495508c4a5755fe95552fb Gitweb: http://git.kernel.org/tip/d909a81b198a397593495508c4a5755fe95552fb Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:47 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 13:55:20 +0200tile: Use common threadinfo allocator
Use the core allocator and deal with the extra cleanup in
arch_release_thread_info().
Quoted 7 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Chris Metcalf <[email protected]>--- arch/tile/include/asm/thread_info.h | 6 ++---- arch/tile/kernel/process.c | 23 ++--------------------- 2 files changed, 4 insertions(+), 25 deletions(-)
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com
PATCH 18/18 task_allocator: Use config switches instead of magic defines
In reply to Thomas GleixnerReplace __HAVE_ARCH_TASK_ALLOCATOR and __HAVE_ARCH_THREAD_ALLOCATOR with proper config switches.
--- arch/Kconfig | 8 ++++++++ arch/ia64/Kconfig | 2 ++ arch/ia64/include/asm/thread_info.h | 3 --- arch/sparc/Kconfig | 1 + arch/sparc/include/asm/thread_info_32.h | 2 -- kernel/fork.c | 7 +++---- 6 files changed, 14 insertions(+), 9 deletions(-)
arch/Kconfig +8 -0
@@ -152,6 +152,14 @@ config GENERIC_SMP_IDLE_THREAD config ARCH_INIT_TASK bool +# Select if arch has its private alloc_task_struct() function +config ARCH_TASK_STRUCT_ALLOCATOR + bool + +# Select if arch has its private alloc_thread_info() function +config ARCH_THREAD_INFO_ALLOCATOR + bool + config HAVE_REGS_AND_STACK_ACCESS_API bool help
arch/ia64/Kconfig +2 -0
@@ -35,6 +35,8 @@ config IA64 select GENERIC_IOMAP select GENERIC_SMP_IDLE_THREAD select ARCH_INIT_TASK + select ARCH_TASK_STRUCT_ALLOCATOR + select ARCH_THREAD_INFO_ALLOCATOR default y help The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/thread_info.h +0 -3
@@ -54,8 +54,6 @@ 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))
@@ -84,7 +82,6 @@ struct thread_info {#endif #define end_of_stack (p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET) -#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR#define alloc_task_struct_node (node) \ ({ \ struct page *page = alloc_pages_node(node, GFP_KERNEL | __GFP_COMP, \
arch/sparc/Kconfig +1 -0
@@ -36,6 +36,7 @@ config SPARC32 def_bool !64BIT select GENERIC_ATOMIC64 select CLZ_TAB + select ARCH_THREAD_INFO_ALLOCATOR config SPARC64 def_bool 64BIT
arch/sparc/include/asm/thread_info_32.h +0 -2
@@ -80,8 +80,6 @@ register struct thread_info *current_thr*/ #define THREAD_INFO_ORDER 1 -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info_node, int)#define alloc_thread_info_node (tsk, node) BTFIXUP_CALL(alloc_thread_info_node)(node)
kernel/fork.c +3 -4
@@ -111,7 +111,7 @@ int nr_processes(void)return total; } -#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR +#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR static struct kmem_cache *task_struct_cachep;static inline struct task_struct *alloc_task_struct_node (int node)
@@ -128,8 +128,7 @@ static inline void free_task_struct(stru }#endif -#ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR - +#ifndef CONFIG_ARCH_THREAD_INFO_ALLOCATOR void __weak arch_release_thread_info (struct thread_info *ti) { }/*
@@ -243,7 +242,7 @@ void __init __weak arch_task_cache_init(void __init fork_init (unsigned long mempages) { -#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR +#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR #ifndef ARCH_MIN_TASKALIGN #define ARCH_MIN_TASKALIGN L1_CACHE_BYTES#endif
Re: [patch 18/18] task_allocator: Use config switches instead of magic defines
Quoted 12 lines · Thomas Gleixner
Replace
__HAVE_ARCH_TASK_ALLOCATORand__HAVE_ARCH_THREAD_ALLOCATORwith proper config switches.Signed-off-by Thomas Gleixner <[email protected]>Cc Sam Ravnborg <[email protected]>Cc Tony Luck <[email protected]>Index:
tip/arch/sparc/include/asm/thread_info_32.h
===================================================================
arch/sparc/include/asm/thread_info_32.h register struct thread_info *current_thr · line 84
Quoted 7 lines
arch/sparc/include/asm/thread_info_32.h +0
-2@@ -80,8 +80,6 @@ register struct thread_info *current_thr*/ #define THREAD_INFO_ORDER 1 -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info_node, int)#define alloc_thread_info_node (tsk, node) BTFIXUP_CALL(alloc_thread_info_node)(node)
On the sparc mailing list we have discussed to drop support for sun4c - and decided to do so. With sun4c dropped sparc32 will be able to use the generic variant too.
I will take care to introduce the generic variant when sparc32 is ready.
Sam
Re: [patch 18/18] task_allocator: Use config switches instead of magic defines
Quoted 26 lines · Sam Ravnborg
Quoted 12 lines · Thomas Gleixner
Replace
__HAVE_ARCH_TASK_ALLOCATORand__HAVE_ARCH_THREAD_ALLOCATORwith proper config switches.Signed-off-by Thomas Gleixner <[email protected]>Cc Sam Ravnborg <[email protected]>Cc Tony Luck <[email protected]>Index:
tip/arch/sparc/include/asm/thread_info_32.h
===================================================================arch/sparc/include/asm/thread_info_32.h register struct thread_info *current_thr · line 84
Quoted 7 lines
arch/sparc/include/asm/thread_info_32.h +0
-2@@ -80,8 +80,6 @@ register struct thread_info *current_thr*/ #define THREAD_INFO_ORDER 1 -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info_node, int)#define alloc_thread_info_node (tsk, node) BTFIXUP_CALL(alloc_thread_info_node)(node)On the sparc mailing list we have discussed to drop support for sun4c - and decided to do so. With sun4c dropped sparc32 will be able to use the generic variant too.
Quoted 2 lines
I will take care to introduce the generic variant when sparc32 is ready.
Nice :)
[tip:smp/hotplug] task_allocator: Use config switches instead of magic defines
In reply to Thomas GleixnerCommit-ID: f5e10287367dcffb5504d19c83e85ca041ca2596 Gitweb: http://git.kernel.org/tip/f5e10287367dcffb5504d19c83e85ca041ca2596 Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 5 May 2012 15:05:48 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 8 May 2012 14:08:46 +0200
task_allocator: Use config switches instead of magic defines
Replace __HAVE_ARCH_TASK_ALLOCATOR and __HAVE_ARCH_THREAD_ALLOCATOR with proper config switches.
--- arch/Kconfig | 8 ++++++++ arch/ia64/Kconfig | 2 ++ arch/ia64/include/asm/thread_info.h | 3 --- arch/sparc/Kconfig | 1 + arch/sparc/include/asm/thread_info_32.h | 2 -- kernel/fork.c | 7 +++---- 6 files changed, 14 insertions(+), 9 deletions(-)
arch/Kconfig +8 -0
@@ -152,6 +152,14 @@ config GENERIC_SMP_IDLE_THREAD config ARCH_INIT_TASK bool +# Select if arch has its private alloc_task_struct() function +config ARCH_TASK_STRUCT_ALLOCATOR + bool + +# Select if arch has its private alloc_thread_info() function +config ARCH_THREAD_INFO_ALLOCATOR + bool + config HAVE_REGS_AND_STACK_ACCESS_API bool help
arch/ia64/Kconfig +2 -0
@@ -35,6 +35,8 @@ config IA64 select GENERIC_IOMAP select GENERIC_SMP_IDLE_THREAD select ARCH_INIT_TASK + select ARCH_TASK_STRUCT_ALLOCATOR + select ARCH_THREAD_INFO_ALLOCATOR default y help The Itanium Processor Family is Intel's 64-bit successor to
arch/ia64/include/asm/thread_info.h +0 -3
@@ -54,8 +54,6 @@ 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))
@@ -84,7 +82,6 @@ struct thread_info {#endif #define end_of_stack (p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET) -#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR#define alloc_task_struct_node (node) \ ({ \ struct page *page = alloc_pages_node(node, GFP_KERNEL | __GFP_COMP, \
arch/sparc/Kconfig +1 -0
@@ -36,6 +36,7 @@ config SPARC32 def_bool !64BIT select GENERIC_ATOMIC64 select CLZ_TAB + select ARCH_THREAD_INFO_ALLOCATOR config SPARC64 def_bool 64BIT
arch/sparc/include/asm/thread_info_32.h +0 -2
@@ -80,8 +80,6 @@ register struct thread_info *current_thread_info_reg asm("g6");*/ #define THREAD_INFO_ORDER 1 -#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR - BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info_node, int)#define alloc_thread_info_node (tsk, node) BTFIXUP_CALL(alloc_thread_info_node)(node)
kernel/fork.c +3 -4
@@ -111,7 +111,7 @@ int nr_processes(void)return total; } -#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR +#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR static struct kmem_cache *task_struct_cachep;static inline struct task_struct *alloc_task_struct_node (int node)
@@ -128,8 +128,7 @@ static inline void free_task_struct(struct task_struct *tsk) }#endif -#ifndef __HAVE_ARCH_THREAD_INFO_ALLOCATOR - +#ifndef CONFIG_ARCH_THREAD_INFO_ALLOCATOR void __weak arch_release_thread_info (struct thread_info *ti) { }/*
@@ -243,7 +242,7 @@ void __init __weak arch_task_cache_init(void) { }void __init fork_init (unsigned long mempages) { -#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR +#ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR #ifndef ARCH_MIN_TASKALIGN #define ARCH_MIN_TASKALIGN L1_CACHE_BYTES#endif