提交 616c05d1 编写于 作者: V Vineet Gupta 提交者: Linus Torvalds

sh: move fpu_counter into ARCH specific thread_struct

Only a couple of arches (sh/x86) use fpu_counter in task_struct so it can
be moved out into ARCH specific thread_struct, reducing the size of
task_struct for other arches.

Compile tested sh defconfig + sh4-linux-gcc (4.6.3)
Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
Cc: Paul Mundt <paul.mundt@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 261adc9a
...@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) ...@@ -46,7 +46,7 @@ static inline void __unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
save_fpu(tsk); save_fpu(tsk);
release_fpu(regs); release_fpu(regs);
} else } else
tsk->fpu_counter = 0; tsk->thread.fpu_counter = 0;
} }
static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs) static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
......
...@@ -111,6 +111,16 @@ struct thread_struct { ...@@ -111,6 +111,16 @@ struct thread_struct {
/* Extended processor state */ /* Extended processor state */
union thread_xstate *xstate; union thread_xstate *xstate;
/*
* fpu_counter contains the number of consecutive context switches
* that the FPU is used. If this is over a threshold, the lazy fpu
* saving becomes unlazy to save the trap. This is an unsigned char
* so that after 256 times the counter wraps and the behavior turns
* lazy again; this to deal with bursty apps that only use FPU for
* a short time
*/
unsigned char fpu_counter;
}; };
#define INIT_THREAD { \ #define INIT_THREAD { \
......
...@@ -126,6 +126,16 @@ struct thread_struct { ...@@ -126,6 +126,16 @@ struct thread_struct {
/* floating point info */ /* floating point info */
union thread_xstate *xstate; union thread_xstate *xstate;
/*
* fpu_counter contains the number of consecutive context switches
* that the FPU is used. If this is over a threshold, the lazy fpu
* saving becomes unlazy to save the trap. This is an unsigned char
* so that after 256 times the counter wraps and the behavior turns
* lazy again; this to deal with bursty apps that only use FPU for
* a short time
*/
unsigned char fpu_counter;
}; };
#define INIT_MMAP \ #define INIT_MMAP \
......
...@@ -44,7 +44,7 @@ void __fpu_state_restore(void) ...@@ -44,7 +44,7 @@ void __fpu_state_restore(void)
restore_fpu(tsk); restore_fpu(tsk);
task_thread_info(tsk)->status |= TS_USEDFPU; task_thread_info(tsk)->status |= TS_USEDFPU;
tsk->fpu_counter++; tsk->thread.fpu_counter++;
} }
void fpu_state_restore(struct pt_regs *regs) void fpu_state_restore(struct pt_regs *regs)
......
...@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, ...@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
#endif #endif
ti->addr_limit = KERNEL_DS; ti->addr_limit = KERNEL_DS;
ti->status &= ~TS_USEDFPU; ti->status &= ~TS_USEDFPU;
p->fpu_counter = 0; p->thread.fpu_counter = 0;
return 0; return 0;
} }
*childregs = *current_pt_regs(); *childregs = *current_pt_regs();
...@@ -189,7 +189,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next) ...@@ -189,7 +189,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)
unlazy_fpu(prev, task_pt_regs(prev)); unlazy_fpu(prev, task_pt_regs(prev));
/* we're going to use this soon, after a few expensive things */ /* we're going to use this soon, after a few expensive things */
if (next->fpu_counter > 5) if (next->thread.fpu_counter > 5)
prefetch(next_t->xstate); prefetch(next_t->xstate);
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
...@@ -207,7 +207,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next) ...@@ -207,7 +207,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)
* restore of the math state immediately to avoid the trap; the * restore of the math state immediately to avoid the trap; the
* chances of needing FPU soon are obviously high now * chances of needing FPU soon are obviously high now
*/ */
if (next->fpu_counter > 5) if (next->thread.fpu_counter > 5)
__fpu_state_restore(); __fpu_state_restore();
return prev; return prev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册