* [PATCH 1/2] x86, xsave: fix non-lazy allocation of the xsave area [not found] <2be7032a-e4b6-4ce7-af53-532d77dbfb48@email.android.com> @ 2011-04-27 14:26 ` Hans Rosenfeld 2011-04-28 5:55 ` [tip:x86/xsave] " tip-bot for Hans Rosenfeld 2011-04-27 14:26 ` [PATCH 2/2] fork: avoid weak function arch_dup_task_struct Hans Rosenfeld 1 sibling, 1 reply; 7+ messages in thread From: Hans Rosenfeld @ 2011-04-27 14:26 UTC (permalink / raw) To: hpa Cc: brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel, Hans Rosenfeld A single static xsave area just for init is not enough, since there are more user processes that are directly executed by kernel threads. Add a call to a new arch-specific function to flush_old_exec(), which will in turn call fpu_alloc() to allocate a xsave area if necessary. Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com> --- arch/x86/include/asm/i387.h | 6 ------ arch/x86/include/asm/thread_info.h | 2 ++ arch/x86/kernel/process.c | 7 +++++++ fs/exec.c | 8 ++++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h index 989c0ac..0448f45 100644 --- a/arch/x86/include/asm/i387.h +++ b/arch/x86/include/asm/i387.h @@ -329,15 +329,9 @@ static inline void fpu_copy(struct fpu *dst, struct fpu *src) } extern void fpu_finit(struct fpu *fpu); -static union thread_xstate __init_xstate, *init_xstate = &__init_xstate; static inline void fpu_clear(struct fpu *fpu) { - if (!fpu_allocated(fpu)) { - BUG_ON(init_xstate == NULL); - fpu->state = init_xstate; - init_xstate = NULL; - } memset(fpu->state, 0, xstate_size); fpu_finit(fpu); set_used_math(); diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 0e691c6..07c8cfe 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -265,6 +265,8 @@ static inline void set_restore_sigmask(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); +extern int arch_prealloc_fpu(struct task_struct *tsk); +#define arch_prealloc_fpu arch_prealloc_fpu #define arch_task_cache_init arch_task_cache_init #endif #endif /* _ASM_X86_THREAD_INFO_H */ diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 0382f98..3edfbf2 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -26,6 +26,13 @@ struct kmem_cache *task_xstate_cachep; EXPORT_SYMBOL_GPL(task_xstate_cachep); +int arch_prealloc_fpu(struct task_struct *tsk) +{ + if (!fpu_allocated(&tsk->thread.fpu)) + return fpu_alloc(&tsk->thread.fpu); + return 0; +} + int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) { int ret; diff --git a/fs/exec.c b/fs/exec.c index 5e62d26..932b9ad 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1022,10 +1022,18 @@ void set_task_comm(struct task_struct *tsk, char *buf) perf_event_comm(tsk); } +#if !defined(arch_prealloc_fpu) +#define arch_prealloc_fpu(tsk) (0) +#endif + int flush_old_exec(struct linux_binprm * bprm) { int retval; + retval = arch_prealloc_fpu(current); + if (retval) + goto out; + /* * Make sure we have a private signal table and that * we are unassociated from the previous thread group. -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [tip:x86/xsave] x86, xsave: fix non-lazy allocation of the xsave area 2011-04-27 14:26 ` [PATCH 1/2] x86, xsave: fix non-lazy allocation of the xsave area Hans Rosenfeld @ 2011-04-28 5:55 ` tip-bot for Hans Rosenfeld 0 siblings, 0 replies; 7+ messages in thread From: tip-bot for Hans Rosenfeld @ 2011-04-28 5:55 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hans.rosenfeld, hpa, mingo, tglx Commit-ID: 300c6120b4653043e8a80b24e0483c0d223c5aac Gitweb: http://git.kernel.org/tip/300c6120b4653043e8a80b24e0483c0d223c5aac Author: Hans Rosenfeld <hans.rosenfeld@amd.com> AuthorDate: Wed, 27 Apr 2011 16:26:34 +0200 Committer: H. Peter Anvin <hpa@zytor.com> CommitDate: Wed, 27 Apr 2011 18:03:45 -0700 x86, xsave: fix non-lazy allocation of the xsave area A single static xsave area just for init is not enough, since there are more user processes that are directly executed by kernel threads. Add a call to a new arch-specific function to flush_old_exec(), which will in turn call fpu_alloc() to allocate a xsave area if necessary. Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com> Link: http://lkml.kernel.org/r/1303914395-841373-1-git-send-email-hans.rosenfeld@amd.com Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- arch/x86/include/asm/i387.h | 6 ------ arch/x86/include/asm/thread_info.h | 2 ++ arch/x86/kernel/process.c | 7 +++++++ fs/exec.c | 8 ++++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h index f410d16..41f1d7e 100644 --- a/arch/x86/include/asm/i387.h +++ b/arch/x86/include/asm/i387.h @@ -327,15 +327,9 @@ static inline void fpu_copy(struct fpu *dst, struct fpu *src) } extern void fpu_finit(struct fpu *fpu); -static union thread_xstate __init_xstate, *init_xstate = &__init_xstate; static inline void fpu_clear(struct fpu *fpu) { - if (!fpu_allocated(fpu)) { - BUG_ON(init_xstate == NULL); - fpu->state = init_xstate; - init_xstate = NULL; - } memset(fpu->state, 0, xstate_size); fpu_finit(fpu); set_used_math(); diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 0e691c6..07c8cfe 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -265,6 +265,8 @@ static inline void set_restore_sigmask(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); +extern int arch_prealloc_fpu(struct task_struct *tsk); +#define arch_prealloc_fpu arch_prealloc_fpu #define arch_task_cache_init arch_task_cache_init #endif #endif /* _ASM_X86_THREAD_INFO_H */ diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index d46cbe4..a70f620 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -26,6 +26,13 @@ struct kmem_cache *task_xstate_cachep; EXPORT_SYMBOL_GPL(task_xstate_cachep); +int arch_prealloc_fpu(struct task_struct *tsk) +{ + if (!fpu_allocated(&tsk->thread.fpu)) + return fpu_alloc(&tsk->thread.fpu); + return 0; +} + int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) { int ret; diff --git a/fs/exec.c b/fs/exec.c index 5e62d26..932b9ad 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1022,10 +1022,18 @@ void set_task_comm(struct task_struct *tsk, char *buf) perf_event_comm(tsk); } +#if !defined(arch_prealloc_fpu) +#define arch_prealloc_fpu(tsk) (0) +#endif + int flush_old_exec(struct linux_binprm * bprm) { int retval; + retval = arch_prealloc_fpu(current); + if (retval) + goto out; + /* * Make sure we have a private signal table and that * we are unassociated from the previous thread group. ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] fork: avoid weak function arch_dup_task_struct [not found] <2be7032a-e4b6-4ce7-af53-532d77dbfb48@email.android.com> 2011-04-27 14:26 ` [PATCH 1/2] x86, xsave: fix non-lazy allocation of the xsave area Hans Rosenfeld @ 2011-04-27 14:26 ` Hans Rosenfeld 2011-05-01 19:25 ` Andrew Morton 1 sibling, 1 reply; 7+ messages in thread From: Hans Rosenfeld @ 2011-04-27 14:26 UTC (permalink / raw) To: hpa Cc: brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel, Hans Rosenfeld Avoid potential gcc bug by not using a weak function for arch_dup_task_struct. Use an #ifdef'ed static function for archs that don't have a special arch_dup_task_struct implementation. Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com> --- arch/sh/include/asm/thread_info.h | 1 + arch/x86/include/asm/thread_info.h | 1 + kernel/fork.c | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h index ea2d508..2d27e1c 100644 --- a/arch/sh/include/asm/thread_info.h +++ b/arch/sh/include/asm/thread_info.h @@ -100,6 +100,7 @@ extern void free_thread_info(struct thread_info *ti); extern void arch_task_cache_init(void); #define arch_task_cache_init arch_task_cache_init extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); +#define arch_dup_task_struct arch_dup_task_struct extern void init_thread_xstate(void); #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 07c8cfe..ce97947 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -266,6 +266,7 @@ 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 int arch_prealloc_fpu(struct task_struct *tsk); +#define arch_dup_task_struct arch_dup_task_struct #define arch_prealloc_fpu arch_prealloc_fpu #define arch_task_cache_init arch_task_cache_init #endif diff --git a/kernel/fork.c b/kernel/fork.c index e7548de..6d929d0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -243,12 +243,13 @@ void __init fork_init(unsigned long mempages) init_task.signal->rlim[RLIMIT_NPROC]; } -int __attribute__((weak)) arch_dup_task_struct(struct task_struct *dst, - struct task_struct *src) +#ifndef arch_dup_task_struct +static int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) { *dst = *src; return 0; } +#endif static struct task_struct *dup_task_struct(struct task_struct *orig) { -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fork: avoid weak function arch_dup_task_struct 2011-04-27 14:26 ` [PATCH 2/2] fork: avoid weak function arch_dup_task_struct Hans Rosenfeld @ 2011-05-01 19:25 ` Andrew Morton 2011-05-01 22:59 ` H. Peter Anvin 0 siblings, 1 reply; 7+ messages in thread From: Andrew Morton @ 2011-05-01 19:25 UTC (permalink / raw) To: Hans Rosenfeld Cc: hpa, brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel On Wed, 27 Apr 2011 16:26:35 +0200 Hans Rosenfeld <hans.rosenfeld@amd.com> wrote: > Avoid potential gcc bug by not using a weak function for > arch_dup_task_struct. Use an #ifdef'ed static function for > archs that don't have a special arch_dup_task_struct implementation. The patch is unreviewable (and hence unusable) if you don't describe this "potential gcc bug". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fork: avoid weak function arch_dup_task_struct 2011-05-01 19:25 ` Andrew Morton @ 2011-05-01 22:59 ` H. Peter Anvin 2011-05-02 0:11 ` Andrew Morton 0 siblings, 1 reply; 7+ messages in thread From: H. Peter Anvin @ 2011-05-01 22:59 UTC (permalink / raw) To: Andrew Morton Cc: Hans Rosenfeld, brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel On 05/01/2011 12:25 PM, Andrew Morton wrote: > On Wed, 27 Apr 2011 16:26:35 +0200 Hans Rosenfeld <hans.rosenfeld@amd.com> wrote: > >> Avoid potential gcc bug by not using a weak function for >> arch_dup_task_struct. Use an #ifdef'ed static function for >> archs that don't have a special arch_dup_task_struct implementation. > > The patch is unreviewable (and hence unusable) if you don't describe > this "potential gcc bug". > http://lkml.indiana.edu/hypermail/linux/kernel/0804.3/3202.html -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fork: avoid weak function arch_dup_task_struct 2011-05-01 22:59 ` H. Peter Anvin @ 2011-05-02 0:11 ` Andrew Morton 2011-05-02 15:36 ` H. Peter Anvin 0 siblings, 1 reply; 7+ messages in thread From: Andrew Morton @ 2011-05-02 0:11 UTC (permalink / raw) To: H. Peter Anvin Cc: Hans Rosenfeld, brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel On Sun, 01 May 2011 15:59:12 -0700 "H. Peter Anvin" <hpa@zytor.com> wrote: > On 05/01/2011 12:25 PM, Andrew Morton wrote: > > On Wed, 27 Apr 2011 16:26:35 +0200 Hans Rosenfeld <hans.rosenfeld@amd.com> wrote: > > > >> Avoid potential gcc bug by not using a weak function for > >> arch_dup_task_struct. Use an #ifdef'ed static function for > >> archs that don't have a special arch_dup_task_struct implementation. > > > > The patch is unreviewable (and hence unusable) if you don't describe > > this "potential gcc bug". > > > > http://lkml.indiana.edu/hypermail/linux/kernel/0804.3/3202.html > gcc-4.1.0 and 4.1.1 were explicitly banned via a test in include/linux/compiler-gcc4.h for this reason. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fork: avoid weak function arch_dup_task_struct 2011-05-02 0:11 ` Andrew Morton @ 2011-05-02 15:36 ` H. Peter Anvin 0 siblings, 0 replies; 7+ messages in thread From: H. Peter Anvin @ 2011-05-02 15:36 UTC (permalink / raw) To: Andrew Morton Cc: Hans Rosenfeld, brgerst, tglx, mingo, suresh.b.siddha, eranian, robert.richter, Andreas.Herrmann3, x86, linux-kernel On 05/01/2011 05:11 PM, Andrew Morton wrote: > On Sun, 01 May 2011 15:59:12 -0700 "H. Peter Anvin"<hpa@zytor.com> wrote: > >> On 05/01/2011 12:25 PM, Andrew Morton wrote: >>> On Wed, 27 Apr 2011 16:26:35 +0200 Hans Rosenfeld<hans.rosenfeld@amd.com> wrote: >>> >>>> Avoid potential gcc bug by not using a weak function for >>>> arch_dup_task_struct. Use an #ifdef'ed static function for >>>> archs that don't have a special arch_dup_task_struct implementation. >>> >>> The patch is unreviewable (and hence unusable) if you don't describe >>> this "potential gcc bug". >> >> http://lkml.indiana.edu/hypermail/linux/kernel/0804.3/3202.html >> > > gcc-4.1.0 and 4.1.1 were explicitly banned via a test in > include/linux/compiler-gcc4.h for this reason. > OK, no issue then. Sorry for the noise. -hpa ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-05-02 15:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2be7032a-e4b6-4ce7-af53-532d77dbfb48@email.android.com>
2011-04-27 14:26 ` [PATCH 1/2] x86, xsave: fix non-lazy allocation of the xsave area Hans Rosenfeld
2011-04-28 5:55 ` [tip:x86/xsave] " tip-bot for Hans Rosenfeld
2011-04-27 14:26 ` [PATCH 2/2] fork: avoid weak function arch_dup_task_struct Hans Rosenfeld
2011-05-01 19:25 ` Andrew Morton
2011-05-01 22:59 ` H. Peter Anvin
2011-05-02 0:11 ` Andrew Morton
2011-05-02 15:36 ` H. Peter Anvin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox